Re: Jasper, JSPC, Ant and Precompiling JSP's
Ah, o.k. I had misunderstood what that attribute was for in the Ant Manual. I will try it and verify if the packaging comes out right. If I understand correctly, I will still need to walk the directories with the forEach task to get them compiled to classes, is this correct? thanks again for the help, -Mark Steph Richardson wrote: Mark, The jspc task that I used from the standard Optional Tasks that come with ant, does support a webapp parameter, and this works fine to compile the whole webapp without any regexp voodoo ( I didn't use it because it won't allow you to exclude any files ). I did see once a conversation on the ant-dev list that complained about how brittle the jspc task has been to maintain. So jasper ( with 4.1.28 ) comes with it's own built in task to completely compile a webapp. As described here : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html#Web%20Application%20Compilation If you ignore the part about the web.xml fragment, and make sure your output dir is the same as your Tomcat workdir, then this works too ( I think - I did so many experiments my mind is now cloudy ). Steph -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 5:05 PM To: Tomcat Users List Subject: Re: Jasper, JSPC, Ant and Precompiling JSP's Bingo! Thats pretty tight. I hadn't thought of using regexp, but I'll give this a try, it seems pretty logical. I didn't realize someone had contributed a forEach task. I'd still like to hear about if theres any work ongoing in relation to JspC and precompilation of entire webapplications in Tomcat? thanks again, Mark Steph Richardson wrote: Mark, I have a working solution for pre-compiling jsp, that I am using successfully with all our tomcat installations. The target looks like : target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${webapp.rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target I then use foreach from antcontrib to iterate over the directories and compile them individually. Tomcat seems to accept all the resulting class files at runtime with no problems. Regards, Steph -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 7:06 PM To: Tomcat Users List Subject: RE: Jasper, JSPC, Ant and Precompiling JSP's That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, I've done my best to review the archives to resolve my problem, but I've
RE: Jasper, JSPC, Ant and Precompiling JSP's
Mark, On compiling the _jsp.java files - yes I had to use foreach . And then because javac works recursively on whatever directory you point it at ( now that every file is in the same package ), I had to move the contents of each dir to a tempdir, compile the tempdir, move classfiles back. Full ( and long ) example below : Steph !-- Translate and compile all jsp files for current web app -- target name=jspc depends=tomcat-setworkdir,jspc_preparse foreach target=jspc_compile param=param.jspdir path dirset dir=${webapp.workdir} /dirset /path /foreach /target !-- Use Jasper2 to parse jsp into java -- target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target target name=jspc_compile description=Compiling _jsp.java files for one tomcat directory echo message=jspc_compile called for ${param.jspdir} / property name=tempbuild value=${rootdir}/WEB-INF/temp/src / mkdir dir=${tempbuild} / copy todir=${tempbuild} fileset dir=${param.jspdir} include name=*.java / /fileset /copy javac srcdir=${tempbuild} destdir=${tempbuild} optimize=off debug=on failonerror=true classpath path refid=build.classpath / pathelement location=${tomcat.home}/common/classes/ fileset dir=${tomcat.home}/common/lib include name=*.jar/ /fileset pathelement location=${tomcat.home}/shared/classes/ fileset dir=${tomcat.home}/shared/lib include name=*.jar/ /fileset /classpath /javac available property=package.created file=${tempbuild}/org/apache/jsp / !-- If no jsp / java files in this dir, then skip move because it would fail -- if istrue value=${package.created} / then move todir=${param.jspdir} fileset dir=${tempbuild}/org/apache/jsp / /move /then else echo message=No java files to compile in ${param.jspdir} / /else /if delete dir=${tempbuild} quiet=true/ /target -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 10:02 PM To: Tomcat Users List Subject: Re: Jasper, JSPC, Ant and Precompiling JSP's Ah, o.k. I had misunderstood what that attribute was for in the Ant Manual. I will try it and verify if the packaging comes out right. If I understand correctly, I will still need to walk the directories with the forEach task to get them compiled to classes, is this correct? thanks again for the help, -Mark Steph Richardson wrote: Mark, The jspc task that I used from the standard Optional Tasks that come with ant, does support a webapp parameter, and this works fine to compile the whole webapp without any regexp voodoo ( I didn't use it because it won't allow you to exclude any files ). I did see once a conversation on the ant-dev list that complained about how brittle the jspc task has been to maintain. So jasper ( with 4.1.28 ) comes with it's own built in task to completely compile a webapp. As described here : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html#Web%20Application%20Compilation If you ignore the part about the web.xml fragment, and make sure your output dir is the same as your Tomcat workdir, then this works too ( I think - I did so many experiments my mind is now cloudy ). Steph
RE: Jasper, JSPC, Ant and Precompiling JSP's
Mark, The jspc task that I used from the standard Optional Tasks that come with ant, does support a webapp parameter, and this works fine to compile the whole webapp without any regexp voodoo ( I didn't use it because it won't allow you to exclude any files ). I did see once a conversation on the ant-dev list that complained about how brittle the jspc task has been to maintain. So jasper ( with 4.1.28 ) comes with it's own built in task to completely compile a webapp. As described here : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html#Web%20Application%20Compilation If you ignore the part about the web.xml fragment, and make sure your output dir is the same as your Tomcat workdir, then this works too ( I think - I did so many experiments my mind is now cloudy ). Steph -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 5:05 PM To: Tomcat Users List Subject: Re: Jasper, JSPC, Ant and Precompiling JSP's Bingo! Thats pretty tight. I hadn't thought of using regexp, but I'll give this a try, it seems pretty logical. I didn't realize someone had contributed a forEach task. I'd still like to hear about if theres any work ongoing in relation to JspC and precompilation of entire webapplications in Tomcat? thanks again, Mark Steph Richardson wrote: Mark, I have a working solution for pre-compiling jsp, that I am using successfully with all our tomcat installations. The target looks like : target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${webapp.rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target I then use foreach from antcontrib to iterate over the directories and compile them individually. Tomcat seems to accept all the resulting class files at runtime with no problems. Regards, Steph -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 7:06 PM To: Tomcat Users List Subject: RE: Jasper, JSPC, Ant and Precompiling JSP's That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, 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
Re: Jasper, JSPC, Ant and Precompiling JSP's
Thanks Ian, We actually already have a shell script that does this too. I was hoping to get some details on how to make the jspc and tomcat behaviors more consistent with each other so that I could move away from this strategy and use the compiler directly. Unfortunately, its often the case that our jsp's are behind security realms and cannot be gotten at without logging into the webapplication first which means we need to maintain session information while 'grazing' the jsp's. Since this was starting to get more complex than I wanted, I was hoping to step back and see why JspC wasn't just providing jsp compilation features that were not consistent with Tomcats behavior when compiling intothe work directory. From what I understand, Jasper loads each JSP into its own classloader, this means that it can get away with having the same exact package name in each JSP even though they are in different directories in 'work' the classloaders load each individual _jsp.java/_jsp.class file relative to to the directory it is within. JspC on the other had, treats the directory as a package hierarchy (which is great if your going to dump them into the classes directory and map them in your web.xml). It is apparent that JspC cannot be used to compile the JSP's into Tomcats work directory because of this package naming issue. -Mark Zabel, Ian wrote: Mark, 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 a class that you can use as part of a build or manually that will trigger tomcat to compile all the jsps, given a directory and a URL. It can easily be converted into an Ant task. I'll send you the source if you want. Basically, it reads in a directory, filters to find all the jsp names in it, and then iterates through them, and calls http://tomcatserver/path/jspname.jsp?jsp_precompile=true The jsp_precompile=true is understood by tomcat to mean: just compile the jsp, don't do anything else. This process effectively compiles every single jsp in your webapp, but must be done on a live tomcat server, not offline. You could then copy all of the generated jsp java classes from the work directory into a production tomcat server, and hopefully it would use them instead of recompiling. Let me know if you want it. Ian. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Jasper, JSPC, Ant and Precompiling JSP's
In fact, I'm curious to the status of this in 5.0 and the directions that this will take in the future, I may be willing to do a little work to add work directory compilation to the capabilities of JspC, if they do not already exist. -Mark Mark R. Diggory wrote: Thanks Ian, We actually already have a shell script that does this too. I was hoping to get some details on how to make the jspc and tomcat behaviors more consistent with each other so that I could move away from this strategy and use the compiler directly. Unfortunately, its often the case that our jsp's are behind security realms and cannot be gotten at without logging into the webapplication first which means we need to maintain session information while 'grazing' the jsp's. Since this was starting to get more complex than I wanted, I was hoping to step back and see why JspC wasn't just providing jsp compilation features that were not consistent with Tomcats behavior when compiling intothe work directory. From what I understand, Jasper loads each JSP into its own classloader, this means that it can get away with having the same exact package name in each JSP even though they are in different directories in 'work' the classloaders load each individual _jsp.java/_jsp.class file relative to to the directory it is within. JspC on the other had, treats the directory as a package hierarchy (which is great if your going to dump them into the classes directory and map them in your web.xml). It is apparent that JspC cannot be used to compile the JSP's into Tomcats work directory because of this package naming issue. -Mark Zabel, Ian wrote: Mark, 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 a class that you can use as part of a build or manually that will trigger tomcat to compile all the jsps, given a directory and a URL. It can easily be converted into an Ant task. I'll send you the source if you want. Basically, it reads in a directory, filters to find all the jsp names in it, and then iterates through them, and calls http://tomcatserver/path/jspname.jsp?jsp_precompile=true The jsp_precompile=true is understood by tomcat to mean: just compile the jsp, don't do anything else. This process effectively compiles every single jsp in your webapp, but must be done on a live tomcat server, not offline. You could then copy all of the generated jsp java classes from the work directory into a production tomcat server, and hopefully it would use them instead of recompiling. Let me know if you want it. Ian. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Jasper, JSPC, Ant and Precompiling JSP's
Mark, I have a working solution for pre-compiling jsp, that I am using successfully with all our tomcat installations. The target looks like : target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${webapp.rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target I then use foreach from antcontrib to iterate over the directories and compile them individually. Tomcat seems to accept all the resulting class files at runtime with no problems. Regards, Steph -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 7:06 PM To: Tomcat Users List Subject: RE: Jasper, JSPC, Ant and Precompiling JSP's That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, 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} destdir=/var/tomcat4/work/Standalone/localhost/Foo failonerror=false compiler=jasper41 classpath !-- snip -- /classpath exclude name=**/WEB-INF/**/ /jspc javac destdir=/var/tomcat4/work/Standalone/localhost/Foo optimize=off debug=on failonerror=false srcdir=/var/tomcat4/work/Standalone/localhost/Foo excludes=**/*.smap classpath !-- snip -- /classpath /javac 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
Re: Jasper, JSPC, Ant and Precompiling JSP's
Bingo! Thats pretty tight. I hadn't thought of using regexp, but I'll give this a try, it seems pretty logical. I didn't realize someone had contributed a forEach task. I'd still like to hear about if theres any work ongoing in relation to JspC and precompilation of entire webapplications in Tomcat? thanks again, Mark Steph Richardson wrote: Mark, I have a working solution for pre-compiling jsp, that I am using successfully with all our tomcat installations. The target looks like : target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${webapp.rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target I then use foreach from antcontrib to iterate over the directories and compile them individually. Tomcat seems to accept all the resulting class files at runtime with no problems. Regards, Steph -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 7:06 PM To: Tomcat Users List Subject: RE: Jasper, JSPC, Ant and Precompiling JSP's That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, 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} destdir=/var/tomcat4/work/Standalone/localhost/Foo failonerror=false compiler=jasper41 classpath !-- snip -- /classpath exclude name=**/WEB-INF/**/ /jspc javac destdir=/var/tomcat4/work/Standalone/localhost/Foo optimize=off debug=on failonerror=false srcdir=/var/tomcat4/work/Standalone/localhost/Foo excludes=**/*.smap classpath !-- snip -- /classpath /javac Both tasks get completed successfully. I observe problems in the package names of the JSPC generated java files
RE: Jasper, JSPC, Ant and Precompiling JSP's
That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, 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} destdir=/var/tomcat4/work/Standalone/localhost/Foo failonerror=false compiler=jasper41 classpath !-- snip -- /classpath exclude name=**/WEB-INF/**/ /jspc javac destdir=/var/tomcat4/work/Standalone/localhost/Foo optimize=off debug=on failonerror=false srcdir=/var/tomcat4/work/Standalone/localhost/Foo excludes=**/*.smap classpath !-- snip -- /classpath /javac 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: Bar/Bam_jsp) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:502) at java.lang.ClassLoader.defineClass(ClassLoader.java:431) 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 _jsp.java 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 differences. 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 /var/tomcat4/work/Foo/org/apache/jsp/Bar/Bam_jsp.java