Assuming an configuration problem on my PC to be the cause of my problem,  I 
did successively:
- desinstall tomcat 5.5.9 (there was one to test the web app)
- desinstall jdk 1.5.0_03 and an anterior jdk 1.4
- install jdk 1.5.0_03, with standard directories option
- install tomcat

After that I did a copy/paste in my build.xml of the jspc task found at 
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jasper-howto.html

<target name="jspc"> 

    <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> 
      </classpath> 
    </taskdef> 

    <jasper2 
             validateXml="false" 
             uriroot="${webapp.path}" 
             webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml" 
             outputDir="${webapp.path}/WEB-INF/src" /> 

  </target>

First attempt, it still throw a NullPointerException ( 
java.lang.NullPointerException at 
org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:220
 ) but I remarked a problem.
The ant task assume that the presence of tools.jar at:

<pathelement location="${java.home}/../lib/tools.jar"/>

But the jdk 1.5 on windows install the following directories :
C:
  +Program Files
     +Java
       +jdk1.5.0_03
       +jre1.5.0_03
and make point ${java.home} to c:/Program Files/Java/jre1.5.0_03 and so cannot 
find tools.jar at ${java.home}/../lib/tools.jar

ok, no problem. As I didn't want to modify the copy/pasted task from 
jasper-howto, I decided to use the jre shipped with jdk at c:/Program 
Files/Java/jdk1.5.0_03/jre.
So I removed the jre from system, added the registry key for 1.5 - removed 
during jre desinstall - that point to the correct JavaHome, RuntimeLib and try 
again with a corrected ${java.home}.

Unfortunately this second attempt failed too. NullPointerException is back . 
Aargh.
For information, I set ${tomcat.home} to C:/Program Files/Apache Software 
Foundation/Tomcat 5.5 and the webapp.path is set to the directory 
c:/eclipse/workspace/myWebApp/build which has the following structure :

+build
  +WEB-INF
    +classes
        my_classes_files
    +lib
       my_libs
    +src
       my_source_files
    web.xml
  +META-INF
    context.xml
  +some_jsp_directories
index.jsp
error.jsp
   
so I arrived to a conclusion: it seems that I have 2 left hands :o)
However If someone see a point to check...

-- 
Nicolas

