掲示板

Class Loader Problem

11年前 に Balaji Chopparapu によって更新されました。

Class Loader Problem

New Member 投稿: 22 参加年月日: 10/10/08 最新の投稿
Hi,
I have two portlet projects namely PA and PB. I am building services (using liferay service builder) in PA and the generated jar(PA-service.jar) is added to classpath of PB(WEB-INF\lib). From PB I am able to access(execute) all the methods in EmployeeLocalServiceUtil.java like create*,find* except add*. I am getting ‘ERROR [ClassLoaderProxy:73] java.lang.NoSuchMethodException’ when try to execute “add*”

Please suggest how to overcome this class loader problem? I am able to solve this bug by placing PA-service.jar in tomcat global classpath “tomcat-6.0.29\lib\ext” but our current architecture doesn’t allow to change tomcat global classpath.

Thanks in advance
Balaji Chopparapu
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Class Loader Problem

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
You have to call the create...() method to create the instance that you're passing to add...().

You must remember that all that you do in SB is crossing the class loader boundary between one war and another (the service consumer and the service provider).

Any class loader errors will be due to failure in managing the crossing of that class loader boundary.
11年前 に Balaji Chopparapu によって更新されました。

RE: Class Loader Problem

New Member 投稿: 22 参加年月日: 10/10/08 最新の投稿
Hi David,

Thanks for your reply. I was able to call create* method but not add*/update*. How can I over come this situation?

Please suggest.
Balaji
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Class Loader Problem

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
// create a new pojo instance
MyPojo pojo = MyPojoLocalServiceUtil.createMyPojo(keyValue);

// update the fields in the new pojo instance
pojo.setXxx(value);

// add the new instance to the data store
MyPojoLocalServiceUtil.addMyPojo(pojo);

// pull an instance to update
pojo = MyPojoLocalServiceUtil.getMyPojo(anotherKeyValue);

// update the fields in the retrieved instance
pojo.setXxx(value);

// save the changes back to the data store.
MyPojoLocalServiceUtil.updateMyPojo(pojo);
11年前 に Balaji Chopparapu によって更新されました。

RE: Class Loader Problem

New Member 投稿: 22 参加年月日: 10/10/08 最新の投稿
Hi David,

We really appreciate your unconditional help in getting me to over come this issue. The below steps works perfectly well in
PA but not in PB. When I try to do it in PB it giving exception "ERROR [ClassLoaderProxy:73] java.lang.NoSuchMethodException." Do we have any limitation in using services exposed by one portlet app into another.

This works perflectly well when services exposed are in global class path of container.

// create a new pojo instance
MyPojo pojo = MyPojoLocalServiceUtil.createMyPojo(keyValue);

// update the fields in the new pojo instance
pojo.setXxx(value);

// add the new instance to the data store
MyPojoLocalServiceUtil.addMyPojo(pojo);

Thanks in Advance
Balaji
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Class Loader Problem

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
Can you provide the full stack trace from PB? There may be something going on here instead of a class loader problem...