Re: Problem with including JspC generated web.xml fragment
[EMAIL PROTECTED] wrote: JspC can acually edit web.xml? Where is this documented? I can't find any documentation of the jasper2 task except the old outdated jspc task (including all the options/attributes) that is included with Ant. Hi, i think JSPC can not merge the web.xml-fragment into the the orginate web.xml-file. You can doit manually, i.e. before every commit to cvs. This it what we are doing here. But Peter Roßbach presents in his column in Javamagazin an xsl-stylsheet to merge it via an ant task using saxon: http://tomcat.objektpark.org/kolumne/kolumneArchiv.html#11.2004+JSPs+optimieren+mit+dem+Tomcat+JSP+Container+Jasper+-+JSPs+das+Springen+beibringen (It's in German, but should be no problem for you :) If i get enough time i wanna change our buildprocess this way too. Regards, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
My snippet does 2 things. 1) Merges the servlet names and mappings into web.xml 2) creates a file containing all the mappings done in 1 The 2 are independent from one another. But I like to see the snippet created by the JSPC task by iteslef occasionally for when bad things happen. The jasper2 task edits web.xml in place. That being said, make sure your build process creates a build directory. Copies all we resources to the build directory (including web.xml), then compile and classes to WEB-INF/classes (or compile and jar them), then run the jasper2 task to in place edit web.xml. The advantage is make clean becomes a dir removal and a rebuild is *very* easy. -Tim Andreas Schildbach wrote: Tim Funk wrote: I haven't read the docs for this so I am very surprised it wasn't there. The source for JSPC is very easy to read. Anything that is a set method can be called via ant. With luck - I might find some time to update the docs for this one. Actually the semantics is more unclear than the syntax to me. What exactly does addWebXmlMappings=true mean? Add to the file specified in webXmlFragment? But in your example the file generated_web.xml isn't present at first, so there can't anything be added? Regards, Andreas jasper2 compile=true validateXml=false uriroot=${basedir}/${build.dir} poolingEnabled=false webXmlFragment=${basedir}/${build.dir}/WEB-INF/generated_web.xml addWebXmlMappings=true outputDir=${basedir}/${jspc.base}/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
On Tue, 18 Jan 2005 06:43:16 -0500, Tim Funk [EMAIL PROTECTED] wrote: My snippet does 2 things. 1) Merges the servlet names and mappings into web.xml 2) creates a file containing all the mappings done in 1 Hi Tim, can you please provide this snippet, maybe direct to me? I googled around a little bit and found an easy solution wich works for me: http://marc.theaimsgroup.com/?l=ant-userm=106153992631697w=2 A copy-task is replacing a token in web.xml with the generated content. Regards, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
Tim Funk wrote: The jasper2 task edits web.xml in place. That being said, make sure your build process creates a build directory. Copies all we resources to the build directory (including web.xml), then compile and classes to WEB-INF/classes (or compile and jar them), then run the jasper2 task to in place edit web.xml. The advantage is make clean becomes a dir removal and a rebuild is *very* easy. Sorry, it still does not work. I have a fully functional, non-precompiled web application in dist/war. I am trying to transform it into a precompiled web app in place, using the following Ant tasks: taskdef classname=org.apache.jasper.JspC name=jasper2 classpath id=jspc.classpath fileset dir=${env.CATALINA_HOME}/common/libinclude name=*.jar//fileset fileset dir=dist/war/WEB-INF/libinclude name=**/*.jar//fileset /classpath /taskdef jasper2 validateXml=false uriroot=dist/war addWebXmlMappings=true compile=false poolingEnabled=false / When executing the target that contains the tasks with Eclipse 3.1M4 (which contains Ant 1.6.2), I just get BUILD FAILED: C:\eclipse-3.1M4\workspace\myapp\build.xml:86: java.lang.NullPointerException My CATALINA_HOME environment variable points to an installation of Tomcat 5.0.28. I am using Windows XP SP2. Is there anything I can do to debug this problem? Where can I read the stack trace of the exception? Regards, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
On Tue, 18 Jan 2005 17:00:54 +0100, Andreas Schildbach [EMAIL PROTECTED] wrote: Sorry, it still does not work. You have still to specify the webXmlFragment-attribute. Without this i'm getting a NullpointerException too. @Tim: i found your snippet and now its works for me too :) It's funny how many people work around this problem on different ways and it could be so easy. Maybe the jasper-howto on apache.org don't tell all secrets. Regards, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment (solved)
You have still to specify the webXmlFragment-attribute. Without this i'm getting a NullpointerException too. Thanks to the help of both of you, I finally managed to get it to work. You'll find my complete Ant target at the bottom of this post. From the perspective of a user I'd like to provide the following feedback: - of course, a documentation would be helpful (-: - the webXmlFragment option shouldn't be mandatory if addWebXmlMappings=true is specified - compile=true does not work at my place, or is at least terribly slow. It consumes 100% CPU and seems to take forever... - it would be great if there was one magic option, let's call it transformInPlace=true, which would do all of the following: * set addWebXmlMappings to true * initialize the outputDir to ${uriroot}/WEB-INF/classes * transform all JSPs and delete the original files * compile all the generated classes and delete the sources This way, a complete transformation from non-precompiled to precompiled would be possible. - it would be great if the transformed webapp would have no dependancies to Jasper (Tomcat) And here is my Ant target (the webapp to transform needs to be in dist, and you maybe have to adapt the location of your jasper jars): target name=jspc taskdef classname=org.apache.jasper.JspC name=jasper2 classpath id=jspc.classpath fileset dir=${env.CATALINA_HOME}/common/libinclude name=*.jar//fileset fileset dir=dist/WEB-INF/libinclude name=**/*.jar//fileset /classpath /taskdef jasper2 validateXml=false uriroot=dist addWebXmlMappings=true webXmlFragment=foobar.xml compile=false poolingEnabled=true outputDir=dist/WEB-INF/classes / javac srcdir=dist/WEB-INF/classes destdir=dist/WEB-INF/classes includes=org/apache/jsp/**/*.java classpathref=jspc.classpath source=1.5 target=1.5 encoding=UTF-8 debug=false nowarn=true / delete includeemptydirs=true fileset dir=dist includes=**/*.java,**/*.jsp,**/*.jspx/ /delete /target Unfortunately the includeemptydirs option in the delete statement does not work as I would expect: There is still empty directories after transformation if you had only JSPs in them. Regards, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
Odd, I do not have this problem. Make sure you are building to a scratchpad. This means your web.xml is copied to a new location before you precompile. Then JSPC can edit it in place and you no not lose any of your changes. To get around the relative pathing issue - prefix your build with ${basedir}. For example: jasper2 compile=true validateXml=false uriroot=${basedir}/${build.dir} poolingEnabled=false webXmlFragment=${basedir}/${build.dir}/WEB-INF/generated_web.xml addWebXmlMappings=true outputDir=${basedir}/${jspc.base}/ -Tim Andreas Schildbach wrote: Hello everyone, I've got a bit of a problem precompiling JSPs for Tomcat 5.0. To be exact, the problem is the web.xml fragment that is generated by JspC containing the servlet and servlet-mapping elements. That fragment has to be included in the web.xml file somehow. Of course, I don't want to do this manually after each precompile. What's the best way to include the fragment automatically? If I use the XML entity inclusion mechanism, I run into some problems. First, if I enter statements into my original web.xml, the XML parser also wants to include when JspC tries to open the file (at this point obviously the generated file is not yet present). The second problem is that the path of the included file seems to be relative to the current directory - not relative to the including XML file. What are the alternatives? Personally, I'd prefer to use a transparent process. First, the web-app is assembled using no precompilation. It should be fully functional at this point (for development and testing), which means that there can't be any tokens or inclusion instructions in web.xml. In a second step, the web-application should be transformed to an application with all JSPs precompiled, with all descriptor modifications that are needed. It would be perfect if in this state the application would still be fully independant of Tomcat. Any help, any thoughts? Thanks a lot! Regards, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
Tim Funk wrote: Odd, I do not have this problem. Make sure you are building to a scratchpad. This means your web.xml is copied to a new location before you precompile. Then JSPC can edit it in place and you no not lose any of your changes. To get around the relative pathing issue - prefix your build with ${basedir}. For example: jasper2 compile=true validateXml=false uriroot=${basedir}/${build.dir} poolingEnabled=false webXmlFragment=${basedir}/${build.dir}/WEB-INF/generated_web.xml addWebXmlMappings=true outputDir=${basedir}/${jspc.base}/ JspC can acually edit web.xml? Where is this documented? I can't find any documentation of the jasper2 task except the old outdated jspc task (including all the options/attributes) that is included with Ant. Given that I have the whole web application in a directory called webapp, whats the complete jasper2 command to transfor it into a webapp with compiled jsps? Regards, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
I haven't read the docs for this so I am very surprised it wasn't there. The source for JSPC is very easy to read. Anything that is a set method can be called via ant. With luck - I might find some time to update the docs for this one. -Tim Andreas Schildbach wrote: Tim Funk wrote: Odd, I do not have this problem. Make sure you are building to a scratchpad. This means your web.xml is copied to a new location before you precompile. Then JSPC can edit it in place and you no not lose any of your changes. To get around the relative pathing issue - prefix your build with ${basedir}. For example: jasper2 compile=true validateXml=false uriroot=${basedir}/${build.dir} poolingEnabled=false webXmlFragment=${basedir}/${build.dir}/WEB-INF/generated_web.xml addWebXmlMappings=true outputDir=${basedir}/${jspc.base}/ JspC can acually edit web.xml? Where is this documented? I can't find any documentation of the jasper2 task except the old outdated jspc task (including all the options/attributes) that is included with Ant. Given that I have the whole web application in a directory called webapp, whats the complete jasper2 command to transfor it into a webapp with compiled jsps? Regards, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with including JspC generated web.xml fragment
Tim Funk wrote: I haven't read the docs for this so I am very surprised it wasn't there. The source for JSPC is very easy to read. Anything that is a set method can be called via ant. With luck - I might find some time to update the docs for this one. Actually the semantics is more unclear than the syntax to me. What exactly does addWebXmlMappings=true mean? Add to the file specified in webXmlFragment? But in your example the file generated_web.xml isn't present at first, so there can't anything be added? Regards, Andreas jasper2 compile=true validateXml=false uriroot=${basedir}/${build.dir} poolingEnabled=false webXmlFragment=${basedir}/${build.dir}/WEB-INF/generated_web.xml addWebXmlMappings=true outputDir=${basedir}/${jspc.base}/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]