-----Original Message-----
From: Bernhard Slominski [mailto:[EMAIL PROTECTED] 
Sent: mercredi 22 juin 2005 11:07
To: 'Tomcat Users List'
Subject: AW: Use JSPC

Hi Nicolas,

what jspc basically needs, is acces to all the internal tomcat libraries,
as you see from the ant script:
${tomcat.home}/bin/*.jar
${tomcat.home}/server/lib/*.jar
${tomcat.home}/common/lib/*.jar

As well as all the libraries from you web application.
So what I did was just "installing" (unzipping) Tomcat on my deployment
machine, just in order to the able to do the precomplation. I think you can
also just download the deployer distribution
(http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi) this
should contain all the stuff you need for the deployment. But I don't have
experience with the deployer application.

Conerning you web application: You need to include all the classes and
libraries in the classpath as well, but it doesn't have to be under
${tomcat.home}/webapps it can be anywhere on your deployment machine.
Maybe what's missing is that you have to include the /WEB-INF/classes
directory too in your ant script.
It's not in mine because I only use jar files in my webapp.

Good luck!

Bernhard


> -----Ursprüngliche Nachricht-----
> Von: Karasek-XID, Nicolas [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 22. Juni 2005 10:26
> An: Tomcat Users List
> Betreff: RE: Use JSPC
> 
> 
> Hi bernhard,
> 
> Just a few dumb questions on this, I still have problem to 
> generate servlets source files from jsp.
> From a previous message you sent on this subject in another 
> thread I guess I have a classpath problem in my jspc task ( 
> NullPointerException at 
> org.apache.jasper.JspCompilationContext.createCompiler(JspComp
> ilationContext.java:220) with tomcat 5.5.9).
> I think I have the correct values for getting tools.jar and 
> jasper jars in jspc.classpath.
> So, should the webapp be placed in tomcat webapps directory 
> in order to allow jspc work ? or maybe it doesn't matter ?
> Maybe someone have an idea on what I miss...
> 
> -- 
> Nicolas
> 
> 
> -----Original Message-----
> From: Bernhard Slominski [mailto:[EMAIL PROTECTED] 
> Sent: jeudi 16 juin 2005 11:44
> To: 'Tomcat Users List'
> Subject: AW: Use JSPC
> 
> Hi Mino,
> 
> just one thing to add to the very good answer from Charl:
> I post you my ant sccript, which does all together precompiling and
> automatic generation of the web.xml file.
> You might take it as a basis for your stuff.
> 
> Cheers
> 
> Bernhard
> 
>       <!-- do the precompilation -->
>       <target name="jspc" depends="get-properties-stage" > 
>               <mkdir dir="${webapproot}/src"/>
> 
>               <!-- define the jasper task -->
>               <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" /> 
> 
>               <!-- compile the source files -->
>               <javac 
> destdir="${webapproot}${webappname}/WEB-INF/classes"
>                       optimize="off"
>                       debug="on" failonerror="false"
>                       srcdir="${webapproot}/src" 
>                       excludes="**/*.smap">
>                               <classpath>
>                               <pathelement
> location="${webapproot}${webappname}/WEB-INF/classes"/>
>                               <pathelement
> location="${tomcat.home}/common/classes"/>
>                               <pathelement
> location="${tomcat.home}/shared/classes"/>
>                               <fileset 
> dir="${tomcat.home}/common/lib">
>                                       <include name="*.jar"/>
>                               </fileset>
>                               <fileset 
> dir="${tomcat.home}/shared/lib">
>                                       <include name="*.jar"/>
>                               </fileset>
>                               <fileset dir="${tomcat.home}/bin"> 
>                                       <include name="*.jar"/> 
>                               </fileset> 
>                               <fileset
> dir="${webapproot}${webappname}/WEB-INF/lib"> 
>                                       <include name="*.jar"/>
>                               </fileset>
>                               </classpath>
>                               <include name="**" />
>                               <exclude name="tags/**" />
>               </javac>
> 
>               <!-- Load your precompiled snippet into a property -->
>               <loadfile property="precompiled"
>       
> srcFile="${webapproot}${webappname}/WEB-INF/generated_web.xml"
>                       encoding="ISO-8859-1"/>
> 
>               <!-- Now replace the web.xml with a predifined 
> snippet -->
>               <replace 
> file="${webapproot}${webappname}/WEB-INF/web.xml"
> value="${precompiled}">
>                       <replacetoken><![CDATA[<!-- precompile include
> -->]]></replacetoken>
>               </replace>
>       </target> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Charl Gerber [mailto:[EMAIL PROTECTED]
> > Gesendet: Donnerstag, 16. Juni 2005 11:24
> > An: Tomcat Users List
> > Betreff: Re: Use JSPC
> > 
> > 
> > If you have the generated java files, you can compile
> > them like any other java class (remember to setup your
> > classpath correctly, including some jars in the Tomcat
> > libraries).
> > 
> > Trickier to figure out first time round is to
> > dynamically create the web.xml settings. Every .jsp
> > now effectively becomes a servlet which needs to be
> > added to your web.xml. Using ant its all done
> > automatically, but getting it set up first time round
> > can be tricky.
> > 
> > Charl
> > 
> > 
> > --- Giacomino Raccuia <[EMAIL PROTECTED]>
> > wrote:
> > 
> > > Hi,
> > > I'd like to compile the JSP pages when I upload some
> > > new files on server 
> > > (tomcat 4.0.3) . I use the utility JSPC, but this
> > > generate only java 
> > > file but not the class file. I read that JRun has
> > > JSPC with -compile 
> > > argument while my JSPC utilty doesn't have thi
> > > argument.
> > > Is possible to generate class file with tomcat and
> > > JSPC? Or there is 
> > > another utility to use?
> > > 
> > > Thanks in advance.
> > > Bye
> > > Mino
> > > 
> > > 
> > >
> > 
> ---------------------------------------------------------------------
> > > 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]
> > 
> 
> ---------------------------------------------------------------------
> 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]
> 

---------------------------------------------------------------------
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