16 Aug 2006, 10:14am
Projects:
by

7 comments

  • JSP Precompilation For Maven2 Project

    You can precompile JSP as part of your Maven2 project build by using Maven2 JSPC Plugin.

    Follow the usage guide for copy-paste samples to add insert-fragment in web.xml file and jspc-maven-plugin + maven-war-plugin as part of build plugins in pom.xml file.

    Here are some problems that I encountered while adding JSP precompilation to Wish:

    Some of the JSPs use SiteMesh taglib and since the application only needed it as part of the war package, I originally set the dependency scope to be runtime. This causes JSPC to complain because it needs the library in the classpath while compiling the JSPs.

    Embedded error: file:E:/tazmania/eclipse-workspace/wish/src/main/webapp/404.jsp(1,1)
    The absolute uri: http://www.opensymphony.com/sitemesh/decorator cannot be resolved
    in either web.xml or the jar files deployed with this application
    

    The solution is to change the scope from runtime to compile so SiteMesh becomes available during JSP precompilation.

    The next problem is with JSP API and Jasper Runtime.

    E:\tazmania\eclipse-workspace\wish\target\jsp-source\jsp\login_jsp.java:[194,68]
    cannot resolve symbol
    symbol  : class JspTag
    location: package tagext
    

    E:\tazmania\eclipse-workspace\wish\target\jsp-source\jsp\_404_jsp.java:[7,61]
    package org.apache.jasper.runtime does not exist
    The solution is to add the missing libraries as dependencies in pom.xml file.

    <dependency>
      <groupId>tomcat</groupId>
      <artifactId>jasper-runtime</artifactId>
      <version>5.5.12</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
      <scope>compile</scope>
    </dependency>
    

    Note that you might want to specify the library versions based on the target environment you’re going to deploy the application to.

     

    Recent Posts

    Recent Comments

    • Cliffano Subagio: Good to hear about your opportunity to visit Japan, I’m sure you will have a great...
    • Kayla: I’m going to Japan for two week this summer. Our sister city is Tsubame, Japan and my school has an...
    • poseidonfu: thanks,Very effective
    • anonymous: I really enjoyed both the last lecture and the book. I don’t think that theres anyone that I look up...
    • dioni: The thing I hate about HK is how people shove and push in the queue. Can’t they be civilized?!! I kept...

    Most Commented Posts

    Linkroll