フォーラム

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

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Pierpaolo Cira
How can I use a service in SDK and 5.1.2? (Null Beanlocator)
2010/11/03 11:42
答え

Pierpaolo Cira

ランク: Regular Member

投稿: 141

参加年月日: 2010/02/26

最近の投稿

Hi all,

I'm writing an hook and I need to use some classes provided by another portlet service.

For example I have a customPortlet (in SDK) containing a customPortlet-service.jar (made by "ant build service").
If I put the jar in my hook lib folder, then I'm able to compile, deploy and run the hook... but when the hook tries to access to the service, it throws a NullPointerException.

I think that the service is not properly initialized.

Any idea or suggestion will be very appreciated.

Thank you
Jelmer Kuperus
RE: How can I use a service in SDK?
2010/11/02 15:33
答え

Jelmer Kuperus

ランク: Liferay Legend

投稿: 1192

参加年月日: 2010/03/10

最近の投稿

It's a bug. Classloader proxies are currently broken in liferay 6.0.5

See: http://www.liferay.com/community/forums/-/message_boards/message/5968217

relevant jira issues are LPS-12372 LPS-12791 and LPS-12792

attached you will find a patch that can be applied against the liferay 6.0.5 classes to restore the functionality. This means you will have to build liferay from source
添付ファイル: liferay-bugs-LPS-12372+LPS-12791+LPS-12792.patch (13.5k)
Pierpaolo Cira
RE: How can I use a service in SDK?
2010/11/03 1:41
答え

Pierpaolo Cira

ランク: Regular Member

投稿: 141

参加年月日: 2010/02/26

最近の投稿

Thank you for you reply... but.. I forgot to write that I'm using Liferay Portal 5.1.2.
I'm searching on the web for similar issue... but without any result.

Do you think the bug you wrote exists since 5.x version... or can I have another problem?


EDIT:
I worked in the same way of http://www.liferay.com/community/wiki/-/wiki/Main/Using+Class+Loader+Proxy+classes+to+share+plugins+services
But in the second comment Jakub Liska wrote:
sharing services then calls from "localContext A" to "otherContext B" EntityLocalServiceUtil.methods() are realized on freshly loaded class loaded by "localContext A" classloader without _service field initialized by spring.
Therefor if (_service == null) is true.


Any idea?

Thanks again
Pierpaolo Cira
RE: How can I use a service in SDK?
2010/11/03 11:41
答え

Pierpaolo Cira

ランク: Regular Member

投稿: 141

参加年月日: 2010/02/26

最近の投稿

Another indication, supponing my bean is named "My".

Using MyServiceUtil.getService() I receive:
19:38:46,827 ERROR [PortletBeanLocatorUtil:52] BeanLocator is null
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set

Using MyUtil.getPersistence() I get a null object.

Please, can you help me?
Any suggestion or consideration will be very appreciated.
Iván Rodríguez Bautista
RE: How can I use a service in SDK?
2010/11/04 10:18
答え

Iván Rodríguez Bautista

ランク: Regular Member

投稿: 166

参加年月日: 2010/01/25

最近の投稿

Hi Pierpaolo,

Do you try using MyLocalServiceUtil?? Maybe this will works.
Peter Shin
RE: How can I use a service in SDK?
2010/11/04 13:07
答え

Peter Shin

LIFERAY STAFF

ランク: Regular Member

投稿: 122

参加年月日: 2007/09/24

最近の投稿

hi pierpaolo, try adding this listener to your web.xml

1<listener>
2    <listener-class>com.liferay.portal.kernel.spring.context.PortletContextLoaderListener</listener-class>
3</listener>
Pierpaolo Cira
RE: How can I use a service in SDK?
2010/11/17 9:23
答え

Pierpaolo Cira

ランク: Regular Member

投稿: 141

参加年月日: 2010/02/26

最近の投稿

Hi Ivàn and Peter... thank you for your reply... but I tried both your solutions, but without success.

However I think that I find the solution.
If a portlet (x) needs to use the service layer defined by another portlet (y), and the y-service.jar is in the Tomcat lib/ext folder, then in the portlet x, I need to copy the service.properties and the files it requires (under src/META-INF) from the portlet y.

Then I followed your suggestion.

I hope it isn't conceptually wrong.

Now I'm going to test it in a hook.

Thanks again.

Pierpaolo
Iván Rodríguez Bautista
RE: How can I use a service in SDK?
2010/11/18 0:14
答え

Iván Rodríguez Bautista

ランク: Regular Member

投稿: 166

参加年月日: 2010/01/25

最近の投稿

In theory, you just have to access to service throught the jars thats the portlet "y" generates. Is strange that this doesn,t work....

Did you try to add the project of portlet "y" to "x" java build path (the second option in project->properties->java build path?? With ext and the rest of the portlets works, maybe this will helps you.
Pierpaolo Cira
RE: How can I use a service in SDK?
2010/11/19 7:45
答え

Pierpaolo Cira

ランク: Regular Member

投稿: 141

参加年月日: 2010/02/26

最近の投稿

Thnks again for you answer.

Iván Rodríguez Bautista:
In theory, you just have to access to service throught the jars thats the portlet "y" generates. Is strange that this doesn,t work....

emoticon

Iván Rodríguez Bautista:

Did you try to add the project of portlet "y" to "x" java build path (the second option in project->properties->java build path?? With ext and the rest of the portlets works, maybe this will helps you.

This solution doesn't work... emoticon
Infact "Java build path" is only for compile purpose, and not regards deployment.

PS: I'm working in Plugin mode and not ext.

Thanks again

Other idea about the solution I found?