Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Tomcat and HTTPServlet destroy Problem

Reply
Thread Tools

Tomcat and HTTPServlet destroy Problem

 
 
Marko Langbein
Guest
Posts: n/a
 
      06-17-2005
Hi,

i run an tomcat 5.5.9 and jdk-1_5_0_03-windows-i586-p.

I'm write an small test HttpServlet (with init/destroy), wich on-loaded
through web.xml at starttime. The init function correctly called by tomcat.

But uf i close tomcat, the destroy function do not called:

----------------snips from servlet code
public class Controller extends HttpServlet {
Logging log;

public void init() throws ServletException {
super.init();
buildController();
return;
}


private void buildController() {
log = new Logging();
log.log("start");
}



public void destroy() {
try {
log.log("end");
} catch (Exception e) {
}
return;
}
}
----------------snips from servlet code

Have somebody same problems or can verify my problem?

best regards
Marko Langbein
 
Reply With Quote
 
 
 
 
Alan Krueger
Guest
Posts: n/a
 
      06-18-2005
Marko Langbein wrote:
> But uf i close tomcat, the destroy function do not called:
>
> ----------------snips from servlet code

[...]

> public void destroy() {
> try {
> log.log("end");
> } catch (Exception e) {
> }
> return;
> }
> }
> ----------------snips from servlet code
>
> Have somebody same problems or can verify my problem?


Put a log statement in that catch and see if an exception is being
thrown. Also put a log statement in init() to be sure it's being called
properly.
 
Reply With Quote
 
 
 
 
Marko Langbein
Guest
Posts: n/a
 
      06-20-2005
Alan Krueger wrote:
> Marko Langbein wrote:
>
>> But uf i close tomcat, the destroy function do not called:
>>
>> ----------------snips from servlet code

>
> [...]
>
>> public void destroy() {
>> try {
>> log.log("end");
>> } catch (Exception e) {
>> }
>> return;
>> }
>> }
>> ----------------snips from servlet code
>>
>> Have somebody same problems or can verify my problem?

>
>
> Put a log statement in that catch and see if an exception is being
> thrown.

No exception
> Also put a log statement in init() to be sure it's being called
> properly.

Yeah - init() works correctly.

I think, this is a little bit beta version of tomcat

Regards
marko
 
Reply With Quote
 
Alan Krueger
Guest
Posts: n/a
 
      06-20-2005
Marko Langbein wrote:
> Yeah - init() works correctly.
> I think, this is a little bit beta version of tomcat


On that note, what version? How are you launching and closing Tomcat?
 
Reply With Quote
 
Marko Langbein
Guest
Posts: n/a
 
      06-21-2005
Alan Krueger wrote:

> Marko Langbein wrote:
>
>> Yeah - init() works correctly.
>> I think, this is a little bit beta version of tomcat

>
>
> On that note, what version?

This: jakarta-tomcat-5.5.9.tar.gz
> How are you launching and closing Tomcat?

startup.bat and shutdown.bat ....

Greetings
marko
 
Reply With Quote
 
Alan Krueger
Guest
Posts: n/a
 
      06-21-2005
Marko Langbein wrote:
> Alan Krueger wrote:
>> On that note, what version?

>
> This: jakarta-tomcat-5.5.9.tar.gz
>
> > How are you launching and closing Tomcat?

> startup.bat and shutdown.bat ....


The following class (based on your post) with the following web.xml
produce the following log for me on Tomcat 5.5.9 under Windows XP.

I performed the following set of operations:
- start Tomcat
- access servlet
- stop Tomcat
- start Tomcat
- stop Tomcat

Note the corresponding start/end log entries.

How are you testing your version of this class? Can you post something
compilable and a copy of your web.xml?

---begin Controller.java---
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.*;

public class Controller extends HttpServlet {
public void init() throws ServletException {
super.init();
buildController();
}
private void buildController() {
log( "start" );
}
protected void service(
HttpServletRequest req,
HttpServletResponse resp )
throws ServletException, IOException {
log( "service" );
}
public void destroy() {
try {
log( "end" );
} catch ( Exception e ) {
log( e.getMessage() );
}
}
}
---end Controller.java---

---begin 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>
<servlet>
<servlet-name>Controller</servlet-name>
<servlet-class>Controller</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
---end web.xml---

---begin log---
Jun 21, 2005 5:26:56 PM org.apache.catalina.core.ApplicationContext log
INFO: Controller: start
Jun 21, 2005 5:26:58 PM org.apache.catalina.core.ApplicationContext log
INFO: Controller: service
Jun 21, 2005 5:27:04 PM org.apache.catalina.core.ApplicationContext log
INFO: Controller: end
Jun 21, 2005 5:32:04 PM org.apache.catalina.core.ApplicationContext log
INFO: Controller: start
Jun 21, 2005 5:32:13 PM org.apache.catalina.core.ApplicationContext log
INFO: Controller: end
---end log---
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When to destroy, when not to destroy Ook C++ 2 10-11-2005 02:11 AM
HttpServlet and Static Methods Eric Java 1 02-12-2004 08:59 PM
parameter in HttpServlet.doGet Raoul Markus Java 0 08-21-2003 10:35 PM
HTTPSERVLET brijesh Java 1 07-31-2003 12:30 PM
HttpServlet implementation in Tomcat 4.1 Laurent Beaubier \(free.fr\) Java 1 07-03-2003 09:58 PM



Advertisments