Re: JSP precompilation and including webinc.xml in web.xml
Al, If it's of any use at this point, your setup should work under 4.1. I did something very similar that worked with 4.1.8. Al Tingley wrote: Hello, We are trying to automate the pre-compilation of our JSP files with JspC and the inclusion of the generated webinc.xml file in our application web.xml file. We have constructed an application web.xml as shown below. Both web.xml and webinc.xml are local to the .../webapps/application/WEB-INF/ directory. Our problem is that Tomcat complains when starting up with the message: org.xml.sax.SAXParseException: Relative URI webinc.xml; can not be resolved without a base URI. Note the local reference to webinc.xml below in the DOCTYPE tag. If we change the reference to webinc.xml to an absolute URI of the form below (on Windows): file://E/jakarta-tomcat-4.0.4b3/webapps/appname/WEB-INF/webinc.xml ... we get a null pointer exception when Tomcat starts up (parser error at the line where we reference the file to be included): 2002-06-04 08:55:27 ContextConfig[/voicemail] Parse error in application web.xml java.lang.NullPointerException at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:524) at org.apache.crimson.parser.Parser2.parse(Parser2.java:305) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442) at org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223) at javax.xml.parsers.SAXParser.parse(SAXParser.java:314) ... What are we doing wrong? We're using Tomcat 4.0.4b3. Thanks, Alan Tingley Iperia, Inc. --- The application web.xml file: ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; [!ENTITY includes SYSTEM webinc.xml] web-app !-- all of the precompiled jsp declarations and mappings are in this included file from the JspC -- includes; /web-app --- Output when starting up Tomcat: Starting service Tomcat-Standalone Apache Tomcat/4.0.4-b3 PARSE error at line 6 column -1 org.xml.sax.SAXParseException: Relative URI webinc.xml; can not be resolved without a base URI. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ smime.p7s Description: S/MIME Cryptographic Signature
Re: JSP precompilation and including webinc.xml in web.xml
Al == Al Tingley [EMAIL PROTECTED] writes: Al Hello, Al We are trying to automate the pre-compilation of our JSP files with JspC and Al the inclusion of the generated webinc.xml file in our application Al web.xml file. We have constructed an application web.xml as shown below. Al Both web.xml and webinc.xml are local to the Al .../webapps/application/WEB-INF/ directory. Al Our problem is that Tomcat complains when starting up with the message: Al org.xml.sax.SAXParseException: Relative URI webinc.xml; can not Al be resolved without a base URI. Al Note the local reference to webinc.xml below in the DOCTYPE tag. I got the complete precompilation process to work, but I gave up on trying to reference the include file with an entity reference. It just doesn't work. What I was able to do was write an XSLT stylesheet that takes the main web.xml and the generated include file and generates a new web.xml that incorporates both files. It uses the Ant style task to do the transformation. A slight wrinkle is that the generated include file is not a fully well-formed XML file, in that it doesn't have a root element. So, in order for the XML parser (used by Ant) to grok it, I had to write a simple well-formed wrapper that references the include file with an entity reference. It's ironic that I'm using the same mechanism in this process that I gave up with using inside of Tomcat. I'll show all the pieces of my solution here. This is the excerpt from my build-war Ant target related to this: - delete dir=jspc/ mkdir dir=jspc/ java classname=org.apache.jasper.JspC fork=yes arg line=-v -d jspc -p org.apache.jsp -uriroot build -webinc web-inf/webinc.xml -webapp build / classpath pathelement location=${catalina.home}/common/lib/jasper-compiler.jar/ pathelement location=${catalina.home}/common/lib/jasper-runtime.jar/ pathelement location=weblib/servlet.jar/ /classpath /java !-- Here, run a style task to merge the two web.xml pieces. -- style basedir=build/WEB-INF in=web-inf/web.xml out=build/WEB-INF/web2.xml style=web-inf/webmerge.xsl param name=includeFile expression=includeWrapper.xml/ /style move file=build/WEB-INF/web2.xml tofile=build/WEB-INF/web.xml/ javac srcdir=jspc destdir=classes debug=on optimize=off deprecation=on classpath pathelement location=${catalina.home}/common/lib/jasper-compiler.jar/ pathelement location=${catalina.home}/common/lib/jasper-runtime.jar/ fileset dir=weblib include name=*.jar/ /fileset /classpath include name=**/*.java/ /javac copy todir=build/WEB-INF/classes fileset dir=webprops include name=**/*.properties/ /fileset fileset dir=classes include name=com/intsoft/strutstest/**/*.class/ include name=org/apache/jsp/**/*.class/ /fileset /copy jar jarfile=deploy/strutstest.war fileset dir=build include name=**/ exclude name=*.jsp/ /fileset /jar - Following this is the includeWrapper.xml file, which references the generated include file. Note that I have to reference a path of web-inf/webinc.xml, which is the path to the generated file in my build tree (not my deploy tree). I'm using Ant 1.4. In Ant 1.5.1, there is apparently some new features in the style task that allow the specification of an alternate EntityResolver that would allow me to avoid hardcoding the name of the directory the file is in. - ?xml version=1.0? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; [ !ENTITY webinc PUBLIC webinc file:web-inf/webinc.xml ] web-app webinc; /web-app - And finally, here is the stylesheet (webmerge.xsl) that does the transformation: - ?xml version=1.0? xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; !-- This takes a parameter indicating the name of the secondary file to merge in. When we've matched the web-app element, we will first insert the servlet elements of the include file, then the servlet elements of the main file, then the servlet-mapping elements of the include file, then the servlet-mapping elements of the main file, and then all the remaining elements of the main file (which will be specified explicitly by element type. -- xsl:output method=xml indent=yes doctype-public=-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN doctype-system=http://java.sun.com/dtd/web-app_2_3.dtd/ xsl:param name=includeFile/ !-- get the required elements of web-app, in their defined order, according to the DTD. -- xsl:template match=/web-app web-app xsl:apply-templates select=icon/ xsl:apply-templates select=display-name/ xsl:apply-templates select=description/
JSP precompilation and including webinc.xml in web.xml
Hello, We are trying to automate the pre-compilation of our JSP files with JspC and the inclusion of the generated webinc.xml file in our application web.xml file. We have constructed an application web.xml as shown below. Both web.xml and webinc.xml are local to the .../webapps/application/WEB-INF/ directory. Our problem is that Tomcat complains when starting up with the message: org.xml.sax.SAXParseException: Relative URI webinc.xml; can not be resolved without a base URI. Note the local reference to webinc.xml below in the DOCTYPE tag. If we change the reference to webinc.xml to an absolute URI of the form below (on Windows): file://E/jakarta-tomcat-4.0.4b3/webapps/appname/WEB-INF/webinc.xml ... we get a null pointer exception when Tomcat starts up (parser error at the line where we reference the file to be included): 2002-06-04 08:55:27 ContextConfig[/voicemail] Parse error in application web.xml java.lang.NullPointerException at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:524) at org.apache.crimson.parser.Parser2.parse(Parser2.java:305) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442) at org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223) at javax.xml.parsers.SAXParser.parse(SAXParser.java:314) ... What are we doing wrong? We're using Tomcat 4.0.4b3. Thanks, Alan Tingley Iperia, Inc. --- The application web.xml file: ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; [!ENTITY includes SYSTEM webinc.xml] web-app !-- all of the precompiled jsp declarations and mappings are in this included file from the JspC -- includes; /web-app --- Output when starting up Tomcat: Starting service Tomcat-Standalone Apache Tomcat/4.0.4-b3 PARSE error at line 6 column -1 org.xml.sax.SAXParseException: Relative URI webinc.xml; can not be resolved without a base URI. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]