This are the steps to generate this
1] create a portlet plugin through
mvn archetype:generate -DarchetypeArtifactId=liferay-portlet-archetype -DarchetypeGroupId=com.liferay.maven.archetypes -DarchetypeVersion=6.1.0 -DarchetypeCatalog=local,remote -DartifactId=sample-portlet -DgroupId=foo.bar.portlet.portlet1 -Dversion=1.0-SNAPSHOT
2] add service.xml under src/main/webapp/WEB-INF/ folder, content of service.xml as follows :-
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd"> <service-builder package-path="foo.bar.portlets.services"> <author>whatever</author> <namespace>FF</namespace> <entity name="Foo" local-service="true" remote-service="true"> <!-- PK fields --> <column name="fooId" type="long" primary="true" /> <!-- Audit fields --> <column name="companyId" type="long" /> <column name="userId" type="long" /> <column name="userName" type="String" /> <column name="createDate" type="Date" /> <column name="modifiedDate" type="Date" /> <!-- Other fields --> <column name="field1" type="String" /> <column name="field2" type="boolean" /> <column name="field3" type="int" /> <column name="field4" type="Date" /> <column name="field5" type="String" /> <!-- Order --> <order by="asc"> <order-column name="field1" /> </order> <!-- Finder methods --> <finder name="Field2" return-type="Collection"> <finder-column name="field2" /> </finder> </entity> </service-builder>
3] Run the following command (got properties set accordingly in maven myProfile)
mvn liferay:build-service -P myProfile
4] End up with NPE, following is the stack trace
- Refreshed the configuration of all components
- Properties for jar:file:/..../maven_repo/com/liferay/portal/portal-impl/6.1.0/po
rtal-impl-6.1.0.jar!/portal loaded from [jar:file:/..../maven_repo/com/liferay/por
tal/portal-impl/6.1.0/portal-impl-6.1.0.jar!/portal.properties]
Loading jar:file:/..../maven_repo/com/liferay/portal/portal-impl/6.1.0/portal-impl
-6.1.0.jar!/portal.properties
Building Foo
java.lang.NullPointerException
at com.liferay.portal.tools.servicebuilder.ServiceBuilder._getJavaClass(
ServiceBuilder.java:4221)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModelWr
apper(ServiceBuilder.java:2242)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(Service
Builder.java:670)
at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(Service
Builder.java:430)
at com.liferay.maven.plugins.ServiceBuilderMojo.doExecute(ServiceBuilder
Mojo.java:119)
at com.liferay.maven.plugins.ServiceBuilderMojo.execute(ServiceBuilderMo
jo.java:59)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)