Fórum

unable to store my data in mysql using Service builder.

srinivasa rao, modificado 10 Anos atrás.

unable to store my data in mysql using Service builder.

Regular Member Postagens: 189 Data de Entrada: 29/01/14 Postagens Recentes
unable to store my data in mysql using Service builder.
srinivasa rao, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Regular Member Postagens: 189 Data de Entrada: 29/01/14 Postagens Recentes
srinivasa rao:
unable to store my data in mysql using Service builder.



Hi ALL,

I developed one portlet by using service builder.i wrote some sample code(ex:upload a pic),every thing is showing fine in console,but data is not stored in Mysql.

Here My view.jsp:

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>

<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%@ page import="com.liferay.portal.kernel.util.Validator" %>
<%@ page import="javax.portlet.PortletPreferences" %>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>

<portlet:actionURL var="addPhotoActionURL" name="addPhoto">
</portlet:actionURL>
<aui:form action="<%= addPhotoActionURL %>" method="post" name="fm" enctype="multipart/form-data">
<aui:input name="title" value="" label="Photo Title"/>
<aui:input name="photo" value="" type="file" label="Select Photo"/>
<aui:button-row>
<aui:button type="submit" />
</aui:button-row>
</aui:form>


Service.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd">
<service-builder package-path="com.liferay.sample">
<author>srinivasaraom</author>
<namespace>SAMPLE</namespace>
<entity name="Photo" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="photoId" type="long" primary="true" />
<!-- Audit fields -->
<column name="photoName" type="String" />
<column name="owner" type="long" />
</entity>
</service-builder>

Logs:

Buildfile: D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\build.xml
build-service:
[copy] Copying 5 files to D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\classes
[jar] Building MANIFEST-only jar: D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\build-service-classpath.jar
[delete] Deleting: D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\build-service-classpath.jar.manifest
[delete] Deleting: D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\build-service-classpath.jar
[echo] Loading jar:file:/D:/Wellness%20Liferay%20portal/bundles/tomcat-7.0.42/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
[echo] Loading jar:file:/D:/Wellness%20Liferay%20portal/bundles/tomcat-7.0.42/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
[echo] Loading jar:file:/D:/Wellness%20Liferay%20portal/bundles/tomcat-7.0.42/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
[echo] Building Photo
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\src\com\liferay\sample\service\persistence\PhotoPersistenceImpl.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\service\persistence\PhotoPersistence.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\service\persistence\PhotoUtil.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\src\com\liferay\sample\model\impl\PhotoModelImpl.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\model\PhotoModel.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\src\com\liferay\sample\model\impl\PhotoCacheModel.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\model\PhotoClp.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\model\PhotoWrapper.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\model\PhotoSoap.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\service\messaging\ClpMessageListener.java
[echo] Writing D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service\com\liferay\sample\service\ClpSerializer.java
[mkdir] Created dir: D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service-classes
compile-java:
[copy] Copied 7 empty directories to 7 empty directories under D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service-classes
[javac] Compiling 53 source files to D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service-classes
[zip] Building zip: D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\lib\Sample-service-portlet-service.jar
[delete] Deleting directory D:\Wellness Liferay portal\liferay-plugins-sdk-6.2.0\portlets\Sample-service-portlet\docroot\WEB-INF\service-classes
BUILD SUCCESSFUL
Total time: 9 seconds


I tried lot of examples,but i unable to see my data in database...

Regards,
Srinivas.
thumbnail
Harish Kumar, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
Are you getting the form parameters in your controller class addPhoto method?
Can you see the table sample_photo in your DB.
Could you please paste your addPhoto method code snippet here.
srinivasa rao, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Regular Member Postagens: 189 Data de Entrada: 29/01/14 Postagens Recentes
Hi Harish,

Sample_photo table is not created in database.

here is my method:

