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(JspCompilationCon
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(InternalAntRunne
r.java:633)
[jasper2]       at
org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunne
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.AntLaunchDelegate$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]

Reply via email to