• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat 3.2.3 classes not refreshing

 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I compile a .java file, the JSP does not use the new version of the bean but an old one.
I have added the following to the ContextManager node in server.xml:
<Context path="/preview" docBase="E:/Virtualhosts/Apache/preview" crossContext="true" debug="0" reloadable="true" trusted="false" />
where my classes are in e:/virtualhosts/apache/preview/web-inf/classes
I even tried removing the classpath variable as someone posted a message about this, but no dice.
This is very frustrating, I cannot be restarting the server every time I change a class. can someone please give me some solid information here on what causes the classes to refresh?
thanks
Zman
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added the following to the ContextManager node in server.xml:

after adding this, did you stop and start the tomcat server...
also, i am not sure if you need to restart your apache?
- satya
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually, I dont think there is any other way to do this. I am not sure if this would work, but you could try writing a servlet that loads the class using Class.forName("com.me.myclass"); and calling that servlet everytime you replace the classes but I dont know if this system overrides the old class value. (i can try this out but it will be monday before I answer)
ideally though, you should write applications that are stable. That means writing classes that achieve what they are supposed to achieve and that do not need regular rewriting. The official way of rewriting classes in java is by subclassing them (extends). I would recommend that you "extend" classes that you ened to rewrite. Firsly, this will get you in the right frame of mind for writing java code ( this is supposed to be how you modify or add to java classes), secondly this will solve your problem, and thirdly it will make it more obvious what version of your class you are using and would allow you to check what you changed if you ruin part of the class trying to rewrite it.
 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Madhav,
Here's server.xml (minus the comments)
<Server>
<Logger name="tc_log" verbosityLevel="INFORMATION"/>
<Logger name="servlet_log" path="logs/servlet.log"/>
<Logger name="JASPER_LOG" path="logs/jasper.log" verbosityLevel="INFORMATION"/>
<ContextManager debug="0" workDir="work" showDebugInfo="true">
<ContextInterceptor className="org.apache.tomcat.context.AutoSetup"/>
<ContextInterceptor className="org.apache.tomcat.context.WebXmlReader"/>
<ContextInterceptor className="org.apache.tomcat.context.LoaderInterceptor"/>
<ContextInterceptor className="org.apache.tomcat.context.DefaultCMSetter"/>
<ContextInterceptor className="org.apache.tomcat.context.WorkDirInterceptor"/>
<RequestInterceptor className="org.apache.tomcat.request.SessionInterceptor" noCookies="false"/>
<RequestInterceptor className="org.apache.tomcat.request.SimpleMapper1" debug="0"/>
<RequestInterceptor className="org.apache.tomcat.request.InvokerInterceptor" debug="0" prefix="/servlet/"/>
<RequestInterceptor className="org.apache.tomcat.request.StaticInterceptor" debug="0" suppress="false"/>
<RequestInterceptor className="org.apache.tomcat.session.StandardSessionInterceptor"/>
<RequestInterceptor className="org.apache.tomcat.request.AccessInterceptor" debug="0"/>
<RequestInterceptor className="org.apache.tomcat.request.SimpleRealm" debug="0"/>
<ContextInterceptor className="org.apache.tomcat.context.LoadOnStartupInterceptor"/>
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
<Parameter name="handler" value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
<Parameter name="port" value="8080"/>
</Connector>
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
<Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
<Parameter name="port" value="8007"/>
</Connector>
<Context path="/examples" docBase="webapps/examples" crossContext="false" debug="0" reloadable="true"/>
<Context path="/admin" docBase="webapps/admin" crossContext="true" debug="0" reloadable="true" trusted="false"/>
<Context path="/preview" docBase="E:/Virtualhosts/Apache/preview" crossContext="true" debug="0" reloadable="true" trusted="false" />
</ContextManager>
</Server>
What's weird is that the problem initially existed on a windows box, then I moved everything onto a fresh Unix box and the problem is still happening: to get a fresh version of a class to work I have to restart tomcat. So I'm thinking it's probably something I'm not setting right with tomcat?
Can you see any probs with the xml? is there any other thing that could cause the JSP to not use the freshest version of a class??
thanks
Zman
 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For those who may be interested, I have apparently found a solution to this problem::
I had set the CLASSPATH to point at the WEB-INF/classes directory for less typing when javac'ing the java files.
When I removed this CLASSPATH, everything mysteriously (and miraculously) started working correctly; I do not have to restart Tomcat to get the fresh classes. Now I have to type a bit more on the command line, but at least it's working! I wish there was some solid documentation on this, why does it work this way??
Zman
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!