UploadRequest uploadRequest=PortalUtil.getUploadPortletRequest(actionRequest);
File photoImage = uploadRequest.getFile("photo");
String title=ParamUtil.getString(uploadRequest,"title");
InputStream fis =new FileInputStream(photoImage);
OutputBlob dataOutputBlob = new OutputBlob(fis, photoImage.length());
Photo photo=PhotoLocalServiceUtil.createPhoto(CounterLocalServiceUtil.increment());
photo.setPhotoName(title);
photo.setOwner(10153);
photo.setData(dataOutputBlob);
photo=PhotoLocalServiceUtil.addPhoto(photo);
thumbnail
Harish Kumar, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
table is created when you deploy the portlet for first time. So table should be there in the database.
Try to print parameter values in the method to make sure that you are getting parameter value.
srinivasa rao, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Regular Member Postagens: 189 Data de Entrada: 29/01/14 Postagens Recentes
even i didnt see any auto generated java files in my workspace..they will created in tomact server.

how to get that into my workspace?
srinivasa rao, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Regular Member Postagens: 189 Data de Entrada: 29/01/14 Postagens Recentes
Harish Kumar:
table is created when you deploy the portlet for first time. So table should be there in the database.
Try to print parameter values in the method to make sure that you are getting parameter value.


i change the database name in portal-ext.properties and restart the server..

i noticed tht one error in console..

11:33:54,831 ERROR [localhost-startStop-1][JDBCExceptionReporter:82] Table 'test.lock_' doesn't exist
11:33:55,168 WARN [localhost-startStop-1][ReleaseLocalServiceImpl:171] Table 'test.release_' doesn't exist
11:33:55,169 INFO [localhost-startStop-1][ReleaseLocalServiceImpl:84] Create tables and populate with default data
thumbnail
Sandip Patel, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Regular Member Postagens: 205 Data de Entrada: 05/01/11 Postagens Recentes
srinivasa rao:
Hi Harish,

Sample_photo table is not created in database.

here is my method:

UploadRequest uploadRequest=PortalUtil.getUploadPortletRequest(actionRequest);
File photoImage = uploadRequest.getFile("photo");
String title=ParamUtil.getString(uploadRequest,"title");
InputStream fis =new FileInputStream(photoImage);
OutputBlob dataOutputBlob = new OutputBlob(fis, photoImage.length());
Photo photo=PhotoLocalServiceUtil.createPhoto(CounterLocalServiceUtil.increment());
photo.setPhotoName(title);
photo.setOwner(10153);
photo.setData(dataOutputBlob);
photo=PhotoLocalServiceUtil.addPhoto(photo);



Hi,

I think you miss one line in your servicel.xml file for "data" attribute.
<column name="data" type="Blob" />

photo.setData(dataOutputBlob); // This line indicate that you have "data" field in your Model class. So entry of that field must be map with service.xml file.

HTH

Regards,
Sandip Patel
srinivasa rao, modificado 10 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Regular Member Postagens: 189 Data de Entrada: 29/01/14 Postagens Recentes
Sandip Patel:
srinivasa rao:
Hi Harish,

Sample_photo table is not created in database.

here is my method:

UploadRequest uploadRequest=PortalUtil.getUploadPortletRequest(actionRequest);
File photoImage = uploadRequest.getFile("photo");
String title=ParamUtil.getString(uploadRequest,"title");
InputStream fis =new FileInputStream(photoImage);
OutputBlob dataOutputBlob = new OutputBlob(fis, photoImage.length());
Photo photo=PhotoLocalServiceUtil.createPhoto(CounterLocalServiceUtil.increment());
photo.setPhotoName(title);
photo.setOwner(10153);
photo.setData(dataOutputBlob);
photo=PhotoLocalServiceUtil.addPhoto(photo);



Hi,

I think you miss one line in your servicel.xml file for "data" attribute.
<column name="data" type="Blob" />

photo.setData(dataOutputBlob); // This line indicate that you have "data" field in your Model class. So entry of that field must be map with service.xml file.

HTH

Regards,
Sandip Patel



Hi Sandip,

confused alot...i created every thing it showing build successfully,but table is not shown in database and java and sql files are also not visible in workspace.
thumbnail
Jennis Vaishnav, modificado 7 Anos atrás.

RE: unable to store my data in mysql using Service builder.

Junior Member Postagens: 59 Data de Entrada: 01/02/17 Postagens Recentes
Till, I know, If you are using service builder you need to build-service so, that it will create table and make necessary dao and implementation classes, check in web-inf folder for sql folder and other generated classes. Hope this helps, anyways I'm not sure for this one, but can give it a try.