Tomcat 6.0 Post Precompilation issue. Help Needed.

R

Roxy

I have a problem with precompilation. I succeeded in able to
precompile my jsp, and compile them as .class. Append the generated
webXMLFragment to web.xml. I can create war file and tomcat is able to
serve my request from browser (both IE & Firefox).

But now when I make change to my jsp place it directly on my Tomcat
(6.0) version. I don’t see my updated jsp getting recompilted by
Tomcat. I am still seeing old jsp content on my browser. No matter how
much I try to refresh my browser cache, I don’t see tomcat compiling
updated jsp.

I don’t know if iam missing something or it is a bug. Please help.

<java classname="org.apache.jasper.JspC" fork="true"
failonerror="false">
<arg line="-d ${dir.jspc.gensrc} -v -s -l
-uriroot ${build}/${src}
-webinc ${jspc.webxml.fragment}
-webapp ${build}/${src}"/>
<classpath>
<fileset dir="${classpath}" includes="ant.jar"/>
<fileset dir="${ant.home}/lib" includes="*.jar"/>
<fileset dir="${tomcat.home}/lib" includes="*.jar"/>
<fileset dir="${tomcat.home}/bin" includes="*.jar"/>
</classpath>
</java>

<javac debuglevel="lines,vars,source" srcdir="${build}/${src}/WEB-INF/
src" destdir="${build}/src/${classes}" classpath="${classpath}"
fork="true" failonerror="true">
<classpath>
<fileset dir="${classpath}" includes="*.jar"/>
<fileset dir="${tomcat.home}/lib" includes="*.jar"/>
</classpath>
<exclude name="**/common/galleryThumbnail_jsp.java" />
<exclude name="**/common/gallerybuilderfooter_jsp.java" />
</javac>
 
R

Roxy

Check the timestamps on the .jsp, .java, and .class files. If Tomcat
thinks that the .class is more recent than the .jsp, it won't recompile.

