Its not a bug in axis or tomcat. You're not supposed to do this.
Normally you redistribute your web application as a .war file which
bundles all your jars, classes, and web resources and you don't need to
do things like this.
To take a parallel example, suppose I have a directory named 'somedir',
then doing 'java -classpath somedir com.example.Main' would look for
'somedir\com\example\Main.class'. If that class was actually inside
'somedir\test.jar' it would not be found. The JVM does not scan
directories or jar files unless they are explicitly in your classpath.
The 'lib' dir in a web application is scanned specially because it says
in the servlet specification that that's what the servlet container is
supposed to do.
You can think of what's actually happening here as the class name is
being converted to a relative URL path, which is then appended in turn
to each of the URLs for elements of your classpath: ie 'somedir' becomes
'file:somedir/', so the VM looks up
'file:somedir/com/example/Main.class'. If your classpath was 'test.jar'
the URL it uses would be 'jar:file:test.jar!/' (see the documentation of
java.net.JarURLConnection) so it would look for
'jar:file:test.jar!/com/example/Main.class'.
Having said all that, it may still be possible to get what you described
to work. Jar files contain a manifest file ('Manifest.mf') which
contains metadata about its contents, including additional classpath
information.
supposing your jar is called 'all.jar' and at its top level it contains
axis.jar, xinidice.jar (etc). Then if you add a line to your manifest
reading:
Class-path: all.jar!/axis.jar all.jar!/xindice.jar
To figure out why this might work, read the jar file specification (its
in the documentation that came with your jdk). However - servlet
containers have to implement their own class loaders in order to conform
to the spec. If their implementation varies even slightly from what's
described above, the trick won't work. I don't even know for sure if it
works with the normal URLClassLoader. You'd do better to reconsider what
you're doing.
-Baz
Abhishek Agrawal wrote:
> We are trying to implement different types of webservices that need different
> jar files ( eg. xindice webservice needs xindice.jar)
>
> I will like to pack all the jar files needed by my webservice into the my
> webservices jar itself. For example if i have xindice webserive that needs
> xindice.jar, i will like to all xindice.jar into the jar file that i put into
> : $TOMCAT_HOME/webapps/axis/WEB-INF/lib
>
> the problem i am facing is that axis is not able to find the jar file
> (xindice.jar ) which is inside the jar of my xindice webservie. When i put
> that jar (xindice.jar ) in $TOMCAT_HOME/webapps/axis/WEB-INF/lib outside the
> jar file for the webserive it runs fine.
>
> Is it a bug in axis, which makes it impossible for axis to look for classes in
> jar files that are inside some other jar file??
>
> Abhishek
>