Here's the maven.xml fragment that we use. I'm afraid I can't help any
further if this doesn't work - after several failed attempts this is the
approach that finally worked for us with Tomcat 5.0.28.

Mark Langley
CaseBank Technologies Inc.
http://www.casebank.com

<project
  default="build-all"
  xmlns:maven="jelly:maven"
  xmlns:j="jelly:core"
  xmlns:u="jelly:util"
  xmlns:ant="jelly:ant"
 
xmlns:velocity="jelly:org.apache.commons.jelly.tags.velocity.VelocityTagLibr
ary"
  xmlns:deploy="deploy">

...

<!-- 
  - The next three goals are used to pre-compile jsp pages into servlets.
  - This code is lifted from 
  - http://wiki.codehaus.org/maven/CreatingWebApplications
  -->
  <preGoal name="war:webapp">
    <j:set var="precompileJsp" value="${precompile.jsp}"/>
    <j:if test="${precompileJsp == 'true'}">
       <echo message="Precompiling JSPs. Set precompile.jsp=false in
build.properties if you're impatient!"/>
       <attainGoal name="precompile-jsp"/>
    </j:if>
    <j:if test="${precompileJsp == 'false'}">
       <echo message="JSPs are NOT being precompiled! Is this a production
build???"/>
    </j:if>
  </preGoal>

  <postGoal name="war:webapp">
    <j:set var="precompileJsp" value="${precompile.jsp}"/>
    <j:if test="${precompileJsp == 'true'}">
      <j:set var="target"
value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.web
app.dir')}"/>
      <u:available file="${maven.build.dir}/web-fragment.xml">
        <u:loadText var="fragment"
file="${maven.build.dir}/web-fragment.xml"/>
        <ant:replace file="${target}/WEB-INF/web.xml" token="&lt;!-- [INSERT
FRAGMENT HERE] --&gt;" value="${fragment}"/>
      </u:available>
    </j:if>
  </postGoal>

  <goal name="precompile-jsp" description="Precompile all JSPs into java
classes, and then into classes" prereqs="war:load,java:compile">
    <j:set var="warSource"
value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.src
')}"/>
    <ant:mkdir dir="${maven.build.dir}/jspc"/>
    <ant:mkdir dir="${maven.build.dir}/jspc-processed"/>
    <ant:mkdir dir="${maven.build.dir}/jspc-classes"/>

    <j:set var="jspOutDir" value="${maven.build.dir}/jspc"/>
    <j:set var="jspClassesOutDir" value="${maven.build.dest}"/>
    <ant:path id="jspc.classpath">
      <ant:fileset dir="${java.home}/../lib">
        <include name="tools.jar"/>
      </ant:fileset>
      <ant:fileset dir="${tomcat.home}/bin/">
        <include name="*.jar"/>
      </ant:fileset>
      <ant:fileset dir="${tomcat.home}/server/lib">
        <include name="*.jar"/>
      </ant:fileset>
      <ant:fileset dir="${tomcat.home}/common/lib">
        <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:java 
      taskname="jspc"
      className="org.apache.jasper.JspC"
      failonerror="true"
      fork="yes">
      <ant:classpath refid="jspc.classpath"/>
<!--      <ant:arg value="-help"/> -->

      <ant:arg value="-webapp"/>    <ant:arg value="${warSource}"/>
      <ant:arg value="-d"/>         <ant:arg value="${jspOutDir}"/>
      <ant:arg value="-l"/>
      <ant:arg value="-p"/>         <ant:arg
value="your.package.path.here"/>
      <ant:arg value="-die"/>
      <ant:arg value="-uribase"/>   <ant:arg value="${warSource}"/>
      <ant:arg value="-uriroot"/>   <ant:arg value="${warSource}"/>
      <ant:arg value="-webinc"/>    <ant:arg
value="${maven.build.dir}/web-fragment.xml"/>
      <ant:arg value="-trimSpaces"/> 
    </ant:java>
    
    <ant:javac
      srcdir="${jspOutDir}"
      destdir="${jspClassesOutDir}"
      debug="${maven.compile.debug}"
      deprecation="${maven.compile.deprecation}"
      optimize="${maven.compile.optimize}"
      classpathref="jspc.classpath"/>

  </goal>


-----Original Message-----
From: Darren Hartford [mailto:[EMAIL PROTECTED] 
Sent: November 9, 2004 1:38 PM
To: Maven Users List
Subject: RE: Class Cast exception trying to use org.apache.jasper.JspC

Tried Tomcat 5.0.28, same problem.
Using Maven 1.0 final and related plugins, tried Tomcat 5.0.27 libs, 5.0.28
libs, 5.0.29-beta libs, all the same problem.

Using commons-el, jasper-runtime, jasper-compile, jsp-api, servlet-api libs
from the tomcat distributions.

Struts 1.1 libs.

commons-lang 2.0, commons-digetser 1.5, commons-validator 1.0.1,
commons-beanutils 1.6.1, commons-logging 1.1-dev.

Please Help!  Confused why having a problem with this, tomcat4.1 works fine.

-D

> -----Original Message-----
> From: Mark Langley [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 09, 2004 9:27 AM
> To: 'Maven Users List'
> Subject: RE: Class Cast exception trying to use org.apache.jasper.JspC
> 
> 
> We had the same problem two weeks ago. Upgrading Tomcat to 
> 5.0.28 made it go
> away. 
> 
> Mark Langley
> CaseBank Technologies Inc.
> http://www.casebank.com
> 
> 
> -----Original Message-----
> From: Darren Hartford [mailto:[EMAIL PROTECTED] 
> Sent: November 8, 2004 10:54 AM
> To: Maven Users List
> Subject: Class Cast exception trying to use org.apache.jasper.JspC
> 
> Hey all,
> Having an issue trying to pre-compile JSP's for Tomcat5.
> 
> Rather than repeating, below is a post back in March with the 
> same problem.
> 
> I may just be having a difficult time going through the 
> mailing list and
> using google - I just can not find a solution.  Any help 
> would be greatly
> appreciated! (note: my maven.xml is slightly different, but 
> same problem).
> -D

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to