掲示板

unable to store my data in mysql using Service builder.

10年前 に srinivasa rao によって更新されました。

unable to store my data in mysql using Service builder.

Regular Member 投稿: 189 参加年月日: 14/01/29 最新の投稿
unable to store my data in mysql using Service builder.
10年前 に srinivasa rao によって更新されました。

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

Regular Member 投稿: 189 参加年月日: 14/01/29 最新の投稿
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
10年前 に Harish Kumar によって更新されました。

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

Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
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.
10年前 に srinivasa rao によって更新されました。

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

Regular Member 投稿: 189 参加年月日: 14/01/29 最新の投稿
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
10年前 に Harish Kumar によって更新されました。

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

Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
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.
10年前 に srinivasa rao によって更新されました。

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

Regular Member 投稿: 189 参加年月日: 14/01/29 最新の投稿
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?
10年前 に srinivasa rao によって更新されました。

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

Regular Member 投稿: 189 参加年月日: 14/01/29 最新の投稿
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
10年前 に Sandip Patel によって更新されました。

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

Regular Member 投稿: 205 参加年月日: 11/01/05 最新の投稿
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
10年前 に srinivasa rao によって更新されました。

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

Regular Member 投稿: 189 参加年月日: 14/01/29 最新の投稿
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
7年前 に Jennis Vaishnav によって更新されました。

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

Junior Member 投稿: 59 参加年月日: 17/02/01 最新の投稿
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.