tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aparna bejugam <aparna.beju...@gmail.com>
Subject Pre Compiling jsp
Date Mon, 03 Oct 2011 21:41:49 GMT
Hi All,

Can some one tell me where to put the jsp precompilation build
file(build.xml) in the Tomcat 7 structure.
I have a web application called myapp which is inside webapps folder and has
bunch of jsp files, I want to precompile them using the following script.

<project name="Webapp Precompilation" default="all" basedir="../../../">

<property name="tomcat.home" value="${basedir}"/>
  <condition property="java.home" value="/usr/local/java" else="C:/Program
Files/java/jdk1.6.0_02" >
               <os name="Linux"/>
    </condition>

 <property name="webapp.path" value="${tomcat.home}/webapps/myapp"/>
 <property name="outputdir" value="${webapp.path}/build"/>
 <target name="jspc" >
<taskdef classname="org.apache.jasper.JspC" name="jasper2"  >
 <classpath id="jspc.classpath">
<pathelement location="${java.home}/../lib/tools.jar"/>
 <fileset dir="${tomcat.home}/bin">
<include name="*.jar"/>
 </fileset>
<fileset dir="${tomcat.home}/lib">
     <include name="*.jar"/>
</fileset>
 </classpath>
</taskdef>

<jasper2
     validateXml="false"
  uriroot="${webapp.path}"
 webxml="${outputdir}/WEB-INF/web.xml"
  webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
 outputDir="${outputdir}/WEB-INF/src">
 </jasper2>

   <java classname="org.apache.jasper.JspC" fork="true"
dir="${outputdir}/WEB-INF/src">
 <classpath refid="jspc.classpath" />
<arg line="-compile"/>
 <arg line="-l"/>
<arg line="-s"/>
 <arg line="-webapp ${webapp.path}"/>
<arg line="-source ${java.home}"/>
 </java>
</target>

<target name="compile">

<mkdir dir="${outputdir}/WEB-INF/classes"/>
     <javac destdir="${outputdir}/WEB-INF/classes"
   optimize="off"
    debug="on" failonerror="false"
   srcdir="${outputdir}/WEB-INF/src"
    excludes="  **/*.smap">

 <classpath>
<fileset dir="${tomcat.home}/lib">
    <include name="*.jar"/>
</fileset>

<fileset dir="${tomcat.home}/bin">
 <include name="*.jar"/>
</fileset>
 </classpath>
<include name="**" />
 <exclude name="tags/**" />
</javac>

  </target>

   <target name="clean">
 <delete dir="${outputdir}/WEB-INF"/>
  </target>

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

 </project>

Right now I have this build file called build.xml inside the build folder in
myapp. So final structure is myapp has bunch of jsp files and a build folder
with build.xml to precompile the jsps.
When I run the above build.xml using ant I get the following error.


BUILD FAILED
C:\apache-tomcat-7.0.16\webapps\myapp\build\build.xml:29:
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
        at java.util.Vector.get(Vector.java:694)
        at org.apache.jasper.JspC.execute(JspC.java:1286)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:809)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 1 second

I have debugged the jasper.jar code and identified that the build.xml is not
finding the jsp files. Please correct me if I'm wrong .
So my question what is wrong with my build.xml and why is that jasper 2 task
not finding the jsp files and how to tell the jasper2 task about the jsp
files.


Thanks in Advance!!!
Please Help me
I am stuck and eagerly waiting for the reply!!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message