ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gareth Western <gar...@garethwestern.com>
Subject Precompiling JSPs for Tomcat using a cachefileset
Date Wed, 22 Jul 2009 11:36:39 GMT
Hi,

While trying to incorporate Ivy into our build scripts I've come
across the following problem. One of our Ant targets is used to
precompile various webapps. Currently this is fairly similar to the
Ant script described in the Tomcat 5.5 documentation[1]:
<!-- snip -->
    <taskdef classname="org.apache.jasper.JspC" name="tomcatJasper" >
      <classpath id="jspc.classpath">
        <pathelement location="${java.home}/../lib/tools.jar"/>
        <fileset dir="${tomcat-dir}/common/lib" includes="*.jar"/>
        <fileset dir="${tomcat-dir}/server/lib" includes="*.jar"/>
        <fileset dir="${tomcat-dir}/bin" includes="*.jar"/>
      </classpath>
    </taskdef>

    <tomcatJasper validateXml="false"
                  uriroot="${tmp-exploded-dir}/"

webXmlFragment="${tmp-exploded-dir}/WEB-INF/source/generatedweb.xml"
                  outputDir="${tmp-exploded-dir}/WEB-INF/source"
                  verbose="0">
    </tomcatJasper>

    <javac destdir="${tmp-exploded-dir}/WEB-INF/classes"
           optimize="off"
           debug="on"
           srcdir="${tmp-exploded-dir}/WEB-INF/source"
           verbose="false">
      <classpath>
        <pathelement location="${exploded-dir}/WEB-INF/classes"/>
        <fileset dir="${exploded-dir}/WEB-INF/lib" includes="*.jar"/>
        <pathelement location="${tomcat-dir}/common/classes"/>
        <fileset dir="${tomcat-dir}/common/lib" includes="*.jar"/>
        <pathelement location="${tomcat-dir}/shared/classes"/>
        <fileset dir="${tomcat-dir}/server/lib" includes="*.jar"/>
      </classpath>
      <include name="**" />
      <exclude name="tags/**" />
    </javac>
<!-- snip -->

As you can see, this relies on having the required jar files stored in
${tomcat-dir} somewhere on the filesystem, so I'd prefer to use Ivy to
retrieve the dependencies instead. I have the following in my ivy.xml:

    <dependency org="tomcat" name="catalina-ant" rev="5.5.23"
conf="precompile->default" />
    <dependency org="tomcat" name="commons-el" rev="5.5.23"
conf="precompile->default" />
    <dependency org="tomcat" name="jasper-compiler" rev="5.5.23"
conf="precompile->default" />
    <dependency org="tomcat" name="jasper-compiler-jdt" rev="5.5.23"
conf="precompile->default" />
    <dependency org="tomcat" name="jasper-runtime" rev="5.5.23"
conf="precompile->default" />
    <dependency org="tomcat" name="jsp-api" rev="5.5.23"
conf="precompile->default" />
    <dependency org="tomcat" name="servlet-api" rev="5.5.23"
conf="precompile->default" />

and then in my build.xml (instead of the taskdef above):

    <ivy:cachefileset setid="precompile-lib" conf="precompile" />

    <path id="jspc.classpath">
      <pathelement location="${java.home}/../lib/tools.jar"/>
      <fileset refid="precompile-lib" />
    </path>

    <taskdef resource="org/apache/catalina/ant/catalina.tasks"
classpathref="jspc.classpath"/>

However now the task falls over with the following stacktrace:

  [jasper2] java.lang.IllegalStateException: No Java compiler available
  [jasper2] 	at
org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:224)
  [jasper2] 	at org.apache.jasper.JspC.processFile(JspC.java:946)
  [jasper2] 	at org.apache.jasper.JspC.execute(JspC.java:1094)
  [jasper2] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  [jasper2] 	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  [jasper2] 	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [jasper2] 	at java.lang.reflect.Method.invoke(Method.java:585)
  [jasper2] 	at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
  [jasper2] 	at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
  [jasper2] 	at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
  [jasper2] 	at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
  [jasper2] 	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [jasper2] 	at java.lang.reflect.Method.invoke(Method.java:585)
  [jasper2] 	at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
  [jasper2] 	at org.apache.tools.ant.Task.perform(Task.java:348)
  [jasper2] 	at org.apache.tools.ant.Target.execute(Target.java:357)
  [jasper2] 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
  [jasper2] 	at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
  [jasper2] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
  [jasper2] 	at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
  [jasper2] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
  [jasper2] 	at org.apache.tools.ant.Main.runBuild(Main.java:758)
  [jasper2] 	at org.apache.tools.ant.Main.startAnt(Main.java:217)
  [jasper2] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
  [jasper2] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

BUILD FAILED
org.apache.jasper.JasperException: No Java compiler available

I've even tried explicitly adding tools.jar from the JDK to the
classpath (when creating the jspc.classpath, above), but I still get
the same problem. I also tried adding EVERY jar from the ${tomcat-dir}
to my list of ivy dependencies, so that the classpaths for both the
old and the new ant tasks should be the same, but that didn't work
either. Any other ideas?

Kind Regards,

Gareth

[1] http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html

Mime
View raw message