フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Balaji Chopparapu
Class Loader Problem
2012/06/11 5:23
答え

Balaji Chopparapu

ランク: New Member

投稿: 22

参加年月日: 2010/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
David H Nebinger
RE: Class Loader Problem
2012/06/11 5:37
答え

David H Nebinger

ランク: Liferay Legend

投稿: 7250

参加年月日: 2006/09/01

最近の投稿

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.
Balaji Chopparapu
RE: Class Loader Problem
2012/06/11 10:40
答え

Balaji Chopparapu

ランク: New Member

投稿: 22

参加年月日: 2010/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
David H Nebinger
RE: Class Loader Problem
2012/06/11 10:49
答え

David H Nebinger

ランク: Liferay Legend

投稿: 7250

参加年月日: 2006/09/01

最近の投稿

 1// create a new pojo instance
 2MyPojo pojo = MyPojoLocalServiceUtil.createMyPojo(keyValue);
 3
 4// update the fields in the new pojo instance
 5pojo.setXxx(value);
 6
 7// add the new instance to the data store
 8MyPojoLocalServiceUtil.addMyPojo(pojo);
 9
10// pull an instance to update
11pojo = MyPojoLocalServiceUtil.getMyPojo(anotherKeyValue);
12
13// update the fields in the retrieved instance
14pojo.setXxx(value);
15
16// save the changes back to the data store.
17MyPojoLocalServiceUtil.updateMyPojo(pojo);
Balaji Chopparapu
RE: Class Loader Problem
2012/06/12 12:05
答え

Balaji Chopparapu

ランク: New Member

投稿: 22

参加年月日: 2010/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
David H Nebinger
RE: Class Loader Problem
2012/06/13 5:51
答え

David H Nebinger

ランク: Liferay Legend

投稿: 7250

参加年月日: 2006/09/01

最近の投稿

Can you provide the full stack trace from PB? There may be something going on here instead of a class loader problem...