| Alessandro Cosenza | : | call servlet not work in production environment | 
    | 
 | 
 | 
 | 
    | 
 | 
 | hello, I have a servlet with mapping /abc (in web.xml). | 
    | 
 | 
 | 
 | 
    | 
 | 
 | In local mode, calling -> localhost:8080/abc => works. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | In production environment -> www.xyz.com/abc => I get "resource not found". | 
    | 
 | 
 | 
 | 
    | 
 | 
 | I use virtual hosting (Guest community has www.xyz.com as public URL   configured in Manages Pages panel) with Apache Web Server on top of   Tomcat. Maybe this could be the problem? | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Any suggestions ? I don't know what to do... | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Thanks in advance. | 
    | 
 | 
 | 
 | 
    | Mazhar Anwar | : | I think you need to set a mount point in your apache web server httpd.conf as follows, | 
    | 
 | 
 | 
 | 
    | 
 | 
 | # Sets a mount point from a context to a Tomcat worker. In this case will allow access (forward the request) to the console. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | JkMount /abc/* ajp13 | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Regards, | 
    | 
 | 
 | 
 | 
    | Alessandro Cosenza | : | Thanks for your fast answer. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | I just tried to insert that entry in my conf file but it doesn't work.. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | A strange thing is that when I enter that URL (this already happened   before), from my log console I can see that init() method of the servlet   gets called. Instead service() method doesn't. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | More ideas? I'm a little bit frustrated. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Thanks however. | 
    | 
 | 
 | 
 | 
    | Alessandro Cosenza | : | Content of my conf file is | 
    | 
 | 
 | 
 | 
    | 
 | 
 |  | 
    | 
 | 
 | 
 | 
    | 
 | 
 | First I tried this | 
    | 
 | 
 | 
 | 
    | 
 | 
 |  | 
    | 
 | 
 | 
 | 
    | 
 | 
 | add ProxyPass at the end of the file and it doesn't work. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Then I tried to add JkMount at the end | 
    | 
 | 
 | 
 | 
    | 
 | 
 |  | 
    | 
 | 
 | 
 | 
    | 
 | 
 | and for a few moments it worked (service() got called) but I got exceptions (from MainServlet, ecc.). | 
    | 
 | 
 | 
 | 
    | 
 | 
 | After a new restart it began to stop working again. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Strange.... | 
    | Mazhar Anwar | : | Hi Aless... | 
    | 
 | 
 | 
 | 
    | 
 | 
 | I wanna some more idea about the servlet. Have you written servlet in   Liferay Context(ROOT)? Can you tell me your url-pattern for the servlet?   What's the response you wanna to generate? | 
    | 
 | 
 | 
 | 
    | 
 | 
 | If you want to call the servlet from the portlet it will be better if   you use serveResource() method of portletAPI rather than defining a new   servlet. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Regards, | 
    | 
 | 
 | 
 | 
    | Alessandro Cosenza | : | I'm using Liferay 5.2.3. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | I have written servlet in Ext environment and modified web.xml as following: | 
    | 
 | 
 | 
 | 
    | 
 | 
 |  | 
    | 
 | 
 | 
 | 
    | 
 | 
 | I need this servlet to interact with Facebook API. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | In service() method I have the following instructions | 
    | 
 | 
 | 
 | 
    | 
 | 
 |  | 
    | 
 | 
 | 
 | 
    | 
 | 
 | I have also tried to call servlet from processAction() of a portlet. How   could I use serveResource method? do you think it would be useful for   me? | 
    | 
 | 
 | 
 | 
    | Mazhar Anwar | : | Hi Aless, | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Is your servlet working on local environment without any exception and   you achieved expected functionality? If yes then don't bother about   serveResource() method. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Anyway, ServeRecource() methods is added in portlet API to serve static   and dynamic content from the portlet. For more information about it you   can refer following links. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | http://www.ibm.com/developerworks/websphere/library/techarticles/0803_hepper/0803_hepper.html | 
    | 
 | 
 | 
 | 
    | 
 | 
 | AND | 
    | 
 | 
 | 
 | 
    | 
 | 
 | http://www.bluesunrise.com/portlet-api/javax/portlet/ResourceServingPortlet.html | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Further, for using serveResource method in liferay portlet, simple steps are | 
    | 
 | 
 | 1- Create an instance of ResourceURL in you jsp as | 
    | 
 | 
 | ResourceURL resourceURL = renderResponse.createResourceURL(); | 
    | 
 | 
 | resourceURL.setParameter("parameterName", parameterValue); | 
    | 
 | 
 | 
 | 
    | 
 | 
 | 2- Assign some event to hit the url using javascript or on form submit. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | <a href='javascipt:document.location.href="<%= resourceURL.toString() %>";'> | 
    | 
 | 
 | 
 | 
    | 
 | 
 | 3- define the method in your portlet class where you have define processAction(), as | 
    | 
 | 
 | public void serveResource( | 
    | 
 | 
 | ResourceRequest resourceRequest, ResourceResponse resourceResponse) | 
    | 
 | 
 | throws IOException, PortletException { | 
    | 
 | 
 | 
 | 
    | 
 | 
 | ...... | 
    | 
 | 
 | your code goes here.. | 
    | 
 | 
 | ... you can get parameters using resourceRequest Object. | 
    | 
 | 
 | } | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Note: in your portlet class you need to import javax.portlet.ResourceRequest and javax.portlet.ResourceResponse classes. | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Hope This will help you  | 
    | 
 | 
 | 
 | 
    | 
 | 
 | Regards, | 
    | 
 | 
 | 
 | 
 
No comments:
Post a Comment