tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <>
Subject Jasper, JSPC, Ant and Precompiling JSP's
Date Mon, 04 Aug 2003 14:09:07 GMT

I've done my best to review the archives to resolve my problem, but I've
not found a solution there so I'm posting it.

I'm stuck back on Tomcat 4.1.24 (LE) and I'm encountering some issues
with JSP Precompilation using Ant and JSPC. First let me outline my problem.

Most messages I've read to date focus on using JSP recompiling to turn
the JSP into Servlets stored in a WAR file and require generating a
fragment web.xml file and including it into your web.xml, I AM NOT
trying to do this. I want my JSP's to get precompiled into the work
directory of Tomcat and used from there, the exact same way that Tomcat
does it. This way afterward, if the jsp is modified, tomcat can still
recompile it.

I have the following jspc and javac tasks coded in my build.xml:

<mkdir dir="/var/tomcat4/work/Standalone/localhost/Foo"/>

<jspc srcdir="${deploy.home}"
         <!-- snip -->
     <exclude name="**/WEB-INF/**"/>

<javac destdir="/var/tomcat4/work/Standalone/localhost/Foo"
        debug="on" failonerror="false"
         <!-- snip -->

Both tasks get completed successfully. I observe problems in the package
names of the JSPC generated java files where the following is the case.

/var/tomcat/webapps/Foo/Bar/Bam.jsp results in the package name

package Bar;

which becomes a problem when I try to access this JSP included into
another, I get the following error

java.lang.NoClassDefFoundError: org/apache/jsp/Bam_jsp (wrong name:
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(
	at java.lang.ClassLoader.defineClass(
	at org.apache.jasper.servlet.JasperLoader.loadClass(Unknown Source)
	at org.apache.jasper.servlet.JasperLoader.loadClass(Unknown Source)
	at org.apache.jasper.JspCompilationContext.load(Unknown Source)
	at org.apache.jasper.servlet.JspServletWrapper.getServlet(Unknown Source)
	at org.apache.jasper.compiler.Compiler.isOutDated(Unknown Source)
	at org.apache.jasper.compiler.Compiler.isOutDated(Unknown Source)

I read somewhere that work had been done on my version (4.1.24) to
eliminate a naming conflict problem. I assume this is why there are now
package names on my files.  I find that when I let
Tomcat/Jasper compile all my jsp's the java files *all* have the package
name "org.apache.jsp" no matter what their directory. I assume that my
compilation is conflicting with Tomcats because of the package naming

So, I've tried adding the following attribute package="org.apache.jsp"
to the jspc task, but this results in even more problems because all the
package names now look like:

package org.apache.jsp.Bar;

and when they are compiled, they end up in a separate directory


Any ideas or solutions out there would be really helpful for me. I just
want to have Tomcat start out using my precompiled jsp's instead of
initially compiling them itself.

Mark Diggory

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message