Forums

Home » Liferay Portal » česky a slovensky

Combination View Flat View Tree View
Threads [ Previous | Next ]
Daniel Breitner
Can`t Store Liferay Service Entity ´with composite primary key
January 7, 2012 1:40 PM
Answer

Daniel Breitner

Rank: Junior Member

Posts: 89

Join Date: July 16, 2008

Recent Posts

Hi you all !

Quick question:

I defined a Service Entity like this:

1<entity name="Test" local-service="true" remote-service="false">
2        <column name="part1" type="long" primary="true" />
3        <column name="part2" type="long" primary="true" />
4        <column name="part3" type="long" />
5    </entity>


"part1" and "part2" are forming a Primary key.

A class called TestPK has already been created for me.

To store a new "Test" object, I need first to create a new TestPK and use it to store the Test object.

1TestPK testpk= new TestPK(someValue, anotherValue);
2TestLocalServiceUtil.createTest(testpk)


But whenever I do this I get the following exception:

121:26:12,708 ERROR [ClassLoaderProxy:70] java.lang.IllegalArgumentException: argument type mismatch
2java.lang.IllegalArgumentException: argument type mismatch
3    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
4    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
5    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
6    at java.lang.reflect.Method.invoke(Method.java:597)
7    at com.liferay.portal.kernel.util.ClassLoaderProxy._invoke(ClassLoaderProxy.java:246)
Alexey Kakunin
RE: Can`t Store Liferay Service Entity ´with composite primary key
February 1, 2013 4:12 AM
Answer

Alexey Kakunin

Rank: Expert

Posts: 370

Join Date: July 7, 2008

Recent Posts

Hi Daniel!
Since ClassLoaderProxy used, I suppose you defined services in one portlet - and trying to use them from another portlet.
Is it your situation?

==
Alexey Kakunin
EmDev Limited
Joaquin Cabal
RE: Can`t Store Liferay Service Entity ´with composite primary key
March 18, 2012 5:01 PM
Answer

Joaquin Cabal

Rank: Junior Member

Posts: 49

Join Date: September 7, 2009

Recent Posts

Hi Daniel, What Liferay version are you using?
Harish Kumar
RE: Can`t Store Liferay Service Entity ´with composite primary key
May 8, 2012 3:59 AM
Answer

Harish Kumar

Rank: Expert

Posts: 336

Join Date: July 31, 2010

Recent Posts

Hi Daniel!

I've used the same and its working fine.

I am using LR 6.1EE and defined services in one portlet and accessing in another portlet.
David H Nebinger
RE: Can`t Store Liferay Service Entity ´with composite primary key
May 8, 2012 5:45 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7252

Join Date: September 1, 2006

Recent Posts

Daniel Breitner:
1TestPK testpk= new TestPK(someValue, anotherValue);
2TestLocalServiceUtil.createTest(testpk)


But whenever I do this I get the following exception:

121:26:12,708 ERROR [ClassLoaderProxy:70] java.lang.IllegalArgumentException: argument type mismatch
2java.lang.IllegalArgumentException: argument type mismatch
3    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
4    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
5    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
6    at java.lang.reflect.Method.invoke(Method.java:597)
7    at com.liferay.portal.kernel.util.ClassLoaderProxy._invoke(ClassLoaderProxy.java:246)


This is a class loader issue. You cannot create the instance in the portlet consuming the service and pass it to the portlet providing the service.

In the portlet providing the service, edit the TestServiceImpl class and make a "Test createTest(long someValue, long anotherValue);" method that invokes the create process and returns the instance. Portlet consuming the service would use this method.