Deploy Spring Sample to Liferay 3.6.1/Tomcat

August 31, 2005 – 22:06 | java, spring

Just upgraded to Liferay Pro 3.6.1 (Tomcat 5.5.9). Smooth process as usual with just a couple minor points make a note of.

A couple folks seem to have some problem getting the Spring Portlet sample portlet content rendered. I just gave it a try and it appears to work fine with my installation. I guess you need to use Liferay's hot deploy script, and follow the steps listed in the Development guide. Copying the portlet directory into tomcat's webapps directory won't work because Liferay won't get a chance to do its own magic - like, make a little "adjustment" to your web.xml. :)

And here goes the latest version of the deployer script I used, in case you need it:

XML:
  1. <project name="portlet-deployer" basedir="." default="deploy">
  2.     <target name="init">
  3.         <property environment="env" />
  4.  
  5.         <!-- Tomcat -->
  6.  
  7.     <property name="app.server.type" value="tomcat" />
  8.     <property name="app.server.dir" value="e:\tomcats\5.5.9-liferay" />
  9.     <property name="app.server.deploy.dir" value="${app.server.dir}/webapps" />
  10.  
  11.         <path id="project.classpath">
  12.             <pathelement location="${env.ANT_HOME}/lib/ant.jar" />
  13.             <fileset dir="${app.server.dir}/shared/lib" />
  14.             <pathelement location="${app.server.dir}/common/lib/servlet-api.jar" />
  15.         </path>
  16.     </target>
  17.  
  18.     <target name="deploy" depends="init">
  19.         <java classname="com.liferay.portal.tools.PortletDeployer"
  20.             classpathref="project.classpath"
  21.             fork="true"
  22.             newenvironment="true">
  23.  
  24.                 <!-- Required Arguments -->
  25.  
  26.                 <jvmarg value="-Ddeployer.base.dir=./" />
  27.                 <jvmarg value="-Ddeployer.dest.dir=${app.server.deploy.dir}" />
  28.                 <jvmarg value="-Ddeployer.app.server.type=${app.server.type}" />
  29.                 <jvmarg value="-Ddeployer.portlet.taglib.dtd=${liferay.dir}/WEB-INF/tld/liferay-portlet.tld" />
  30.  
  31.                 <!-- Optional Arguments -->
  32.  
  33.                 <jvmarg value="-Ddeployer.jboss.prefix=1" />
  34.         <jvmarg value="-Ddeployer.tomcat.lib.dir=${app.server.dir}/shared/lib" />
  35.  
  36.                 <!-- Dependent Libraries -->
  37.  
  38.                 <arg value="${app.server.deploy.dir}/ext.ear/portal-web-complete.war/WEB-INF/lib/util-taglib.jar" />
  39.                 <arg value="${app.server.deploy.dir}/ext.ear/lib/util-java.jar" />
  40.                 <!--<arg value="${app.server.deploy.dir}/ext.ear/lib/util-jsf.jar" />-->
  41.         </java>
  42.     </target>
  43. </project>

Here's one note to myself in the future - if you get something like this while running the hot deployer script:

CODE:
  1. [java] Deploying spring-portlet-sample.war
  2.      [java]   Expanding: .\spring-portlet-sample.war into 20050831212239171
  3.      [java]   Modifying 20050831212239171\WEB-INF\web.xml
  4.      [java] java.lang.NullPointerException
  5.      [java]     at com.liferay.util.FileUtil.listFiles(FileUtil.java:245)
  6.      [java]     at com.liferay.util.FileUtil.listFiles(FileUtil.java:237)
  7.      [java]     at com.liferay.portal.tools.BaseDeployer.deployDirectory(BaseDeployer.java:229)
  8.      [java]     at com.liferay.portal.tools.BaseDeployer.deployFile(BaseDeployer.java:272)
  9.      [java]     at com.liferay.portal.tools.BaseDeployer.deploy(BaseDeployer.java:188)
  10.      [java]     at com.liferay.portal.tools.BaseDeployer.<init>(BaseDeployer.java:81)
  11.      [java]     at com.liferay.portal.tools.PortletDeployer.</init><init>(PortletDeployer.java:71)
  12.      [java]     at com.liferay.portal.tools.PortletDeployer.main(PortletDeployer.java:63)

