> The Servlet spec requires that the class is in the class path.
> 
> Accordingly, in the META-INF/manifest.mf file for myWeb.war, there is an
> entry that reads thusly:
> Class-Path: myLib.jar
> 
There is nothing in the spec that says war files can specify dependencies
using the manifest Class-Path attribute. In fact in the J2EE 1.3PFD3 spec
says:

<j2ee 1.3 spec>
J2EE.8.1.1.2 Dependencies

A .jar file can reference another .jar file by naming the referenced .jar file
in a Class-Path header in the referencing .jar file's Manifest file. The referenced
.jar file is named as a relative URL, relative to the URL of the referencing .jar
file. (This mechanism is only applicable to JAR format files containing class files
or resources to be loaded by a ClassLoader; such files are always named with a
.jar extension. This mechanism does not apply to other JAR format files such as
.ear files, .war files, and .rar files that are never loaded directly by a
ClassLoader.)
</j2ee 1.3 spec>

Are you using this archive format successfully with another app server?

> The reason this is built like this is that the servlet is a generic piece of
> infrastructure which uses locally provided classes (instantiated by
> reflection) to implement a Model2 architecture. As we expect to deploy
> several web apps (each in their own WAR) in the final EAR, we have the
> servlet in an external library JAR. All perfectly legal according to the
> J2EE spec.
> 
That is your interpretation.

> Sorry if that wasn't clear before. :) Anyway, to get back to the core of the
> problem:
> 
> Is there an object that the servlet has access to (such as the ServletConfig
> or the ServletContext) that is certain to be instantiated by the classloader
> for the Web App? If I can get such an object, I can use its classloader to
> instantiate the other classes.
> 
Any class loaded from the standard WEB-INF/classes or WEB-INF/lib/*.jar
is certain to be loaded by the servlet war class loader. At what point are
you trying to do the reflection, and how are you loading the class? I would
expect that using the thread context class loader should work:

    public void init() throws ServletException
    {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        Class clazz = loader.loadClass("myClass");
        ...
    }




_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to