DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18244>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18244

JspC doesn't work as its examples say.

           Summary: JspC doesn't work as its examples say.
           Product: Ant
           Version: 1.5.2
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Optional Tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


First, I tried a very simple one from the first example of JspC task like the 
following:

<project name="jspc-test" default="all" basedir=".">

        <property name="src" value="${basedir}/src"/>
        <property name="build" value="${basedir}/dist"/>

  <target name="all" depends="clean, init, compile"/>

        <target name="init">
                <mkdir dir="${build}" />
        </target>


        <target name="compile">
                <jspc srcdir="${src}" destdir="${build}" verbose="9" 
compiler="jasper41"
                >
                    <include name="**/*.jsp" />
                </jspc>
        </target>

        <target name="clean">
                <delete dir="${build}" />
        </target>

</project>

However, it failed with this message:

  [jasperc] java.lang.ArrayIndexOutOfBoundsException: 5
  [jasperc]     at org.apache.jasper.JspC.locateUriRoot(JspC.java:628)
  [jasperc]     at org.apache.jasper.JspC.execute(JspC.java:759)
  [jasperc]     at org.apache.jasper.JspC.main(JspC.java:823)
  [jasperc] Exception in thread "main"

And I tried a revised one:

<project name="jspc-test" default="all" basedir=".">

        <property name="src" value="${basedir}/src"/>
        <property name="build" value="${basedir}/dist"/>

  <target name="all" depends="clean, init, compile"/>

        <target name="init">
                <mkdir dir="${build}" />
        </target>


        <target name="compile">
                <jspc srcdir="${src}" destdir="${build}" verbose="9" 
compiler="jasper41"
                uriroot="${basedir}/webapp"
                >
                    <include name="**/*.jsp" />
                </jspc>
        </target>

        <target name="clean">
                <delete dir="${build}" />
        </target>

</project>

(Added uriroot attribute.)

In this case, failure appeared like this:

  [jasperc] java.net.MalformedURLException: 
Path 'D:/java/examples/jspc/src/index.jsp' does not start with '/'
  [jasperc]     at org.apache.jasper.servlet.JspCServletContext.getResource
(JspCServletContext.java:278)
  [jasperc]     at org.apache.jasper.JspCompilationContext.getResource
(JspCompilationContext.java:234)
  [jasperc]     at org.apache.jasper.compiler.Compiler.isOutDated
(Compiler.java:405)
  [jasperc]     at org.apache.jasper.JspC.processFile(JspC.java:572)
  [jasperc]     at org.apache.jasper.JspC.execute(JspC.java:801)
  [jasperc]     at org.apache.jasper.JspC.main(JspC.java:823)

In addition, my linux box also shows a similar message under the above 
build.xml:

 [jasperc] 2003-03-22 11:24:00 - The file 
argument '/home/iasandcb/jspc/src/index.jsp' does not exist
 [jasperc] 
error:org.apache.jasper.JasperException: /home/iasandcb/jspc/src/index.jsp
 [jasperc]     at org.apache.jasper.JspC.processFile(JspC.java:586)
 [jasperc]     at org.apache.jasper.JspC.execute(JspC.java:801)
 [jasperc]     at org.apache.jasper.JspC.main(JspC.java:823)

Finally, I found a successful one:

<project name="jspc-test" default="all" basedir=".">

        <property name="src" value="${basedir}/src"/>
        <property name="build" value="${basedir}/dist"/>

  <target name="all" depends="clean, init, compile"/>

        <target name="init">
                <mkdir dir="${build}" />
        </target>


        <target name="compile">
                <jspc srcdir="${src}" destdir="${build}" verbose="9" 
compiler="jasper41"
                >
                    <webapp basedir="${basedir}/webapp"/>
                </jspc>
        </target>

        <target name="clean">
                <delete dir="${build}" />
        </target>

</project>

This build script runs well.

I guess this problem may come from Jasper's URL resource handling, which works 
fine within web applcation concept, but doesn't seem good without it. I hope 
Ant and Tomcat Jasper team can collaborate to figure the problem out and add 
more examples to Ant Manual compliant with 
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html#Web%
20Application%20Compilation .

Thanks.

Reply via email to