Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pete Helgren
BeanLocatorException when accessing LR portal services from Servlet
November 29, 2012 11:18 AM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

Successfully built and deployed a Liferay portlet using the service builder and deployed it in the LR 6.1.1 ce Tomcat bundle. I also have a servlet deployed to the same Tomcat instance that uses services exposed by the portlet. I put the -services.jar of the portlet in the WEB-INF/lib folder of the servlet but when I call those services I see the following:

Nov 28, 2012 10:51:52 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Unable to locate deployment context from portlet properties
Nov 28, 2012 10:51:52 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Unable to locate deployment context from portal properties
Nov 28, 2012 10:51:58 AM com.liferay.portal.kernel.log.Jdk14LogImpl error
SEVERE: BeanLocator is null for servlet context MyServices-portlet
Nov 28, 2012 10:52:07 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [LectureManagerServlet] in context with path threw exception
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set for servlet context MyServices-portlet

The error occurs in ClpSerializer.getServletContextName() as it attempts to load the class. I am stepping through the code in the portlet when I get the error so I can't quite figure out *what* bean it is trying to locate (since I am in the portlet, it obviously has the correct jar.)

I saw many references to the the "BeanLocator has not been set for servlet context..." error but none of the suggested fixes seems to work. Perhaps because of the way the service is being called?

Thanks for any pointers...

And to add to the original post:

This error occurs in 6.1.1ce Tomcat bundle AND 6.0.6ce Tomcat bundle but NOT in 6.0.6ce Glassfish bundle. So why would this work with Glassfish (3.0.1) and not with Tomcat in 6.0.6 and 6.1.1 ? All I can think of is that GF is properly loading classes but somehow Tomcat is not (but that is just a guess...)
David H Nebinger
RE: BeanLocatorException when accessing LR portal services from Servlet
November 29, 2012 12:12 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7027

Join Date: September 1, 2006

Recent Posts

Try adding an empty portlet.properties file into your classes folder...

I had issues recently allowing a servlet to invoke the XxxLocalServiceUtil classes, and I believe the portlet.properties addition fixed it.

Also include a higher number for load on startup in web.xml to allow the portal and the plugins time to come up before your servlet starts as this could be a matter of timing (servlet is starting before the portlet providing the service has started).
Pete Helgren
RE: BeanLocatorException when accessing LR portal services from Servlet
November 29, 2012 1:05 PM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

Thanks David. I did see a post that mentioned that trick and I had added it to the 6.1.1 Tomcat bundle I deployed. Taking a look at the 6.0.6 deployed portlet, it already had that portlet.propeties file.

Let me give you just a bit more info. I am using MyEclipse with the LR IDE plugin installed. I am creating a new portal project, copying in a services.xml from another project and then generating the services and deploying the portlet to TC from within MyEclipse.

My servlet is just a web app that serves up a single page and prompts a user for information and then validates that information by calling methods in the portlet services jar. I deployed that app using the MyEclipse deployment tool. I can step through my code and into the code within the -portlet-services.jar created by LR but when I get to the ....LocalService.class.getName() method it throws a "BeanLocator is null for servlet context" error (I have seen many, many posts for this error with no simple resolution) This occurs when the code within the getService method it trying to retrieve the InvokableLocalService class.

One more variable (and perhaps clue). This works in GF 3.0.1 and LR 6.0.6 but the portlet war was generated by a Netbeans IDE and not MyEclipse. I am going to attempt to deploy original portlet created by the service builder in Netbeans and see if that makes a difference (I don't use Netbeans...I inherited this project from someone who developed using Netbeans). What is interesting about the Netbeans generated portlet is that it carries the name MyServices.war and when I generated the MyServices portlet, MyEclipse generated it as MyServices-portlet.war. Netbeans created the services jar as MyServices-service.jar and MyEclipse generated it MyServices-portlet-services.jar. It is probably inconsequential that the naming is generated differently since I haven't mixed and matched the jars and wars but I am mentioning it *just* in case there is some setting I need to tweak.

Thanks again. I am planning to take a Developer Training course but it isn't coming up until February so until then I just need to get over a few hurdles......

Pete
Pete Helgren
RE: BeanLocatorException when accessing LR portal services from Servlet
December 5, 2012 5:56 AM
Answer

Pete Helgren

Rank: Regular Member

Posts: 126

Join Date: April 7, 2011

Recent Posts

I am still stuck here. What I need an answer to at this point is:

Can a servlet use portlet services when deployed to the same servlet container and if so, how do you go about doing that? IOW, what configuration steps need to be taken on the portlet side (if any) and on the servlet side (if any).

There has got to be a way to do this....