掲示板
RE: How can I use a service in SDK?
13年前 に Pierpaolo Cira によって更新されました。
How can I use a service in SDK and 5.1.2? (Null Beanlocator)
Regular Member 投稿: 141 参加年月日: 10/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
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
13年前 に jelmer kuperus によって更新されました。
RE: How can I use a service in SDK?
Liferay Legend 投稿: 1191 参加年月日: 10/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
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
13年前 に Pierpaolo Cira によって更新されました。
RE: How can I use a service in SDK?
Regular Member 投稿: 141 参加年月日: 10/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:
Any idea?
Thanks again
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
13年前 に Pierpaolo Cira によって更新されました。
RE: How can I use a service in SDK?
Regular Member 投稿: 141 参加年月日: 10/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.
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.
13年前 に Iván Bautista Bautista によって更新されました。
RE: How can I use a service in SDK?
Regular Member 投稿: 166 参加年月日: 10/01/25 最新の投稿
Hi Pierpaolo,
Do you try using MyLocalServiceUtil?? Maybe this will works.
Do you try using MyLocalServiceUtil?? Maybe this will works.
13年前 に Peter Shin によって更新されました。
RE: How can I use a service in SDK?
Regular Member 投稿: 121 参加年月日: 07/09/24 最新の投稿
hi pierpaolo, try adding this listener to your web.xml
<listener>
<listener-class>com.liferay.portal.kernel.spring.context.PortletContextLoaderListener</listener-class>
</listener>
13年前 に Pierpaolo Cira によって更新されました。
RE: How can I use a service in SDK?
Regular Member 投稿: 141 参加年月日: 10/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
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
13年前 に Iván Rodríguez Bautista によって更新されました。
RE: How can I use a service in SDK?
Regular Member 投稿: 166 参加年月日: 10/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.
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.
13年前 に Pierpaolo Cira によって更新されました。
RE: How can I use a service in SDK?
Regular Member 投稿: 141 参加年月日: 10/02/26 最新の投稿
Thnks again for you answer.
This solution doesn't work...
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?
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....
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...
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?