Reputation: 448
(and if so, how?)
I have a Liferay portlet that was built using service builder that provides services to other portlets and I am wondering if I can use the same jar in my servlets. So far I haven't been successful. I tried creating a portlet and tried calling the same services from that portlet and that didn't work either. So I must be missing something in the configuration of the portlet and servlet that allows those services to be utilized. What did I miss?
Running Liferay 6.1.1 Tomcat (7) bundle on Windows if that makes a difference...
Upvotes: 2
Views: 1526
Reputation: 1402
Make sure your servlet uses the PortalDelegateServlet
of Liferay. Otherwise, it will not have access to the Liferay service API (which eventually is used by the classes of your service builder generated classes).
<?xml version="1.0" encoding="UTF-8"?>
<web-app ...>
...
<servlet>
<servlet-name>my-servlet</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortalDelegateServlet</servlet-class>
<init-param>
<param-name>servlet-class</param-name>
<param-value>org.example.YourOwnServlet</param-value>
</init-param>
<init-param>
<param-name>sub-context</param-name>
<param-value>do-something</param-value>
</init-param>
<servlet>
</web-app>
Don't forget to fill out the correct init parameters:
servlet-class
is the class representing your servletsub-context
is the subcontext your servlet should listen toWhen deployed, your servlet will be accessible through the following URL:
http://localhost:8080/delegate/do-something
Upvotes: 4