掲示板

Service Builder error: Cannot invoke clone() on the primitive type long

10年前 に nithin varghese によって更新されました。

Service Builder error: Cannot invoke clone() on the primitive type long

New Member 投稿: 13 参加年月日: 13/05/02 最新の投稿
Hi ,

I've created a project with portlet plug-in and included liferay service builder (service.xml) . I've added 3 entities with names Tool, ToolAliasName and ToolType. and provided mapping between entities as shown below.


<!--?xml version="1.0" encoding="UTF-8"?-->

<service-builder package-path="com.usop.tool">
	<author>NK87569</author>
	<namespace>usop</namespace>
	<entity name="Tool" local-service="true" remote-service="false">

		<column name="toolId" type="long" primary="true" />
		<column name="toolName" type="String" />
		<column name="sourceUrl" type="String" />
		<column name="reportIP" type="String" />
		<column name="toolAliasNameId" type="long" entity="ToolAliasName" mapping-key="toolAliasNameId" />
		<column name="toolTypeId" type="long" entity="ToolType" mapping-key="toolTypeId" />
		<order by="asc">
			<order-column name="toolId" />
		</order>
		<finder name="ToolAliasNameId" return-type="Collection">
			<finder-column name="toolAliasNameId" />
		</finder>
	</entity>
	<entity name="ToolAliasName" local-service="true" remote-service="false">

		<column name="toolAliasNameId" type="long" primary="true" />
		<column name="toolAliasName" type="String" />
		<order by="asc">
			<order-column name="toolAliasNameId" />
		</order>
	</entity>
	<entity name="ToolType" local-service="true" remote-service="false">

		<column name="toolTypeId" type="long" primary="true" />
		<column name="toolTypeName" type="String" />
		<order by="asc">
			<order-column name="toolTypeId" />
		</order>
	</entity>
	
</service-builder>


But when I build the services I'm getting following error in the console:

[Console output redirected to fileemoticon:\Liferay Latest\workSpace\.metadata\.plugins\com.liferay.ide.eclipse.sdk\sdk.log]
Buildfile: D:\Liferay Latest\liferay-plugins-sdk-6.1.1\portlets\usop-tools-portlet\build.xml
build-service:
[echo] Loading jar:file:/D:/Liferay%20Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
[echo] May 3, 2013 4:23:11 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
[echo] INFO: Global shared lib directory /D:/Liferay Latest/liferay-plugins-sdk-6.1.1/lib/
[echo] May 3, 2013 4:23:11 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
[echo] INFO: Global lib directory /D:/Liferay Latest/server-1/tomcat-7.0.27/lib/ext/
[echo] May 3, 2013 4:23:11 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
[echo] INFO: Portal lib directory /D:/Liferay Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/
[echo] Loading jar:file:/D:/Liferay%20Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
[echo] Loading jar:file:/D:/Liferay%20Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
[echo] Loading file:/D:/Liferay%20Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/portal-ext.properties
[echo] May 3, 2013 4:23:12 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
[echo] INFO: Properties for portal loaded from [file:/D:/Liferay%20Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/portal-ext.properties, jar:file:/D:/Liferay%20Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties, jar:file:/D:/Liferay%20Latest/server-1/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties]
[echo] Building Tool
[echo] Building ToolAliasName
[echo] Building ToolType
compile-java:
[javac] Compiling 1 source file to D:\Liferay Latest\liferay-plugins-sdk-6.1.1\portlets\usop-tools-portlet\docroot\WEB-INF\service-classes
[javac] ----------
[javac] 1. ERROR in D:\Liferay Latest\liferay-plugins-sdk-6.1.1\portlets\usop-tools-portlet\docroot\WEB-INF\service\com\usop\tool\model\ToolClp.java (at line 195)
[javac] clone.setToolAliasNameId((ToolAliasName)getToolAliasNameId().clone());
[javac] ^^^^^^^^^^^^^^^^^^
[javac] The method setToolAliasNameId(long) in the type ToolClp is not applicable for the arguments (ToolAliasName)
[javac] ----------
[javac] 2. ERROR in D:\Liferay Latest\liferay-plugins-sdk-6.1.1\portlets\usop-tools-portlet\docroot\WEB-INF\service\com\usop\tool\model\ToolClp.java (at line 195)
[javac] clone.setToolAliasNameId((ToolAliasName)getToolAliasNameId().clone());
[javac] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[javac] Cannot invoke clone() on the primitive type long
[javac] ----------
[javac] 3. ERROR in D:\Liferay Latest\liferay-plugins-sdk-6.1.1\portlets\usop-tools-portlet\docroot\WEB-INF\service\com\usop\tool\model\ToolClp.java (at line 196)
[javac] clone.setToolTypeId((ToolType)getToolTypeId().clone());
[javac] ^^^^^^^^^^^^^
[javac] The method setToolTypeId(long) in the type ToolClp is not applicable for the arguments (ToolType)
[javac] ----------
[javac] 4. ERROR in D:\Liferay Latest\liferay-plugins-sdk-6.1.1\portlets\usop-tools-portlet\docroot\WEB-INF\service\com\usop\tool\model\ToolClp.java (at line 196)
[javac] clone.setToolTypeId((ToolType)getToolTypeId().clone());
[javac] ^^^^^^^^^^^^^^^^^^^^^^^
[javac] Cannot invoke clone() on the primitive type long
[javac] ----------
[javac] 4 problems (4 errors)

