tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (David M. Karr)
Subject Problems getting "jspc" to completely work
Date Thu, 11 Apr 2002 18:43:09 GMT
I recently set up a "jspc" task in my build.xml, but only for verification.  I
wasn't bothering to use the output.  That was working ok.

Now, I'm trying to set it up to really pregenerate the JSP code, compile the
generated sources, put the compiled servlet classes into my "classes"
directory, and use an entity declaration in my "web.xml" file to include the
generated servlet mappings.  This isn't working quite right, in several areas.

I'll try to include all the relevant file pieces and output messages.  Sorry
this is somewhat long, but I'm trying to include all the relevant information.

Here is the top of my "web.xml":
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
<!ENTITY webinc PUBLIC "webinc" "file:./webinc.xml">

Following this is the section of my "build.xml" that uses "jspc".  I don't
actually have a separate task for this, I just do it "inline" for now.  This is
inside my "build-war" target.  Before this part, I copy into the "build"
directory all but my "classes" directory.  After this part, I copy in the
"classes" directory.

  <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 build/WEB-INF/webinc.xml -webapp build "/>
    <pathelement location="${catalina.home}/lib/jasper-compiler.jar"/>
    <pathelement location="${catalina.home}/lib/jasper-runtime.jar"/>
    <pathelement location="weblib/servlet.jar"/>
  <javac srcdir="jspc" destdir="classes" debug="on" optimize="off"
    <pathelement location="${catalina.home}/lib/jasper-compiler.jar"/>
    <pathelement location="${catalina.home}/lib/jasper-runtime.jar"/>
    <fileset dir="weblib">
     <include name="*.jar"/>
   <include name="**/*.java"/>

The following is an excerpt of the output when I run "ant build-war" with this:

Copying 2 files to C:\cygwin\home\dmkarr\java\strutstest\build\WEB-INF
Copying 16 files to C:\cygwin\home\dmkarr\java\strutstest\build\WEB-INF\tlds
Copying 12 files to C:\cygwin\home\dmkarr\java\strutstest\build\WEB-INF\lib
Copying 5 files to C:\cygwin\home\dmkarr\java\strutstest\build
Deleting directory C:\cygwin\home\dmkarr\java\strutstest\jspc
Created dir: C:\cygwin\home\dmkarr\java\strutstest\jspc
2002-04-11 11:27:14 - Exception initializing TldLocationsCache: XML parsing error on file
/WEB-INF/web.xml: Invalid PUBLIC ID: webinc
Compiling 5 source files to C:\cygwin\home\dmkarr\java\strutstest\classes
Copying 3 files to C:\cygwin\home\dmkarr\java\strutstest\build\WEB-INF\classes
Building jar: C:\cygwin\home\dmkarr\java\strutstest\deploy\strutstest.war

The parse error is the first problem I see.  However, I'm not certain whether
this is really causing a problem, as it does complete writing the "webinc.xml"
file, which looks ok, and which begins like this:

Automatically created by Tomcat JspC.
Place this fragement in the web.xml before all icon, display-name,
description, distributable, and context-param elements.


After this point in the build, I use a class that interfaces to the Manager app
to stop and start the application, which works most of the time.  However, I
see this in the output when it gets to this point:

Processing URL "http://admin:@localhost:8080/manager/stop?path=/strutstest".
FAIL - Encountered exception java.lang.NullPointerException

In the Tomcat "localhost_log" file, I found this:
	at java.util.Hashtable.remove(
	at org.apache.naming.ContextBindings.unbindClassLoader(
	at org.apache.catalina.core.StandardContext.stop(
	at org.apache.catalina.core.StandardHost.stop(
	at org.apache.catalina.servlets.ManagerServlet.stop(

Now is when the build process copies in the WAR file.  After that, it tries to
run the "start" operation, which gives me this output:

Processing URL "http://admin:@localhost:8080/manager/start?path=/strutstest".
FAIL - Application at context path /strutstest could not be started

Again, in the log file, I saw this:
2002-04-11 11:13:00 ContextConfig[/strutstest] Parse error in application web.xml
org.xml.sax.SAXParseException: File "file:./webinc.xml" not found.
	at org.apache.xerces.framework.XMLParser.reportError(
	at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalEntity(
	at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromEntity(
	at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(
	at org.apache.xerces.framework.XMLDocumentScanner.parseSome(

In the console output of Tomcat, I also see this:
Resolve: webinc file:./webinc.xml
XmlMapper: Can't find resource for entity: webinc --> file:./webinc.xml "null"
PARSE error at line 0 column 0
org.xml.sax.SAXParseException: File "file:./webinc.xml" not found.

David M. Karr          ; Java/J2EE/XML/Unix/C++

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message