Precompiling JSPs with Tomcat 5.5.12

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Precompiling JSPs with Tomcat 5.5.12

VahidG
Hi,

I am having trouble precompiling JSP files with Tomcat 5.5.12 whereas this
went ok with Tomcat 4.1.31. If I remove the jasper jar files from the
common/lib directory and replace them with the ones from the old Tomcat then
it works, but that's not the best solution..

I think my Ant task needs to be changed so that it works with the new jasper
files, but I don't know in what way and haven't been able to find anything
about this anywhere on the internet.

This is how the ant task looks like
...
<ant:path id="jspc.classpath">
      <ant:pathelement
location="${tomcat.home}/common/lib/jasper-runtime.jar"/>
      <ant:pathelement
location="${tomcat.home}/common/lib/jasper-compiler.jar"/>
      <ant:pathelement
location="${tomcat.home}/common/lib/jasper-compiler-jdt.jar"/>
      <ant:pathelement
location="${tomcat.home}/common/lib/servlet-api.jar"/>
      <ant:pathelement
location="${tomcat.home}/common/lib/jsp-api.jar"/>
      <ant:fileset dir="${tomcat.home}/server/lib">
        <ant:include name="*.jar"/>
      </ant:fileset>
      <ant:path refid="maven.dependency.classpath"/>
      <ant:pathelement path="${maven.build.dest}"/>
    </ant:path>
    <ant:taskdef name="jasper2" classname="org.apache.jasper.JspC"
classpathref="jspc.classpath"/>
    <ant:jasper2
      webXmlFragment="${maven.build.dir}/web-fragment.xml"
      package="${pom.package}.jsp"
      outputDir="${jspOutDir}"
      srcdir="${warSource}"
      uriroot="${warSource}"
      uribase="/${pom.artifactId}"
      verbose="2"/>
    <ant:javac
      srcdir="${jspOutDir}"
      destdir="${jspClassesOutDir}"
      debug="${maven.compile.debug}"
      deprecation="${maven.compile.deprecation}"
      optimize="${maven.compile.optimize}"
      classpathref="jspc.classpath"/>
...

I have tried adding and removing path elements..

These are the exceptions I get:

<ant:jasper2> java.lang.ClassCastException:
org.apache.tools.ant.AntClassLoader
        at com.werken.werkz.Goal.fire(Goal.java:620)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:671)
        at
org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
        at org.apache.maven.cli.App.doMain(App.java:488)
        at org.apache.maven.cli.App.main(App.java:1239)
        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:585)
        at com.werken.forehead.Forehead.run(Forehead.java:551)
        at com.werken.forehead.Forehead.main(Forehead.java:581)
org.apache.commons.jelly.JellyTagException:
<ant:jasper2> java.lang.ClassCastException:
org.apache.tools.ant.AntClassLoader
        at
org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:683)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:288)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:79)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:110)
        at com.werken.werkz.Goal.fire(Goal.java:639)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
        at
org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:127)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:88)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
com.werken.werkz.jelly.PreGoalTag$1.firePreGoal(PreGoalTag.java:87)
        at com.werken.werkz.Goal.firePreGoalCallbacks(Goal.java:691)
        at com.werken.werkz.Goal.fire(Goal.java:616)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:671)
        at
org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
        at org.apache.maven.cli.App.doMain(App.java:488)
        at org.apache.maven.cli.App.main(App.java:1239)
        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:585)
        at com.werken.forehead.Forehead.run(Forehead.java:551)
        at com.werken.forehead.Forehead.main(Forehead.java:581)
Caused by: java.lang.ClassCastException:
org.apache.tools.ant.AntClassLoader
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:155)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at
org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        ... 28 more
Caused by: java.lang.ClassCastException:
org.apache.tools.ant.AntClassLoader
        at
org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:96)
        at org.apache.jasper.JspC.initServletContext(JspC.java:1195)
        at org.apache.jasper.JspC.execute(JspC.java:1056)
        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:585)
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:147)
        ... 31 more
Root cause
java.lang.ClassCastException: org.apache.tools.ant.AntClassLoader
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:155)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at
org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:79)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:110)
        at com.werken.werkz.Goal.fire(Goal.java:639)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
        at
org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:127)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:88)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
com.werken.werkz.jelly.PreGoalTag$1.firePreGoal(PreGoalTag.java:87)
        at com.werken.werkz.Goal.firePreGoalCallbacks(Goal.java:691)
        at com.werken.werkz.Goal.fire(Goal.java:616)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:671)
        at
org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
        at org.apache.maven.cli.App.doMain(App.java:488)
        at org.apache.maven.cli.App.main(App.java:1239)
        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:585)
        at com.werken.forehead.Forehead.run(Forehead.java:551)
        at com.werken.forehead.Forehead.main(Forehead.java:581)
Caused by: java.lang.ClassCastException:
org.apache.tools.ant.AntClassLoader
        at
org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:96)
        at org.apache.jasper.JspC.initServletContext(JspC.java:1195)
        at org.apache.jasper.JspC.execute(JspC.java:1056)
        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:585)
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:147)
        ... 31 more
