You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by simon colston <si...@idealnet.co.jp> on 2004/06/30 08:21:34 UTC

Errors in precompiled JSPs

I have set up an ant task to precompile JSPs and everything works fine 
*if* there are no errors in the JSP.

The ant task is:

<target name="jspc" depends="prepare" description="Compile JSP files">
  <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
   <classpath id="jspc.classpath">
    <pathelement location="${java.home}/../lib/tools.jar"/>
     <fileset dir="${extlib.home}">
      <include name="**/*.jar"/>
     </fileset>
    </classpath>
   </taskdef>
   <jasper2 verbose="4"
      validateXml="false"
      uriroot="${build.home}"
      webXmlFragment="${web.home}/WEB-INF/generated_web.xml"
      outputDir="${build.home}/WEB-INF/src" />
   <loadfile
      srcfile="${web.home}/WEB-INF/generated_web.xml" 				 
property="gen.web.xml">
    <filterchain >
     <tokenfilter delimoutput="\r\n"/>
    </filterchain>
   </loadfile>
   <delete file="${web.home}/WEB-INF/generated_web.xml"></delete>
   <delete file="${build.home}/WEB-INF/web.xml"></delete>
   <copy tofile="${build.home}/WEB-INF/web.xml"
      file="${web.home}/WEB-INF/web.xml">
    <filterset>
     <filter value="${gen.web.xml}" token="jspServlets"/>
    </filterset>
   </copy>
</target>

If I introduce an error into the JSP page, such as:

	<c:url var="url"/>
	<img src="${url}"/>

(where c: is the JSTL common taglib) the ant task ends without errors 
and I get a NullPointerException when I test the page on the server.

How can I get my jspc ant task to show errors in the JSP?

Using Tomcat 5.0.25.

Cheers,

Simon


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


Re: Errors in precompiled JSPs

Posted by simon colston <si...@idealnet.co.jp>.
Hello Woodchuck,

Thanks for the reply.

Woodchuck wrote:
> 
> <jspc srcdir="${webapp.build}" destdir="gensrc/src"
> uriroot="${webapp.build}"
> compiler="jasper41"
> includes="index.jsp,jsp/**/*.jsp"
> verbose="9"
> webxml="jspmaps">
> 
> <classpath>
> <pathelement path="${tomcat.home}/common/lib/jasper-compiler.jar"/>
> <pathelement path="${tomcat.home}/common/lib/servlet.jar"/>
> <pathelement path="${tomcat.home}/common/lib/jasper-runtime.jar"/>
> <pathelement path="${ant.home}/lib/ant.jar"/>
> </classpath>
> 
> </jspc>

I gave this a try and got:
   [jasperc] org.apache.jasper.JasperException: Unrecognized option: 
-v9.  Use -help for help.

I think this may be because I am using Tomcat 5 and the jasper compiler 
is different.  I tried "japser", "jasper41", "jasper5" and "jasper50" 
for the compiler option but it only recognised the first two, and they 
both gave me the -v9 exception (related to the verbosity attribute).

The manual page for the jspc task,

http://ant.apache.org/manual/OptionalTasks/jspc.html

seems very old and seems to have been written in March 2003.  It also 
has warnings everywhere that this should just be used for validation and 
not for pre-compiling.  It doesn't look like it has been updated for 
Tomcat 5 comptatibility.

> 
> why do you need to define your own pre-compile task may i ask?
> 

I read the manual ;-)
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html


Am I messing up somewhere here?  And is there anyway to get the jasper 
shipped with Tomcat 5 to display errors when used for pre-compiling?

Cheers,

simon


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


Re: Errors in precompiled JSPs

Posted by Woodchuck <wo...@yahoo.com>.
hi simon,

i just tried to introduce the same 'errors' you did and my
pre-compiling stopped and complained the following exception:

  [jasperc] 2004-06-30 10:38:20 - ERROR-the file '\jsp\Test.jsp'
generated the following general exception: java.
lang.NullPointerException
  [jasperc]     at org.apache.jasper.JspC.processFile(JspC.java:596)
  [jasperc]     at org.apache.jasper.JspC.execute(JspC.java:801)
  [jasperc]     at org.apache.jasper.JspC.main(JspC.java:823)

so it seems i'm getting the error-checking that you want.  the
difference is that i didn't use <taskdef> to do my pre-compiling.  i
just used ant's <jspc> task:

<jspc srcdir="${webapp.build}" destdir="gensrc/src"
uriroot="${webapp.build}"
compiler="jasper41"
includes="index.jsp,jsp/**/*.jsp"
verbose="9"
webxml="jspmaps">

<classpath>
<pathelement path="${tomcat.home}/common/lib/jasper-compiler.jar"/>
<pathelement path="${tomcat.home}/common/lib/servlet.jar"/>
<pathelement path="${tomcat.home}/common/lib/jasper-runtime.jar"/>
<pathelement path="${ant.home}/lib/ant.jar"/>
</classpath>

</jspc>

why do you need to define your own pre-compile task may i ask?

woodchuck


--- simon colston <si...@idealnet.co.jp> wrote:
> I have set up an ant task to precompile JSPs and everything works
> fine 
> *if* there are no errors in the JSP.
> 
> The ant task is:
> 
> <target name="jspc" depends="prepare" description="Compile JSP
> files">
>   <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
>    <classpath id="jspc.classpath">
>     <pathelement location="${java.home}/../lib/tools.jar"/>
>      <fileset dir="${extlib.home}">
>       <include name="**/*.jar"/>
>      </fileset>
>     </classpath>
>    </taskdef>
>    <jasper2 verbose="4"
>       validateXml="false"
>       uriroot="${build.home}"
>       webXmlFragment="${web.home}/WEB-INF/generated_web.xml"
>       outputDir="${build.home}/WEB-INF/src" />
>    <loadfile
>       srcfile="${web.home}/WEB-INF/generated_web.xml" 				 
> property="gen.web.xml">
>     <filterchain >
>      <tokenfilter delimoutput="\r\n"/>
>     </filterchain>
>    </loadfile>
>    <delete file="${web.home}/WEB-INF/generated_web.xml"></delete>
>    <delete file="${build.home}/WEB-INF/web.xml"></delete>
>    <copy tofile="${build.home}/WEB-INF/web.xml"
>       file="${web.home}/WEB-INF/web.xml">
>     <filterset>
>      <filter value="${gen.web.xml}" token="jspServlets"/>
>     </filterset>
>    </copy>
> </target>
> 
> If I introduce an error into the JSP page, such as:
> 
> 	<c:url var="url"/>
> 	<img src="${url}"/>
> 
> (where c: is the JSTL common taglib) the ant task ends without errors
> 
> and I get a NullPointerException when I test the page on the server.
> 
> How can I get my jspc ant task to show errors in the JSP?
> 
> Using Tomcat 5.0.25.
> 
> Cheers,
> 
> Simon
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 



	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

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