Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My Context Listener problem

 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic