The moose likes IDEs, Version Control and other tools and the fly likes My Context Listener problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "My Context Listener problem" Watch "My Context Listener problem" New topic
Author

My Context Listener problem

Rudradutt Joshi
Ranch Hand

Joined: Dec 06, 2008
Posts: 45

Hello,

I am using Tomcat 6 as container (Initializes my listener twice, as it is a common thing I guess.)
The Following is the code:



and trace is (Line no differs as Headers not included.)



also when stop the server



So,
(1) Container loads listener twice. (same for servlets when used load on startup.)
(2) If possible a way through point 1, so I do not have to maintain server socket closely.
(3) or show me the solution for the trace. (java.lang.NullPointerException: null)
(4) also java.net.BindException
(5) When I tries to stop the tomcat it does not stop(80% of the time). (Dew to ports listening.)

Thanks in advance for your time.

Regards,
Rudradutt
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
First of all, it is not normal that servlets, fitlers, listenets, etc are initialized twice on startup. I would fix that first and then re-evaluate the problem (which may already been disappeared then).

This at least sounds like that you've specified the webapplication context twice in the Tomcat configuration. Keep in mind that anything in /webapps folder is implicitly always loaded. If you have definied it as a new <context> in the server.xml as well, then you need to make sure that the docbase is the same, otherwise you need to remove the one or the other.
Rudradutt Joshi
Ranch Hand

Joined: Dec 06, 2008
Posts: 45

Thanks for your reply,

I am using NetBeans 6, So I manually didn't altered any of the container configuration.
If you want than I can print the server.xml file here.
Also NetBeans had created a
CATALINA_HOME/conf/Catalina/localhost/MyApp.xml

which contains

even if I remove the file, it generates a new one and continues while starting server,
I tried load the listener on tomcat 5.5,6.0 and glassfish but the result is same,

Thanks Again,

Regards,
Rudradutt
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Sorry, I can´t help you further. I haven´t used Netbeans for more than 5 minutes, so I can´t tell from experience. At least I can tell that this is certainly caused by having the webapplication definied twice in the appserver. Other users here with more Netbeans knowledge may be able to help you how to fix this Netbeans´ mistake. Good luck.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

rudradutt the MyApp.xml file is created by netbeans for deploying web aaps outside the tomcat folder. Since you have said that if you remove that file, then too the application get's deployed, so it seems that the server.xml is creating the problem or the webapps directory contains a .war file of the web application. Just open tomcat manager and see if the application is deployed at a different context path or something...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Rudradutt Joshi
Ranch Hand

Joined: Dec 06, 2008
Posts: 45

Thank you for your replies and letting me know that this is unexpected behavior of the container, because when first time I needed to built that Listener I researched the topic and found it in so many threads.

Anyways, I got the solution. NetBeans also generated a sun-web.xml , which was the reason why the application was loading twice. I removed the file and voila ( ) my application is having appropriate behavior. Indeed its reappeared, but now no issues are occurring.


That means my first four points are solved, but I am stuck(not really) at the 5th point

(5) When I tries to stop the tomcat it does not stop(80% of the time). (Dew to ports listening.)


Thanks Again to Both of you for the Help,

Reagards,
Rudradutt
Rudradutt Joshi
Ranch Hand

Joined: Dec 06, 2008
Posts: 45

rudradutt joshi wrote:Thank you for your replies and letting me know that this is unexpected behavior of the container, because when first time I needed to built that Listener I researched the topic and found it in so many threads.

Anyways, I got the solution. NetBeans also generated a sun-web.xml , which was the reason why the application was loading twice. I removed the file and voila ( ) my application is having appropriate behavior.


That means my first four points are solved, but I am stuck(not really) at the 5th point

(5) When I tries to stop the tomcat it does not stop(80% of the time). (Dew to ports listening.)


Thanks Again to Both of you for the Help,

Reagards,
Rudradutt

P.S: Indeed its (sun-web.xml) reappeared, but now no issues are occurring.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My Context Listener problem