5 Replies Latest reply on Jul 4, 2008 8:19 AM by ronanker

    Unable to pre-compile JSP using ANT task with JBoss 4.2.2

      Hi,

      We recently switched from JBoss 4.0.4 to JBoss 4.2.2 (I know, this is a big jump). We used to have an ant task that pre-compiled all our JSP.

      That stopped working under 4.2.2 with the following message:

      jspc:
       [echo] Compiling JSPs...
      
      BUILD FAILED
      C:\projects\seerdms\build.xml:649: org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: XML parsing error on file /WEB-INF/tld/struts-html.tld
      


      Here is the ant task we are using:

       <target name="jspc">
       <echo message="Compiling JSPs..." />
      
       <taskdef classname="org.apache.jasper.JspC" name="jasper2">
       <classpath>
       <pathelement location="${java.home}/../lib/tools.jar" />
       <pathelement location="${deploy.dir}/jboss-web.deployer/jbossweb.jar" />
       <pathelement location="${deploy.dir}/../../../lib/jboss-common.jar" />
       <pathelement location="${lib.dir}/eclipse/javaee.jar" />
      
       <path refid="cp.jasper2" />
       </classpath>
       </taskdef>
      
       <jasper2 compile="false" validateXml="false" uriroot="${build.war.files.dir}" webXmlFragment="${registry.build.dir}/generated_web.xml" package="${package.web}" outputDir="${registry.build.dir}/jsp-src" />
      
       <javac srcdir="${registry.build.dir}/jsp-src" destdir="${registry.build.dir}/classes" listfiles="${compile.listfiles}" failonerror="${compile.failonerror}" debug="${compile.debug}" debuglevel="${compile.debuglevel}" optimize="${compile.optimize}" deprecation="${compile.deprecation}">
       <classpath>
       <fileset refid="fileset.jasper2" />
       <path refid="cp.lib" />
       </classpath>
       </javac>
      
       </target>
      


      I am not totally familiar with the TLD files, but here are the beginning of the struts-html.tld file that is not successfully parsed:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
      <taglib>
      <tlibversion>1.0</tlibversion>
      <jspversion>1.1</jspversion>
      <shortname>html</shortname>
      <uri>http://jakarta.apache.org/struts/tags-html</uri>
      <tag>
      <name>base</name>
      ...
      


      Thank you!

        • 1. Re: Unable to pre-compile JSP using ANT task with JBoss 4.2.
          erasmomarciano

          I think that should be a problem of classpth

          I not see in your classpath the jar for parser the xml

          example xerces


          • 2. Re: Unable to pre-compile JSP using ANT task with JBoss 4.2.
            erasmomarciano

            try adding in your classpath

            the following jar

            xercesImpl.jar
            xalan.jar
            serializer.jar

            you can find in this path

            jboss-XXXXlib/endorsed

            • 3. Re: Unable to pre-compile JSP using ANT task with JBoss 4.2.

              That was a pretty good suggestion; I did add those jars but the result was the same. I actually solved my problem; it turned out that our TLD files had <DOCTYPE...> headers in them; and the XML parser didn't like that at all.

              I removed the <DOCTYPE...> line and the task executed successfully (note that some of the TLD files had schema information instead of a DOCTYPE, but that seems to fine...

              For anybody having the same problem, here is my final pre-compiling task:

               <path id="cp.jasper2">
               <pathelement location="${java.home}/../lib/tools.jar" />
               <pathelement location="${deploy.dir}/jboss-web.deployer/jbossweb.jar" />
               <pathelement location="${deploy.dir}/../../../lib/jboss-common.jar" />
               <pathelement location="${deploy.dir}/../../../lib/commons-logging.jar" />
               <pathelement location="${lib.dir}/eclipse/javaee.jar" />
               <pathelement location="${deploy.dir}/../../../lib/endorsed/xercesImpl.jar" />
               <pathelement location="${deploy.dir}/../../../lib/endorsed/xalan.jar" />
               <pathelement location="${deploy.dir}/../../../lib/endorsed/serializer.jar" />
              
               <fileset dir="${lib.dir}/web" />
               <pathelement path="${registry.build.dir}/classes" />
               <path refid="cp.lib"/>
               </path>
              


               <target name="jspc" description="Pre-compile are JSP files." depends="copy-metadata, compile" if="jsp.precompile">
               <echo message="Compiling JSPs..." />
              
               <taskdef classname="org.apache.jasper.JspC" name="jasper2" classpathref="cp.jasper2" />
              
               <!-- this will generate the java files for each JSP file -->
               <jasper2
               compile="false"
               validateXml="false"
               uriroot="${build.war.files.dir}"
               webXmlFragment="${registry.build.dir}/generated_web.xml"
               package="${package.web}"
               outputDir="${registry.build.dir}/jsp-src" />
              
               <!-- compile the java files generated in the previous step -->
               <javac
               srcdir="${registry.build.dir}/jsp-src"
               destdir="${registry.build.dir}/classes"
               listfiles="${compile.listfiles}"
               failonerror="${compile.failonerror}"
               debug="${compile.debug}"
               debuglevel="${compile.debuglevel}"
               optimize="${compile.optimize}"
               deprecation="${compile.deprecation}"
               classpathref="cp.jasper2" />
               </target>
              


              Thanks for the help!

              • 4. Re: Unable to pre-compile JSP using ANT task with JBoss 4.2.
                erasmomarciano

                Try to removed
                <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">


                This string code it just needs for to validation XML

                • 5. Re: Unable to pre-compile JSP using ANT task with JBoss 4.2.
                  ronanker

                  Hi all,

                  We got the same problem. With JBoss 4.0.2, precompiling JSP is working fine but not with JBoss 4.2.1.
                  The ant task failed with the "Unable to initialize TldLocationsCache" message.

                  Removing all the doctype is working but is not an option: We have several TLD files provided by several jars. We don't want to update manually those jars.

                  There must be a right way to make precompilation successful without editing the TLD files. No ?

                  Is this the awaited behavior of the JSP compiler or is it a bug ?

                  Thanks for any help.