It's because the tomcat lib directory set in the script doesn't exist.

Trackback from your site, or follow the comments in RSS.
  1. 11 Responses to “Deploy Spring Sample to Liferay 3.6.1/Tomcat”

  2. HI Jing Xue,

    thanks for your advice, i've finally got it working!
    i had to use the expert tomcat installation and hot-deploy the spring sample portlet by using the deployer script provided by liferay (of course modify it to work for tomcat as recommended by you).
    i've also checked that the web.xml of the spring war is modified by the deploy script in a different way than that of liferay 3.2! that's why manually copying the war into the webapps didn't work.
    the main difference is an additional set of servlet-mappings for each portlet (this was not needed in 3.2).

    By Jose Choi on Sep 1, 2005

  3. Hi Jing Xue and Jose Choi

    Thank you for your extremely useful explaination.

    I got it work successfully.

    By Mike Tran on Sep 3, 2005

  4. HI Jing Xue,

    Can you help me? I am developing JSF Portlets and I'd like to ask you for a help of integrating JSF Portlets into Liferay Jboss-Tomcat. I create JSF Portlets by using Sun Java Studio Creator 2 Early Access.

    Sorry if this message is not in the right place.

    Thanks in advance,
    Ronald
    netsearcher2000@yahoo.com

    By Ronald on Sep 7, 2005

  5. All
    Please tell me the stpes to deploy the my own portlet war in liferay3.6.1
    Defining a listener class in web.xml for liferay com.liferay.portal.servlet.PortletContextListener

    is this mandatory?
    and two liferay xml files are they mandatory files to deploy the myown portlet war?
    can any one help out

    Thanks in advance
    Malligarjunan

    By Malligarjunan S on Nov 11, 2005

  6. 12.

    Hi,

    I have the Spring portlets fully working with Liferay. However, I now want to put them into a category of portlets in Liferay. e.g. Wiki

    Have you ever tried such things ?

    PS I once followed the instruction at http://opensource2.atlassian.com/confluence/spring/display/JSR168/Home but yet it does not work at all.

    By Mike Tran on Dec 4, 2005

  7. Mike,

    I'm not sure I understand what you mean by "put them into a category of portlets".

    --Jing

    By Jing Xue on Dec 5, 2005

  8. Hi,

    The portlet categories I mentioned are the ones you could see in the "Content and Layout" function page. I realised this function is extremely useful when I am an admin and trying to configure pages for many user groups who are not Power Users (can not add portlets into theirs pages themselves).

    Every Liferay has some builtin categories such as Community, Development, Wiki and so on.

    If I want to put the sample portlet into one of them and even a new one that I could create. How could I do that ?

    -Mike

    By Mike Tran on Dec 8, 2005

  9. Mike,
    I've never tried to do that myself, but I've noticed a liferay-display.xml under liferay/WEB-INF that looks like defining the category-portlet relationship. I'm not sure that's supposed to be hand edited though.

    Did you ask around on the liferay forum?
    --Jing

    By Jing Xue on Dec 8, 2005

  10. Hi,

    There are some posts relating to this issue. They did show some instructions to create liferay-display.xml and liferay-portlet.xml manually.

    After trying all of them, the portlet still does not show up in my case. I saw some peoples achieved it and some are the same as me.

    I posted my question and yet not get any answer. I thought you might have experienced this.

    Would you like to try it ?

    -Mike

    By Mike Tran on Dec 8, 2005

  11. Hi,
    actually i am deploying the spring samples("Books portlet") on Liferay 4.1.1. The portlets appear in the list of portlets. I am also able to add the portlet "books" to the main page but i am getting the following error in the portlet content: The requested resource (/spring-samples/WEB-INF/servlet/view) is not available

    Can anyone help me on this issue?

    Thanks,
    Kenz K.

    By kenz on Sep 1, 2006

  12. make a entry of in web.xml to resolve the proble /WEB-INF/servlet/view) is not available

    ViewRendererServlet
    org.springframework.web.servlet.ViewRendererServlet
    1

    ViewRendererServlet
    /WEB-INF/servlet/view

    By Amit on Jul 31, 2008

Post a Comment