You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jason Axtell <ja...@stanford.edu> on 2003/08/19 00:00:08 UTC

Jasper2: Can't load class for custom tag library

Hi folks,

I have a web app that deploys and runs just fine under Tomcat 4.1.x with
JSPs being compiled on-the-fly. Now, I'm trying to precompile my JSPs using
jasper2 in Ant. I added a jspc target to my build.xml based on the example
at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html.
Unfortunately, each time I run Ant, I'm getting the following error message:

     [jasper2] Error in class org.apache.jasper.JspC
     [jasper2] BUILD FAILED: file:C:/java/MeSA2/build.xml:306:
org.apache.jasper.JasperException: /applicantMstp.jsp(32,0)
/applicantInfo.jspf(21,1) Unable to load class cityStateCountry

cityStateCountry is the name of one of my custom JSP tags.
applicantInfo.jspf is a file statically included in applicantMstp.jsp. 

Here's the relevant portion of build.xml:

    <path id="jspc.classpath"> 
	<!-- Don't know if I really need this but the example had it. -->
      <pathelement location="${java.home}/lib/tools.jar"/> 

	<!-- I seriously doubt that I need this, but the example had it too.
-->
      <fileset dir="${tomcat.home}/server/lib"> 
        <include name="*.jar"/> 
      </fileset> 

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

	<!-- All the JAR files for my project -->
      <fileset dir="lib"> 
        <include name="*.jar"/> 
      </fileset> 

	<!-- Classes for my custom tag libraries -->
      <fileset dir="classes"> 
        <include name="**/*.class"/> 
      </fileset> 
    </path> 

  <target name="jspc" depends="compile"> 

    <taskdef classname="org.apache.jasper.JspC" name="jasper2" > 
        <classpath refid="jspc.classpath"/>
    </taskdef> 

    <jasper2 verbose="1" 
             validateXml="false" 
             package="edu.stanford.irt.mesa.web.jsp"
             uriroot="${basedir}/web"
             webXmlFragment="etc/web/jsp-web.xml" 
             outputDir="jsp-src/edu/stanford/irt/mesa/web/jsp" />
             
    <javac debug="${compile.debug}"
        deprecation="${compile.deprecation}"
        destdir="classes"
        optimize="${compile.optimize}" 
        srcdir="jsp-src">
        <classpath refid="jspc.classpath"/>
    </javac>
    
  </target> 

Here's a snippet of applicantInfo.jspf:

<%@ taglib uri="/WEB-INF/mesa-tags.tld" prefix="mesa" %>

.
.
.

<mesa:cityStateCountry/>

Here's part of mesa-tags.tld:

	<tag>
		<name>cityStateCountry</name>
	
<tagclass>edu.stanford.irt.mesa.web.CityStateCountryTag</tagclass>
		<bodycontent>JSP</bodycontent>
	</tag>

And here's a bit of web.xml:

  <taglib>
    <taglib-uri>/WEB-INF/mesa-tags.tld</taglib-uri>
    <taglib-location>/WEB-INF/mesa-tags.tld</taglib-location>
  </taglib>

You'll just have to take my word for it that all of the files are in the
usual places and CityStateCountryTag.class is in the classpath named
"jspc.classpath". Also, please ignore for the time being that I'm not really
taking advantage of web.xml's ability to map the physical locations of TLD
files to logical ones (unless of course you think this may be part of the
problem).

My guess is that I'm not using the jasper2 task correctly in my build.xml. I
haven't been able to find any useful documentation for this task except for
the example I mentioned above, and this didn't explain what any of the
task's attributes did. So, I had to guess. 

So, my main question is: 

- Do you know what the cause of my error message is? 

Secondary questions are: 

- Do you know where I can get some good documentation for the jasper2 task? 

- What is the difference between jasper2 and jspc tags? I've just been
assuming that jasper2 is newer and better, but I'd love to find a document
that explains the actual differences, if any, between these two Ant tasks.

Thanks for any help you may be able to offer,

Jason Axtell


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org