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.

    Related Posts:

    1 Sep 2006, 7:37am
    by Martin Gilday

    reply

    Thanks for this. I just had to make a slight change to use the jstl libraries.

    taglibs
    standard
    1.1.2

    jstl
    jstl
    1.1.2

    1 Sep 2006, 7:38am
    by Martin Gilday

    reply

    Sorry that took out the xml formatting.
    It was 2 dependencies (groupId, artifactId, version)

    16 Jan 2007, 11:16am
    by Grzegorz Loniewski

    reply

    The problem: 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 is not olny ptoblem with the scope.. I ve changed it to compile and still the same error occurs… Thanks in advance for some new suggestion.

    Greg

    9 May 2008, 7:45pm
    by Viktor Nordling

    reply

    Hi,

    I’m trying to use the Maven jspc plugin, but compilation fails because it uses version 1.4 of Java and I need 5.0. I cannot figure out how to change it.

    Any ideas?

    Thanks!

    Viktor, maybe you need to specify maven-compiler-plugin 1.5?
    Check this out http://blog.cliffano.com/2007/07/10/going-java-15-with-maven2-based-project/

    To use java 1.5 for compiling your JSPs,

    org.codehaus.mojo
    jspc-maven-plugin
    1.4.6

    jspc

    compile

    1.5
    1.5
    1.5
    true

    [...] bir maven plugin’i mevcut. Ben her ne kadar henüz başaramasam da ilgili blog yazısına buradan ulaşabilirsiniz. :java, maven No comments for this entry [...]

     

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

     

    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