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:tazmaniaeclipse-workspacewishtargetjsp-sourcejsplogin_jsp.java:[194,68] cannot resolve symbol symbol : class JspTag location: package tagext

E:tazmaniaeclipse-workspacewishtargetjsp-sourcejsp_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. tomcat jasper-runtime 5.5.12 compile javax.servlet jsp-api 2.0 compile Note that you might want to specify the library versions based on the target environment you’re going to deploy the application to.

Share Comments
comments powered by Disqus