BUILD FAILED
D:\Liferay Latest\liferay-plugins-sdk-6.1.1\build-common-plugin.xml:221: The following error occurred while executing this line:
D:\Liferay Latest\liferay-plugins-sdk-6.1.1\build-common.xml:95: Compile failed; see the compiler error output for details.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I couldn't identify the issue. if I remove the mapping between entities and build the service , it will successfully build.Is there any problem with below mapping..??

<column name="toolAliasNameId" type="long" entity="ToolAliasName" mapping-key="toolAliasNameId" />
		<column name="toolTypeId" type="long" entity="ToolType" mapping-key="toolTypeId" />


please suggest me a solution for this.
10年前 に nithin varghese によって更新されました。

RE: Service Builder error: Cannot invoke clone() on the primitive type long

New Member 投稿: 13 参加年月日: 13/05/02 最新の投稿
Hi all,

I've waited for one week but no reply from anyone...!! only 150+ views...
Is there anybody who got the same error... please let me know....
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: Service Builder error: Cannot invoke clone() on the primitive type long

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
Take off the entity and mapping key for the column; it's what is driving SB nuts...

SB just doesn't handle relationships very well. The entity attribute is providing an EJBName (SB internal artifact) to the column and, since it is an object instead of a primitive, tries to invoke the clone() method on the object but the column is still just a primitive.

Instead of trying to treat SB like an ORM (which it's not), you would get the Tool object then perform a subsequent get for the ToolNameAlias using the id manually. SB will be just fine and generate/compile the code w/o any problem.
10年前 に nithin varghese によって更新されました。

RE: Service Builder error: Cannot invoke clone() on the primitive type long

New Member 投稿: 13 参加年月日: 13/05/02 最新の投稿
Thanks David for your support. but still I've one doubt on
SB just doesn't handle relationships very well.
.
Is that means ,we can't define any relationships in service.xml . Then what is the use of column tag attributes : entity & mapping-key.

<column name="toolAliasNameId" type="long" entity="ToolAliasName" mapping-key="toolAliasNameId" />


or will this support only one-to-many relationship. please give a clarification on this.
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: Service Builder error: Cannot invoke clone() on the primitive type long

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
SB is not like Hibernate or JPA. It fails when handling full object graphs, even inconsequential object graphs of a single parent/child relationship.

SB does excel at supporting single table <-> entity ORM, however.

If you check out Liferay's service.xml, you'll find that they generally use few (if any) relationships in the entities; you're given the keys but expected to call the service layer to get children or other related tables.

The crux of the issue is crossing the class loader boundary. In crossing the boundary, instances from one class loader are serialized and restored in another class loader. It's fairly easy to do this for a single entity or a collection of entities, but gets rather complicated when trying to do this for an object graph of entities (retrieving may work, but how do you deal with persisting changes to the object graph after serializing back to the service provider's class loader, ...). Where Liferay chose to handle this case, it seemed to be under specific circumstances and rather limited.

Personally I use basic entities and, for one to many, will define a finder that returns a collection using the parent key as the finder column, but you're still left to deal w/ add/remove on your own.

Not as cool as using a regular hibernate/JPA implementation, but it works in the portal environment w/o having to deal w/ class loader issues.
9年前 に Mahesh Nanavate によって更新されました。

RE: Service Builder error: Cannot invoke clone() on the primitive type long

New Member 投稿: 5 参加年月日: 15/03/12 最新の投稿
Hi All,

We too are facing the same issue in liferay-portal-tomcat-6.2-ce-ga2. Is there any plan to address this in the future releases ?

Thanks and Regards
Mahesh
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Service Builder error: Cannot invoke clone() on the primitive type long

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
No. Note that comes from an outsider, but I feel fairly confident just saying an outright no for any 6.x release.

It's hard to cross the class loader boundary, and collections are significantly harder to add on top of that.

There is potential with LR7 and OSGi implementations. With OSGi your services should be deployed within the Liferay container eliminating the need to cross the class loader, so possibly the relationship management might be left in (I'm not far enough in my review to say whether that's in or out yet).