Tomcat Cant Pick Class-path From Manifest File
Tomcat Version :5.0.28 JDK: 1.5.0.14
The problem:
I am using both hibernate and struts We are not on the latest and greatest of the version for these libraries So- both need a different version of apache-commons library.
The solution I have in mind:
Use manifest file and specify a different version of apache-commons for each
My web app is deployed as webapps\myapp
And the lib is webapps\myapp\WEB-INF\lib
I modified the Manifest.mf in hibernate3.jar as follows
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver Created-By: 1.5.0_15-b04 (Sun> Microsystems Inc.) Class-Path: hibernatelib/slf4j-api-1.5.2.jar
and put the slf4j-api-1.5.2.jar in webapps\myapp\WEB-INF\lib\hibernatelib
Now I would expect that slf4j-api-1.5.2.jar would be loaded automatically along with hibernate But its not working... Tomcat is unable to find the jar files specified in the .MF as above
The Question:
- Am I doing something wrong? or is it Tomcat ?
- Is there another solution to this problem ?
I have already tried\checked the following
- Checked for new-line characters at the end of the file
- If I put slf4j-api-1.5.2.jar in the main lib folder- the error goes away- so I know its not able to find this particular jar file
- Tried relative, absolute path in the manifest file
Answer
The only place where the Class-Path
attribute in the manifest is used is when the jar
containing the manifest is called as an executable jar using ("java -jar theFile.jar
").
Some servlet containers seem to support it, but according to this mailing list post (Sorry, couldn't find anything more authorative so quickly) it's not specified in the spec either.
As far as I understand it, web applications generally load their classes using a single class loader. "Correctly" solving that dependency problem would require at least 2 different classloaders.
A hack-ish solution might be to use jarjar or a similar tool to package the different libraries together with their respective dependencies.
So you'd produce one jar
containing Hibernate together with its apache-commons library and another jar
containing struts together with its apache-commons library. Each copy of the apache-commons library would be moved to different packages (possibly hibernate.org.apache.*
and struts.org.apache.*
) to solve the problem with different classe versions.
Related Questions
- → CORS header 'Access-Control-Allow-Origin' missing only in browser/jquery but OK with curl
- → How to use foreach in jstl + javascript?
- → Server-side rendering of Java, ReactJs code on a web browser
- → MySQL JDBC driver not found in Tomcat 7 on Ubuntu 14.04 LTS
- → ambiguous mapping while deploying
- → Programmatically get Tomcat8 HTTP Connector's maxPostSize in a JSP
- → Element type "Resource" must be followed by either attribute specifications, ">" or "/>"
- → Caching lookups on application startup doesn't work
- → getting too many follow-up request as response of request
- → Apache Tomcat configuration: Access not authorized
- → Tomcat: One or more listeners failed to start
- → How to keep running a program on Linux through SSH connection?
- → Eclipse closed automatically