Nightmare: Upgrading Tomcat 5.5 to 6.0

断了今生、忘了曾经 提交于 2019-12-06 02:03:50

The servlet-api.jar is definitely needed for running tomcat embedded. However, is seems to be a classloader issue here. The Classloader for the webapp must not have "direct" access to the servlet.jar, only through its parent class loader.

If you only replaced jars, then there must be a subtle difference in the ClassLoaders of 6.0 vs. 5.5, but I cannot say where.

Tomcat 5.5 and Tomcat 6.0 have some significant differences. My suggestion is to move the WAR files to the new Tomcat instead of trying to gut the old one. One particular difference that comes to mind is that the JAR files are all organized differently.

Since Tomcat 6.0 obviously comes with all of the Tomcat 6.0 JAR files, it stands to reason that you won't have any conflicts if you just use a fresh Tomcat 6.0 install and then move your WAR file applications to the new Tomcat 6.

You will probably still have conflicts, but you'll at least have one variable knocked out, you'll know you're working with a fresh, solid, Tomcat installation instead of one that might be broken or might not be broken.

Good call setting the logging level to ALL, just make sure you get all of the logging.properties files as sometimes there may be more than one.

http://tomcat.apache.org/tomcat-6.0-doc/logging.html

Good luck!

This seems strange - if you didn't change your own web app this issue must exit in 5.5, too.

As @daniel said, your web app is not allowed to have a jar file containing servlet stuff. If i interpret the log correctly, there is a servlet-api in the web app directory. Delete servlet-api completely there.

EDIT

  • What is the directory layout of your application, where do the jars (especially the tomcat jars) live.
  • What is the log output when tomcat starts without the servlet-api in your web app
  • How do you "embedd" tomcat
  • What's the classpath when you start your app

EDIT

You MUST separate the environment lets say in

\yourapp
|
+ lib
|
+ webapp
  |
  + lib (this is where your webapp lives, WITHOUT servlet-api)

If this has similiarity to standard JavaEE container structure - it is NOT by pure hazard :-)

yourapp\lib hosts your application and tomcat libraries. This forms the classpath for starting.

The yourapp\webapp\lib jars are never referenced by the classpath, only by the webapp classloader. You must take the correct path to them into account when you configure your builtin tomcat to point to this webapp, otherwise the web app loader may not find them.

EDIT

Maybe start with something less ambitioned than a JSP. Do you have a simple test servlet deployed?

You must take care to which web application context you have deployed your application. In the log i see you use the root context. Is this really true? If for example you said

  tomcat.addWebapp("foo", appBase);

in your embedding, you must request /foo/servlet, not /servlet in your browser.

So the issue really was: not compiling the source code with latest jars. The classes present on the machine were pre-existent and compiled using Tomcat 5.5 jars and not Tomcat 6.0. Transferring fresh classes solved my problem.

Big thanks to mtraut for showing interest on this question. I wish I could up-vote you more than once. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!