--- Nested Exception ---
java.lang.ClassCastException: org.apache.tools.ant.AntClassLoader
        at
org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:96)
        at org.apache.jasper.JspC.initServletContext(JspC.java:1195)
        at org.apache.jasper.JspC.execute(JspC.java:1056)
        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:585)
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:147)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at
org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:79)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:110)
        at com.werken.werkz.Goal.fire(Goal.java:639)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
        at
org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:127)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:88)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
com.werken.werkz.jelly.PreGoalTag$1.firePreGoal(PreGoalTag.java:87)
        at com.werken.werkz.Goal.firePreGoalCallbacks(Goal.java:691)
        at com.werken.werkz.Goal.fire(Goal.java:616)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:671)
        at
org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
        at org.apache.maven.cli.App.doMain(App.java:488)
        at org.apache.maven.cli.App.main(App.java:1239)
        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:585)
        at com.werken.forehead.Forehead.run(Forehead.java:551)
        at com.werken.forehead.Forehead.main(Forehead.java:581)
Root cause
java.lang.ClassCastException: org.apache.tools.ant.AntClassLoader
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:155)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at
org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:79)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:110)
        at com.werken.werkz.Goal.fire(Goal.java:639)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
        at
org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:127)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:88)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
com.werken.werkz.jelly.PreGoalTag$1.firePreGoal(PreGoalTag.java:87)
        at com.werken.werkz.Goal.firePreGoalCallbacks(Goal.java:691)
        at com.werken.werkz.Goal.fire(Goal.java:616)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:671)
        at
org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
        at org.apache.maven.cli.App.doMain(App.java:488)
        at org.apache.maven.cli.App.main(App.java:1239)
        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:585)
        at com.werken.forehead.Forehead.run(Forehead.java:551)
        at com.werken.forehead.Forehead.main(Forehead.java:581)
Caused by: java.lang.ClassCastException:
org.apache.tools.ant.AntClassLoader
        at
org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:96)
        at org.apache.jasper.JspC.initServletContext(JspC.java:1195)
        at org.apache.jasper.JspC.execute(JspC.java:1056)
        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:585)
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:147)
        ... 31 more
--- Nested Exception ---
java.lang.ClassCastException: org.apache.tools.ant.AntClassLoader
        at
org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:96)
        at org.apache.jasper.JspC.initServletContext(JspC.java:1195)
        at org.apache.jasper.JspC.execute(JspC.java:1056)
        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:585)
        at
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:147)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at
org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:185)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag(MavenGoalTag.java:79)
        at
org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction(MavenGoalTag.java:110)
        at com.werken.werkz.Goal.fire(Goal.java:639)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
com.werken.werkz.WerkzProject.attainGoal(WerkzProject.java:193)
        at
org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag(MavenAttainGoalTag.java:127)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:88)
        at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:279)
        at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:135)
        at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:233)
        at
com.werken.werkz.jelly.PreGoalTag$1.firePreGoal(PreGoalTag.java:87)
        at com.werken.werkz.Goal.firePreGoalCallbacks(Goal.java:691)
        at com.werken.werkz.Goal.fire(Goal.java:616)
        at com.werken.werkz.Goal.attain(Goal.java:575)
        at
org.apache.maven.plugin.PluginManager.attainGoals(PluginManager.java:671)
        at
org.apache.maven.MavenSession.attainGoals(MavenSession.java:263)
        at org.apache.maven.cli.App.doMain(App.java:488)
        at org.apache.maven.cli.App.main(App.java:1239)
        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:585)
        at com.werken.forehead.Forehead.run(Forehead.java:551)
        at com.werken.forehead.Forehead.main(Forehead.java:581)
-----
Your help will be very much appreciated,

Vahid



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Precompiling JSPs with Tomcat 5.5.12

Alexander E Genaud
I am using Tomcat 5.0 and have added the JSPs to the WEB-INF/web.xml
file as follows:

  <servlet>
    <servlet-name>MyJsp</servlet-name>
    <jsp-file>/MyWebApp/MyJsp.jsp</jsp-file>
    <load-on-startup>1</load-on-startup>
  </servlet>

While I learned about this feature from BEA's website, it seems to
pre-compile the JSP's in Tomcat as well.

http://edocs.bea.com/wls/docs81/webapp/web_xml.html

about halfway down in servlet, search for "jsp-file".

This precompiles when you deploy the webapplication, so you will not
get compilation or parsing error reporting, but we never make errors,
right?

Alex
--
Those who can make you believe absurdities can make you commit atrocities
-- Fran=E7ois Marie Arouet (Voltaire)
http://cph.blogsome.com
http://genaud.org/alex/key.asc
--
CCC7 D19D D107 F079 2F3D BF97 8443 DB5A 6DB8 9CE1


--
Alex
--
Those who can make you believe absurdities can make you commit atrocities
-- Fran├žois Marie Arouet (Voltaire)
http://cph.blogsome.com
http://genaud.org/alex/key.asc
--
CCC7 D19D D107 F079 2F3D BF97 8443 DB5A 6DB8 9CE1

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]