Hi Nicolas,

two things:
1. in Tomcat 5.5.4 there is a bug in Jasper, which leads (sometimes) to JSP
compile errors even if the classes are in the classpath, Jasper just looses
the classpath sometimes (see
http://issues.apache.org/bugzilla/show_bug.cgi?id=32330)
So you should upgrade at least to 5.5.7, with this version it was fixed.
But it should only happen sometimes, if this is the cause.

2. I use it in the same way you do it and it's definitly working for me, so
I post you my build.xml here.
The differences I see is that I have the id="jspc.classpath" in the
classpath element.
Also you don't have the ${tomcat.home}/bin in your classpath.
The NullPointerException you get actually means "ClassNotFoundException", at
least I got exactly the same exception when the classpath was not correctly
set, and some classes were missing.

Good luck 

Bernhard

                <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}/server/lib"> 
                                        <include name="*.jar"/> 
                                </fileset> 
                                <fileset dir="${tomcat.home}/common/lib"> 
                                        <include name="*.jar"/> 
                                </fileset>
                                <fileset
dir="${webapproot}${webappname}/WEB-INF/lib"> 
                                        <include name="*.jar"/>
                                </fileset>
                        </classpath>
                </taskdef> 

                <!-- execute jasper, creates the servlet source files -->
                <jasper2 
                        validateXml="false" 
                        uriroot="${webapproot}${webappname}" 
 
webXmlFragment="${webapproot}${webappname}/WEB-INF/generated_web.xml" 
                        outputDir="${webapproot}/src" /> 





> -----Urspr�ngliche Nachricht-----
> Von: Karasek-XID, Nicolas [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 19. Mai 2005 14:28
> An: [email protected]
> Betreff: Unable to pre-compile JSP with jspC ant task
> 
> 
> Hello,
> 
> I'm trying to precompile jsp pages with Ant before deploying a Web
> Archive.
> 
> The ant task I'm using is :
> 
> <!-- ======== definition of jspc task ======= -->
> <taskdef classname="org.apache.jasper.JspC" name="jasper2">
>       <classpath>
>               <path id="jspc.classpath">
>                       <pathelement
> location="${java.home}/../lib/tools.jar" />
>                       <!-- ======== My Jars, commented
> ================= -->
> <!--                  
>                       <fileset dir="${source.libs.dir}">
>                               <include name="*.jar" />
>                       </fileset> 
> -->
>                       <!-- ======== End of My Jars
> ===================== -->
>                       <fileset dir="${tomcat.home.dir}/server/lib">
>                               <include name="*.jar" />
>                       </fileset>
>                       <fileset dir="${tomcat.home.dir}/common/lib">
>                               <include name="*.jar" />
>                       </fileset>
>                       <fileset dir="${tomcat.home.dir}/bin">
>                               <include name="commons-logging-api.jar"
> />
>                       </fileset>
>               </path>
>       </classpath>
> </taskdef>
> 
> Notice I commented the reference to the library directory.
> 
> The task is then used by:
> 
> <!-- ========================================= -->
> <!-- Compiles the jsp pages                                      -->
> <!-- ========================================= -->
> <target name="jspc" depends="" description="Compile jsp pages with
> jasper2">
>       <mkdir dir="${jspc.src.dir}" />
>       <jasper2 
>               verbose="1" 
>               validateXml="false" 
>               uriroot="${eclipse.my-app.dir}/web" 
>               webXmlFragment="build/WEB-INF" 
>               outputDir="build/WEB-INF/src" />
>       <javac destdir="${deploy.class.dir}"
> classpathref="jspc.classpath">
>               <src path="${jspc.src.dir}">
>               </src>
>       </javac>
> </target>
> 
> 
> When I launch the task, I got the following error on a jsp file:
> 
> org.apache.jasper.JasperException:
> file:C:/eclipse/workspace/MyWebApp/web/jsp/login/index.jsp(18,0) The
> value for the useBean class attribute myapp.jspbean.IndexJspBean is
> invalid.
> 
> The error in the index.jsp file come from the line:
> 
> <jsp:useBean id="indexJspBean" scope="session" class="
> myapp.jspbean.IndexJspBean" /> 
> 
> As I thought that I should give to jspC a reference to the 
> Bean, I tried
> to package the Bean in a jar file, put it in library 
> directory and then
> uncommenting the reference to the libray directory in the previous ant
> file  sample, but I got then the following error:
> 
> [jasper2] java.lang.NullPointerException
> [jasper2]     at
> org.apache.jasper.JspCompilationContext.createCompiler(JspComp
> ilationCon
> text.java:220)
> [jasper2]     at org.apache.jasper.JspC.processFile(JspC.java:809)
> [jasper2]     at org.apache.jasper.JspC.execute(JspC.java:945)
> [jasper2]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> [jasper2]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
> [jasper2]     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> [jasper2]     at java.lang.reflect.Method.invoke(Unknown Source)
> [jasper2]     at
> org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:123)
> [jasper2]     at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
> [jasper2]     at org.apache.tools.ant.Task.perform(Task.java:364)
> [jasper2]     at org.apache.tools.ant.Target.execute(Target.java:341)
> [jasper2]     at
> org.apache.tools.ant.Target.performTasks(Target.java:369)
> [jasper2]     at
> org.apache.tools.ant.Project.executeTarget(Project.java:1214)
> [jasper2]     at
> org.apache.tools.ant.Project.executeTargets(Project.java:1062)
> [jasper2]     at
> org.eclipse.ant.internal.core.ant.InternalAntRunner.run(Intern
> alAntRunne
> r.java:633)
> [jasper2]     at
> org.eclipse.ant.internal.core.ant.InternalAntRunner.run(Intern
> alAntRunne
> r.java:412)
> [jasper2]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> [jasper2]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
> [jasper2]     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> [jasper2]     at java.lang.reflect.Method.invoke(Unknown Source)
> [jasper2]     at
> org.eclipse.ant.core.AntRunner.run(AntRunner.java:350)
> [jasper2]     at
> org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDele
> gate$1.run
> (AntLaunchDelegate.java:182)
> [jasper2]     at java.lang.Thread.run(Unknown Source)
> BUILD FAILED: C:\eclipse\workspace\MywebApp\build.xml:158:
> org.apache.jasper.JasperException
> 
> I'm using the task shipped with tomcat 5.5.4.
> 
> Have anyone an idea about what I'm missing ?
> 
> Regards,
> 
> -- 
> Nicolas
> 
> ---------------------------------------------------------------------
> 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