Question Regarding Ant Build and Jspc Task (Tomcat JSPC, not ANT depricated JSPC)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Question Regarding Ant Build and Jspc Task (Tomcat JSPC, not ANT depricated JSPC)

Mohammed Manna
Hello,

Firstly, thanks for allowing me to post on the user list forum. i hope to
get useful information from you guys.

I have configured my ant build job to precompile JSP files for my web
application. below is the portion of taskdef

    <!-- Configure Jasper -->
    <target name="jspc" depends="build.web">
<property name="java.home" value="${env.JAVA_HOME}"/>
<echo>${java.home}</echo>
<echo>${env.JAVA_HOME}</echo>
        <taskdef classname="org.apache.jasper.JspC" name="jasper2">
            <classpath id="jspc.classpath">
               <fileset dir="${catalina_home}/bin">
                    <include name="*.jar"/>
                </fileset>
<fileset dir="${env.ANT_HOME}/lib">
<include name="ant.jar"/>
<include name="ant-launcher.jar"/>
</fileset>
<fileset dir="${catalina_home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${env.JAVA_HOME}/lib">
<include name="tools.jar"/>
</fileset>
</classpath>
        </taskdef>

        <jasper2
                validateXml="false"
                uriroot="webapps/${webdir}"
                webXmlFragment="work/generated_web.xml"
                outputDir="work/jsp"
                compiler="javac1.8"
compile="true"/>
    </target>

    <!-- Compile JSP -->
    <target name="compile.jsp" depends="jspc">
        <javac
                destdir="work/jsp"
                optimize="off"
                debug="on"
                failOnError="false"
                srcdir="work/jsp">

            <classpath>
                <pathelement location="webapps/${webdir}/WEB-INF/classes"/>
                <fileset dir="webapps/${webdir}/WEB-INF/lib">
                    <include name="*.jar"/>
                </fileset>
               <fileset dir="${catalina_home}/bin">
                    <include name="*.jar"/>
                </fileset>
<fileset dir="${env.ANT_HOME}/lib">
<include name="ant.jar"/>
<include name="ant-launcher.jar"/>
</fileset>
<fileset dir="${catalina_home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${env.JAVA_HOME}/lib">
<include name="tools.jar"/>
</fileset>
            </classpath>
            <include name="**"/>
            <exclude name="tags/**"/>
        </javac>
    </target>

    <!-- Normal build of application -->
    <target name="compile"
            description="Compiles all files"
            depends="build.web, mobile">

        <antcall target="compile.jsp"/>

    </target>


I can build my project, no problem. But I do receive 64k method size
violation from Tomcat when the application is launched. Now here are my
points:

1) I can see that I am using the same compiler (Ant Compiler, not JDT
Compiler) for both build and deployment.

2) I expected that any method footprint violation (>64k) should be checked
and informed by ant jspc task. But it seems not.

I also want to quote this (don't know if it holds true) from Ant JSPC task
doc

https://ant.apache.org/manual/Tasks/jspc.html

*"This task can be used to precompile JSP pages for fast initial invocation
of JSP pages, deployment on a server without the full JDK installed, or
simply to syntax check the pages without deploying them. In most cases, a
javac task is usually the next stage in the build process. The task does
basic dependency checking to prevent unnecessary recompilation -this
checking compares source and destination timestamps, and does not factor in
class or taglib dependencies, or <jsp:include> references."*

If my interpretation is correct, then Ant cannot guarantee a full check if
there are lots of JSP includes and custom Tag libraries included in the
JSP? But if there is a workaround to pop those erroneous JSPs out, could
you please advise? I have been struggling with this over a week now.

As a temporary check, I have written a small tool using BCEL and output the
files which has method sizes exceeding the 64k limit. But The cool ANT is
what I really want to use for this.

Once again, I appreciate the time you guys have taken for this.

KR,