File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat loading servlet ..twice.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat loading servlet ..twice.." Watch "Tomcat loading servlet ..twice.." New topic
Author

Tomcat loading servlet ..twice..

ani jadhao
Ranch Hand

Joined: Dec 23, 2008
Posts: 62
Hello,
I have a web application in which I am facing one wiered pbm. I see tomcat loading servlet twice , on which my application logic is failing and quits.
Getting below error in log file.
My findings : One thing I did was , inside comp folder I made a copy of website folder and renamed it to website_old. Now both folders contains servlet.jar. Will it be causing a pbm???
==========================================================
Jan 29, 2009 10:48:34 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(.\comp\website_old\WEB-INF\lib\servlet.jar) - jar no
t loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
==========================================================

Ani


SCJP 1.4 : 91%
SCWCD 5: 96%
ani jadhao
Ranch Hand

Joined: Dec 23, 2008
Posts: 62
One more findings :
I have
Server.xml has an entry of below

<Context docBase="C:\Program Files\Avaya/comp/website" path="/website" reloadable="false" crossContext="true" />

So tomcat should look for website folder in the specified directory, but in the C:\Program Files\Avaya/comp directory, there are two directories , website and website_old.
Why tomcat is searching for C:\Program Files\Avaya/comp/website_old application if it gets the C:\Program Files\Avaya/comp/website . ??
I have tomcat6.

Any reason??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
While I'm not sure why the servlet would get loaded twice, there are two things you should fix:

1) Don't keep the Servlet and JSP API jar files anywhere in your web app. Tomcat has its own copy, and will refuse to load it from elsewhere. That's what that message is telling you.

2) Any servlet can be loaded more than once. You need to write your servlets in such a way that loading it, then unloading it, and then loading it again will not cause problems. The container is free to do that. So if loading the servlet a second time causes problems, then you need to write the servlet's destroy method so that there will be no problems when it is loaded again.


Ping & DNS - updated with new look and Ping home screen widget
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Moving to the Tomcat forum.

It sounds like the advice you got on the Tomcat User's Mailing list would be a good start.
Have you read that?


Hi,

If you go in via Tomcat's Manager app, do you see more webapps than you
expect?

A long time ago I made the mistake of deploying apps under the webapps
directory as well as configuring them with their own context - this
resulted in those particular applications being loaded twice.

Also, make sure you clean out Tomcat's work directory - just to be sure
that your config changes are taking effect.

--
Stephen Souness





Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
ani jadhao
Ranch Hand

Joined: Dec 23, 2008
Posts: 62
yes i have ,thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

When that happens, we appreciate it if you could drop a note into the thread stating that you found the solution and what it was. This will, first and foremost, prevent someone from wasting time answering a question that's already been answered and also, possibly provide the answer to someone else with the same problem who is searching the forums before asking the question..

Glad it's working for you.

-Ben
ani jadhao
Ranch Hand

Joined: Dec 23, 2008
Posts: 62
I mean to say , I have received the reply on tomcat forum. I didnt mean to say that my issues/doubt has been released. I appreciate , your time for responding my posts. I am always be and will take care here forth too , to update about the status of the query .
thanks again.
Ani
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

So, you're still seeing your servlet loaded twice?

Did you check the tomcat manager to verify that your application did not get deployed twice?

How do know that your servlet is being loaded twice?
Do you have logging statements in the init method?

If this is still happening, can you post the contents of your web.xml file?
Be sure to use code tags so it can be read easily.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat loading servlet ..twice..
 
Similar Threads
Class JSPException not found error
Running a servlet using Tomcat
How to check, TOMCAT is running as welcome page not coming
jar not loaded?
validateJarFile - Reg