I am using 4.0.1, so its possible that something may have changed, but see
intermixed.

> -----Original Message-----
> From: JavaJosh [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 19, 2002 4:08 PM
> To: [EMAIL PROTECTED]
> Subject: Where's my fish? How do I go fishing? (Tomcat 4.0)
> 
> 
> Hello,
> 
> Tomcat 4.0.3 is apparently not reloading a recompiled 
> servlet. According
> to the docs, this should be the default behavior.
> 
> Interestingly, it WILL load a new servlet.
> 
> I have 2 questions, of the "where's my fish" sort and of the "how do I
> fish" sort.
> 
> Where's my fish: why isn't Tomcat reloading my changed servlet? I have
> verified that the class file has changed by checking the timestamp, so
> I'm pretty sure it's not a build problem.
> 

your context needs to be set to reloadable="true".
I have noticed that it takes one request for Tomcat to realize the servlet
has changed, then the next request picks up the change. Sometimes I have to
wait 30 seconds or so for it to pick up the change(don't know why).

> How do I fish: what is a reasonable way to troubleshoot this problem?
> 
A message will appear in the log for your context when the reload is done.
This, of course, is provided that you have a logger for your host in
server.xml

> While I would love to have a fish right now, I am perfectly willing to
> learn how to fish and catch my own.
> 
> Some fishing I've already done:
> 1) tried restarting tomcat. Picks up the new class!
this is expected. You can also use manager to restart your context. While it
doesn't solve your problem, it is less painful than restarting tomcat.
> 2) tried restarting the browser. No go.
you may want to check your browser cache settings(request new version of
page on EVERY access)
> 3) examined the tomcat logs. Nothing interesting.
> 4) examined the servlet class file in the webapps dir. Yup, it sure
> changed.
> 5) tried adding a second servlet. Tomcat picks it up!
> 6) tried changing the second servlet. No go.
> 
> I *suspect* that in the murky depths of this problem swims an enormous
> caching flounder. Is its name Tomcat 4.0.3? Is it IE 5? Either way, I
> want to hook it, filet it, and have it for dinner tonight.
> 
> Thanks for your help,
> Josh Rehman
> 
> Here are some more facts for you:
> Hardware: Dell Inspiron 7000 Laptop - P2-366 256M/10G
> OS: MS Windows 2000 (NT5) Professional SP2 1024x768x64k
> Java: Sun J2SE 1.3.1_01 - c:\java\jdk131
> Tomcat: 4.0.3 - c:\java\jakarta-tomcat-4.0.3
>       %CATALINA_HOME%\conf\web.xml is stock
>       %CATALINA_HOME%\conf\server.xml is stock
> Environment variables: 
>       CATALINA_HOME=C:\java\jakarta-tomcat-4.0.3
>       JAVA_HOME=c:\java\jdk131_01
>       JIKES_HOME=c:\java\jikes114
>       ANT_HOME=c:\java\ant14
> Project organization:
>       Deploy root: %CATALINA_HOME%\webapps\tomcat40
>               \WEB-INF\web.xml
>               \WEB-INF\classes\joshbrain\tomcat40\FirstServlet.class
>               \WEB-INF\classes\joshbrain\tomcat40\SecondServlet.class
> 
> Contents of web.xml:
> <!DOCTYPE web-app 
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
>     "http://java.sun.com/dtd/web-app_2_3.dtd";>
> 
> <web-app>
>     <display-name>Tomcat 4.0.3 Evaluation Application</display-name>
>     
>     <description>
>       This is version 1.0 of a simple evaluation application 
>       written by Josh Rehman ([EMAIL PROTECTED]).
>     </description>
>     
>     <context-param>
>       <param-name>webmaster</param-name>
>       <param-value>[EMAIL PROTECTED]</param-value>
>       <description>
>         The EMAIL address of the administrator to whom questions
>         and comments about this application should be addressed.
>       </description>
>     </context-param>
> 
>     <servlet>
>       <servlet-name>first</servlet-name>
>       <servlet-class>joshbrain.tomcat.FirstServlet</servlet-class>
>     </servlet>
> 
>     <servlet>
>       <servlet-name>second</servlet-name>
>       <servlet-class>joshbrain.tomcat.SecondServlet</servlet-class>
>     </servlet>
> 
>     <servlet-mapping>
>       <servlet-name>first</servlet-name>
>       <url-pattern>/first</url-pattern>
>     </servlet-mapping>
> 
>     <servlet-mapping>
>       <servlet-name>second</servlet-name>
>       <url-pattern>/second</url-pattern>
>     </servlet-mapping>
> 
>     <session-config>
>       <session-timeout>30</session-timeout>    <!-- 30 minutes -->
>     </session-config>
> 
> </web-app>
> 
> Contents of FirstServlet.java (SecondServlet similar):
> /*
>  * FirstServlet.java
>  *
>  * Created on March 18, 2002, 4:56 PM
>  */
> 
> package joshbrain.tomcat;
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> /**
>  *
>  * @author  Josh Rehman
>  * @version
>  */
> public class FirstServlet extends HttpServlet
> {
>     public void init(ServletConfig config) throws ServletException
>     {
>         super.init(config);
>         
>     }
>     protected void processRequest(HttpServletRequest request,
> HttpServletResponse response)
>     throws ServletException, java.io.IOException
>     {
>         response.setContentType("text/html");
>         java.io.PrintWriter out = response.getWriter();
>         out.println("<html>");
>         out.println("<head>");
>         out.println("<title>Servlet</title>");
>         out.println("</head>");
>         out.println("<body>");
>         out.println("<b>This is the string that will change!</b>");
>         out.println("</body>");
>         out.println("</html>");
>         
>         out.close();
>     }
> 
>     protected void doGet(HttpServletRequest request, 
> HttpServletResponse
> response)
>     throws ServletException, java.io.IOException
>     {
>         processRequest(request, response);
>     }
>     
>     protected void doPost(HttpServletRequest request,
> HttpServletResponse response)
>     throws ServletException, java.io.IOException
>     {
>         processRequest(request, response);
>     }    
> }
> 
> My ant build script:
> 
> <project name="Tomcat 4.0.3 Evaluation" default="compile" basedir=".">
> 
> 
>   <property file="build.properties"/>
>   <property file="${user.home}/build.properties"/>
> 
> 
>   <property name="app.name"      value="tomcat40"/>
>   <property name="app.version"   value="1.0"/>
>   <property name="build.home"    value="build"/>
>   <!--<property name="catalina.home" value="../../../.."/>  
> UPDATE THIS!
> -->
>   <property name="deploy.home"
> value="${catalina.home}/webapps/${app.name}"/>
>   <property name="dist.home"     value="dist"/>
> 
> 
>   <property name="compile.debug"       value="true"/>
>   <property name="compile.deprecation" value="false"/>
>   <property name="compile.optimize"    value="true"/>
> 
> 
>   <path id="compile.classpath">
> 
>     <pathelement location="${catalina.home}/common/classes"/>
>     <fileset dir="${catalina.home}/common/lib">
>       <include name="*.jar"/>
>     </fileset>
>     <pathelement location="${catalina.home}/classes"/>
>     <fileset dir="${catalina.home}/lib">
>       <include name="*.jar"/>
>     </fileset>
> 
>   </path>
> 
>   <target name="all" depends="clean,compile"
>    description="Clean build and dist, then compile"/>
> 
> 
>   <target name="clean"
>    description="Delete old build and dist directories">
>     <delete dir="${build.home}"/>
>     <delete dir="${dist.home}"/>
>   </target>
> 
> 
>   <target name="compile" depends="prepare"
>    description="Compile Java sources">
> 
>     <!-- Compile Java classes as necessary -->
>     <mkdir    dir="${build.home}/WEB-INF/classes"/>
>     <javac srcdir="src"
>           destdir="${build.home}/WEB-INF/classes"
>            debug="${compile.debug}"
>      deprecation="${compile.deprecation}"
>         optimize="${compile.optimize}">
>         <classpath refid="compile.classpath"/>
>     </javac>
> 
>     <!-- Copy associated resource files -->
>     <copy  todir="${build.home}/WEB-INF/classes">
>     <fileset dir="src" includes="**/*.properties"/>
>     </copy>
> 
>   </target>
> 
> 
>   <target name="deploy" depends="compile"
>    description="Deploy application to servlet container">
> 
>     <!-- Copy the contents of the build directory -->
>     <mkdir     dir="${deploy.home}"/>
>     <copy    todir="${deploy.home}">
>       <fileset dir="${build.home}"/>
>     </copy>
> 
>   </target>
> 
> 
>   <target name="dist" depends="deploy,javadoc"
>    description="Create binary distribution">
> 
>     <!-- Copy documentation subdirectory -->
>     <copy    todir="${dist.home}/doc">
>       <fileset dir="doc"/>
>     </copy>
> 
>     <!-- Create application JAR file -->
>     <jar jarfile="${dist.home}/${app.name}.war"
>          basedir="${deploy.home}"/>
> 
>     <!-- Copy additional files to ${dist.home} as necessary -->
> 
>   </target>
> 
> 
>   <target name="javadoc" depends="compile" description="Create Javadoc
> API documentation">
> 
>     <mkdir          dir="${dist.home}/doc/api"/>
>     <javadoc sourcepath="src"
>                 destdir="${dist.home}/doc/api"
>            packagenames="*">
>       <classpath refid="compile.classpath"/>
>     </javadoc>
> 
>   </target>
> 
> 
> 
>   <target name="prepare">
> 
>     <!-- Create build directory and copy static content -->
>     <mkdir  dir="${build.home}"/>
>     <copy todir="${build.home}">
>       <fileset dir="web"/>
>     </copy>
> 
>   </target>
> 
> </project>
> 
> Contents of my proj_home\build.properties file:
>       catalina.home=c\:/java/jakarta-tomcat-4.0.3
>       build.compiler=jikes
> 
> For development, I am using Netbeans 3.3.1. However, I am NOT 
> using the
> integrated Tomcat 3.2 container.
> 
> Here are the log contents generated in the following way:
> Delete all logs
> Start tomcat
> Browse to http://localhost:8080/first
> Browse to http://localhost:8080/second
> Modify FirstServlet
> Ant all, ant deploy
> Browse to http://localhost:8080/first
> Verify no change
> Stop tomcat
> 
> I have attached the log files to this message.
> 

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to