Also, take a look at the location of the files. When Tomcat compiles it
creates the class files and puts them someplace. (It used to be
WEB-INF/work, but I haven't checked lately). There may be two sets of
class files, the old and the new, and the old may be getting picked up
first.

jsp has new date than java and its .class. i checked all the
directories of tomcat 6. didnt find any location for the compiled
class.
 
A

Arne Vajhøj

Roxy said:
I have a problem with precompilation. I succeeded in able to
precompile my jsp, and compile them as .class. Append the generated
webXMLFragment to web.xml. I can create war file and tomcat is able to
serve my request from browser (both IE & Firefox).

But now when I make change to my jsp place it directly on my Tomcat
(6.0) version. I don’t see my updated jsp getting recompilted by
Tomcat. I am still seeing old jsp content on my browser. No matter how
much I try to refresh my browser cache, I don’t see tomcat compiling
updated jsp.

I don’t know if iam missing something or it is a bug. Please help.

<java classname="org.apache.jasper.JspC" fork="true"
failonerror="false">
<arg line="-d ${dir.jspc.gensrc} -v -s -l
-uriroot ${build}/${src}
-webinc ${jspc.webxml.fragment}
-webapp ${build}/${src}"/>
<classpath>
<fileset dir="${classpath}" includes="ant.jar"/>
<fileset dir="${ant.home}/lib" includes="*.jar"/>
<fileset dir="${tomcat.home}/lib" includes="*.jar"/>
<fileset dir="${tomcat.home}/bin" includes="*.jar"/>
</classpath>
</java>

<javac debuglevel="lines,vars,source" srcdir="${build}/${src}/WEB-INF/
src" destdir="${build}/src/${classes}" classpath="${classpath}"
fork="true" failonerror="true">
<classpath>
<fileset dir="${classpath}" includes="*.jar"/>
<fileset dir="${tomcat.home}/lib" includes="*.jar"/>
</classpath>
<exclude name="**/common/galleryThumbnail_jsp.java" />
<exclude name="**/common/gallerybuilderfooter_jsp.java" />
</javac>

If the web.xml fragment maps the "JSP URL's" to the generated
servlets, then ofcourse you can not access real JSP pages with
the same URL's.

I think you need to either precompile or not, so one of:
- precompile and deploy, when you need to change, then
precompile and deploy again
- deploy JSP pages, and preferrable deply again if you need
to change them, but it will work to edit them in place

Arne
 
A

Arne Vajhøj

Spud said:
Also, take a look at the location of the files. When Tomcat compiles it
creates the class files and puts them someplace. (It used to be
WEB-INF/work, but I haven't checked lately).

It used to be work/Catalina/<host>/<app>
(not webapps/<app>/WEB-INF/work).

Arne
 
R

Roxy

If the web.xml fragment maps the "JSPURL's" to the generated
servlets, then ofcourse you can not access realJSPpages with
the same URL's.

I think you need to either precompile or not, so one of:
- precompile and deploy, when you need to change, then
   precompile and deploy again
- deployJSPpages, and preferrable deply again if you need
   to change them, but it will work to edit them in place

Arne

I want to precompile and deploy my changes. But later on if there is a
small change to my jsp, i want to just deploy my jsp. There is a pre-
requirement at my place, sometimes they dont want to create a new war
file and deploy it for 1 jsp change. I thought Tomcat will check the
modified date, and when .class has older date, it will precompile the
jsp. But then i dont understand how and which package structure tomcat
will follow to create the new servlet. what if it is not following the
package strcuture i used when i did my initial pre-compilation?. And
what happens to the fragmented-web.xml created by manaul pre-
compilation after tomcate does its pre-compilation. I was unable to
find a good document explaining the feature.

Below is my whole target:
<target name="buildstage" depends="setup">
<copy file="WEB-INF/src/stage.oscache.properties" overwrite="true"
tofile="${build}/${src}/WEB-INF/classes/oscache.properties" />
<copy file="WEB-INF/src/stage.log4j.properties" overwrite="true"
tofile="${build}/${src}/WEB-INF/classes/log4j.properties" />

<war destfile="${build}/${dist}/stage/ROOT.war" webxml="WEB-INF/
stage.web.xml" duplicate="preserve">
<fileset dir="${build}/${src}">
<exclude name="**/WEB-INF/web.xml" />
<exclude name="**/WEB-INF/classes/**/*.*" />
<exclude name="**/WEB-INF/templates/samples/**/*.*" />
</fileset>
<classes dir="${build}/${src}/${classes}" />
</war>
</target>


<!-- Build timestamp in the release.jsp -->
<tstamp>
<format property="timestamp" pattern="yyyy/MM/dd hh:mm:ss
z" />
</tstamp>
<echo file="${build}/src/release.jsp" message=" Built at: $
{timestamp}." append="true"/>

<copy file="WEB-INF/src/oscache.properties" overwrite="true"
tofile="${build}/${src}/WEB-INF/classes/oscache.properties" />
<!--copy file="WEB-INF/src/dev.log4j.properties" overwrite="true"
tofile="${build}/${src}/WEB-INF/classes/log4j.properties" /-->
<copy file="WEB-INF/src/log4j.properties" overwrite="true" tofile="$
{build}/${src}/WEB-INF/classes/log4j.properties" />
<echo message="builddev: ${classpath} build: ${build}"/>

<!-- these two properties are the generated web.xml fragment,
and the resulting merged xml-->
<property name="jspc.webxml.fragment" value="${build}/src/WEB-INF/
jspc-xml-fragment-web.xml"/>
<property name="jspc.webxml.merged" value="${build}/src/WEB-INF/
jspc-merged-web.xml"/>
<property name="dir.jspc.gensrc" value="${build}/src/WEB-INF/src"/ <property environment="env"/>

<!--property name="tomcat.home" value="C:/Software/Tomcat6.0"/ -- <property name="tomcat.home" value="${env.J2EE-HOME}"/>
<property name="ant.home" value="${env.ANT-HOME}"/>
<echo message="Tomcat Home: ${tomcat.home}" />
<!-- create the java class from jsp files -->
<java classname="org.apache.jasper.JspC" fork="true"
failonerror="false">
<arg line="-d ${dir.jspc.gensrc}
-uriroot ${build}/${src}
-webinc ${jspc.webxml.fragment}
-webapp ${build}/${src}"/>
<classpath>
<fileset dir="${classpath}" includes="ant.jar"/>
<fileset dir="${ant.home}/lib" includes="*.jar"/>
</classpath>
</java> <!--
<java classname="org.apache.jasper.JspC" fork="true"
failonerror="false">
<arg line="-d ${dir.jspc.gensrc}
-p com.wwe.jspc -v -s -l
-uriroot ${build}/${src}
-webinc ${jspc.webxml.fragment}
-webapp ${build}/${src}"/>
<classpath>
<fileset dir="${classpath}" includes="ant.jar"/>
<fileset dir="${ant.home}/lib" includes="*.jar"/>
</classpath>
</java> -->
<echo file="${build}/src/release.jsp" message="after java. "
append="true"/>
<!-- compile the java & jsp files -->
<javac debuglevel="lines,vars,source" srcdir="${build}/${src}/
WEB-INF/src" destdir="${build}/src/${classes}" classpath="$
{classpath}" fork="true" failonerror="true">
<classpath>
<fileset dir="${classpath}" includes="*.jar"/>
<fileset dir="${tomcat.home}/lib" includes="*.jar"/>
</classpath>
<exclude name="**/common/galleryThumbnail_jsp.java" />
<exclude name="**/common/gallerybuilderfooter_jsp.java" />
</javac>
<echo file="${build}/src/release.jsp" message="after javac. "
append="true" />
<!-- merge the jspc generated web.xml fragment with the real
web.xml-->
<loadfile property="jspc.webxml.fragment.contents" srcFile="$
{jspc.webxml.fragment}"/>
<copy file="${build}/src/WEB-INF/web.xml" tofile="$
{jspc.webxml.merged}"/>

<replace file="${jspc.webxml.merged}">
<replacefilter token="&lt;!-- @JSPC-INSERT-HERE@ --&gt;"
value="${jspc.webxml.fragment.contents}"/>
</replace>



<!-- create the war file, exclude all unwanted files -->
<war destfile="${build}/${dist}/dev/ROOT.war" webxml="$
{jspc.webxml.merged}" duplicate="preserve">
<fileset dir="${build}/${src}">
<exclude name="**/WEB-INF/src/**" />
<exclude name="**/WEB-INF/web.xml" />
<exclude name="**/WEB-INF/*.web.xml" />
<exclude name="**/WEB-INF/*-web.xml" />
<exclude name="**/WEB-INF/classes/*.*.properties" />
<exclude name="**/WEB-INF/classes/test/**" />
<!--exclude name="**/WEB-INF/classes/**/*.*" / -->
<exclude name="**/WEB-INF/templates/samples/**/*.*" />
</fileset>
<!--classes dir="${build}/${src}/${classes}" /-->
</war>
<!-- move the file to J2EE-HOME -->
<copy file="${build}/${dist}/dev/ROOT.war" overwrite="true" todir="$
{tomcat.home}/webapps" />
</target>
 
A

Arne Vajhøj

Roxy said:
I want to precompile and deploy my changes. But later on if there is a
small change to my jsp, i want to just deploy my jsp. There is a pre-
requirement at my place, sometimes they dont want to create a new war
file and deploy it for 1 jsp change. I thought Tomcat will check the
modified date, and when .class has older date, it will precompile the
jsp. But then i dont understand how and which package structure tomcat
will follow to create the new servlet. what if it is not following the
package strcuture i used when i did my initial pre-compilation?. And
what happens to the fragmented-web.xml created by manaul pre-
compilation after tomcate does its pre-compilation. I was unable to
find a good document explaining the feature.

I still believe my explanation above is correct.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top