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:
Sorry that took out the xml formatting.
It was 2 dependencies (groupId, artifactId, version)
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
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!
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 [...]
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