Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Alex Belt
Custom Servlet in Liferay 5.2.3
January 23, 2013 1:43 PM
Answer

Alex Belt

Rank: Junior Member

Posts: 49

Join Date: October 9, 2012

Recent Posts

Hi Everyone,

I've created a servlet that uses some Liferay classes in a plug-in project. I've put the servlet mapping in the plug-in's web.xml as suggested here:
http://issues.liferay.com/browse/LEP-2297

The servlet extends another class which extends HttpServlet, so I took the init() code from the com.liferay.portal.kernel.servlet.PortalDelegateServlet and put it in the custom servlet so it would be registered with the PortalDelegatorServlet. However, whenever I try to reach the servlet from a browser (http://localhost:8080/delegate/servlet-name) as a test that the servlet is reachable, I keep getting this:

javax.servlet.ServletException: No servlet registred for context servlet-name
com.liferay.portal.kernel.servlet.PortalDelegatorServlet.service(PortalDelegatorServlet.java:89)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:193)
com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:271)
com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
com.liferay.portal.servlet.filters.threadlocalcache.ThreadLocalCacheFilter.processFilter(ThreadLocalCacheFilter.java:55)
com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:94)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)


I embedded some logging code in the servlet's init() method to verify that it's getting invoked, but the logging code isn't even being executed. At this point I have to conclude that the servlet is not getting registered properly for use. What I don't understand is, why?

I've tried reaching it using a number of different paths, /delegate/servlet-name, /servlet-name, /plugin-name/servlet-name, all with the same result. I know I'm overlooking something obvious, I just can't figure out what it is. Any suggestions?

Thanks,
Alex
Alex Belt
RE: Custom Servlet in Liferay 5.2.3
January 29, 2013 8:10 AM
Answer

Alex Belt

Rank: Junior Member

Posts: 49

Join Date: October 9, 2012

Recent Posts

I figured out how to solve the issue. I'm embarassed to say it, it was simple and I completely overlooked it. I created the servlet in a plug-in project and overrode the auth.public.paths in the portal.properties. Servlet access solved.