Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sunil Kulkarni
Service Builder in hook throwing NullPointerException
September 12, 2012 10:32 AM
Answer

Sunil Kulkarni

Rank: Junior Member

Posts: 94

Join Date: June 24, 2011

Recent Posts

Hello,

I am using liferay 6.1.1 CE version.

I have to create a new table for extending the blogs functionality. For this I have to create a new table. So I have created service.xml which is following.
<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">

<service-builder package-path="com.blogs">
<author>Sunil Kulkarni</author>
<namespace>Blogs</namespace>
<entity name="Todo" local-service="true" remote-service="true">

<!-- PK fields -->
<column name="entryId" type="long" primary="true" />

<column name="userId" type="long" />
<column name="blogEntryId" type="long" />


<finder name="UserId" return-type="Collection">
<finder-column name="userId" />
</finder>

<finder name="BlogEntryId" return-type="Collection">
<finder-column name="blogEntryId" />
</finder>

<finder name="B_U" return-type="BlogsFavorite">
<finder-column name="blogEntryId" />
<finder-column name="userId" />
</finder>

</entity>
</service-builder>

I have created a source package as com.blogs and kept service.xml file into it.

I have also added new target in build.xml of the hook. So my build.xml from hook looks like following :
<?xml version="1.0"?>
<!DOCTYPE project>

<project name="My-hook" basedir="." default="deploy">
<import file="../build-common-hook.xml" />

<target name="build-service-blogs">
<antcall target="build-service">
<param name="service.file" value="${basedir}/src/com/blogs/service.xml" />
</antcall>
</target>

</project>


When I run this target from command prompt following log will be generated.
Logs :
c:\Sunil\Liferay_All\Liferay6.1.1\Setup\liferay-plugins-sdk-6.1.1\hooks\My-hook>ant build-service-blogs
Buildfile: c:\Sunil\Liferay_All\Liferay6.1.1\Setup\liferay-plugins-sdk-6.1.1\hooks\My-hook\build.xml

build-service-blogs:

build-service:
Loading jar:file:/C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
Sep 12, 2012 5:22:14 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Global shared lib directory /C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-plugins-sdk-6.1.1/lib/
Sep 12, 2012 5:22:14 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Global lib directory /C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/lib/ext/
Sep 12, 2012 5:22:14 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Portal lib directory /C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/
Sep 12, 2012 5:22:15 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Properties for portal loaded from [file:/C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/portal-ext.properties, jar:file:/C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay
-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties, jar:file:/C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-I
NF/lib/portal-impl.jar!/portal.properties]
Loading jar:file:/C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
Loading jar:file:/C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
Loading file:/C:/Sunil/Liferay_All/Liferay6.1.1/Setup/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/portal-ext.properties
java.lang.NullPointerException
at com.liferay.portal.kernel.io.unsync.UnsyncStringReader.<init>(UnsyncStringReader.java:34)
at com.liferay.util.xml.XMLSafeReader.<init>(XMLSafeReader.java:25)
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:409)
at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:155)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder._getContentDocument(ServiceBuilder.java:4002)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder._getContent(ServiceBuilder.java:3925)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:559)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:151)

Created dir: c:\Sunil\Liferay_All\Liferay6.1.1\Setup\liferay-plugins-sdk-6.1.1\hooks\My-hook\docroot\WEB-INF\service-classes

compile-java:
Copied 8 empty directories to 8 empty directories under c:\Sunil\Liferay_All\Liferay6.1.1\Setup\liferay-plugins-sdk-6.1.1\hooks\My-hook\docroot\WEB-INF\service-classes
Compiling 18 source files to c:\Sunil\Liferay_All\Liferay6.1.1\Setup\liferay-plugins-sdk-6.1.1\hooks\My-hook\docroot\WEB-INF\service-classes
Building zip: c:\Sunil\Liferay_All\Liferay6.1.1\Setup\liferay-plugins-sdk-6.1.1\hooks\My-hook\docroot\WEB-INF\lib\My-hook-service.jar
Deleting directory c:\Sunil\Liferay_All\Liferay6.1.1\Setup\liferay-plugins-sdk-6.1.1\hooks\My-hook\docroot\WEB-INF\service-classes

BUILD SUCCESSFUL
Total time: 17 seconds

I am unable to understand that why server builder is throwing NullPointerException.
Sunil Kulkarni
RE: Service Builder in hook throwing NullPointerException
September 12, 2012 11:46 AM
Answer

Sunil Kulkarni

Rank: Junior Member

Posts: 94

Join Date: June 24, 2011

Recent Posts

Hello,

Problem is solved.

The service.xml file path that I have mentioned was wrong. Therefore service builder is throwing NullPointerException.
Hung Quang
RE: Service Builder in hook throwing NullPointerException
May 2, 2013 1:44 AM
Answer

Hung Quang

Rank: New Member

Posts: 11

Join Date: April 8, 2013

Recent Posts

Hi Sunil Kulkarni!
what is your path? Can you talk detail?
I have problem same you.
Please help me!
Sunil Kulkarni
RE: Service Builder in hook throwing NullPointerException
May 4, 2013 8:10 AM
Answer

Sunil Kulkarni

Rank: Junior Member

Posts: 94

Join Date: June 24, 2011

Recent Posts

Sorry for the late reply.

Path for service.xml should be following:

<target name="build-service-blogs">
<antcall target="build-service">
<param name="service.input.file" value="${basedir}/docroot/WEB-INF/src/com/blogs/service.xml" />
</antcall>
</target>
Anh Lee
RE: Service Builder in hook throwing NullPointerException
May 23, 2013 1:57 AM
Answer

Anh Lee

Rank: New Member

Posts: 4

Join Date: February 24, 2013

Recent Posts

Hi Quang Hung,
Did you resolve your problem? emoticon
Hung Quang
RE: Service Builder in hook throwing NullPointerException
May 23, 2013 6:44 PM
Answer

Hung Quang

Rank: New Member

Posts: 11

Join Date: April 8, 2013

Recent Posts

Anh Lee:
Hi Quang Hung,
Did you resolve your problem? emoticon



hi! sorry for reply late!

I'm tried but i don't reslove problem. I created ext plugin, I wirten service for my ext. I had same problem.huhu
Sagar A Vyas
RE: Service Builder in hook throwing NullPointerException
July 21, 2013 9:28 PM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Sunil Kulkarni:
Sorry for the late reply.

Path for service.xml should be following:

<target name="build-service-blogs">
<antcall target="build-service">
<param name="service.input.file" value="${basedir}/docroot/WEB-INF/src/com/blogs/service.xml" />
</antcall>
</target>



Sunil,

Thanks for this reply it helps.

Could you please let me know excatly where we needs keep this target...I meant in which file ?

Thanks,
Sagar Vyas
Sunil Kulkarni
RE: Service Builder in hook throwing NullPointerException
August 6, 2013 5:15 AM
Answer

Sunil Kulkarni

Rank: Junior Member

Posts: 94

Join Date: June 24, 2011

Recent Posts

in build.xml of portlet/hook.
Vilmos Papp
RE: Service Builder in hook throwing NullPointerException
August 6, 2013 5:19 AM
Answer

Vilmos Papp

LIFERAY STAFF

Rank: Liferay Master

Posts: 521

Join Date: October 21, 2010

Recent Posts

Hi,

I think you cannot use ServiceBuilder from EXT plugin as it's deprecated. See details here: http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/developing-an-ext-plugin

Cheers,
Vilmos