this is exactly what Im talking about, tom.  Yes, the interface class is
loaded by the class loader cl, and the object "homeClass" is valid. but when
you go referring directly to the class (eg. "my.home.interface.class",
casting to (my.home.interface), declaring a variable my.home.interface if)
the JVM will not use the class loaded by cl, it will try to load the
my.home.interface class AGAIN using the defining classloader for whatever
class we are looking at here.  Which will fail because the defining
classloader cant see my.home.interface.

your code would be fine if the last line read:
Object if = PortableRemoteObject.narrow( o, homeClass );

-----Original Message-----
From: Tom Cook [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 14, 2001 8:43 PM
To: jBoss
Subject: Re: [jBoss-User] DYNAMIC CLASSLOADING


On Thu, 15 Feb 2001, you wrote:
> Hi,
> 
> Isn't it your EJB home interface that
> cannot be found?
> This is in your EJB jar, and its
> classes are not served by the web
> server.
> This is similar to when one EJB jar
> tries to access classes and defined
> in another EJB jar.
> Problem is, while it would make
> sense to serve the interface classes
> (but not implementation classes) of
> the EJB jar, there are no sure way
> to differentiate what classes are
> interface and which are
> implementation.

What about having a peek at the deployment descriptor?  That's a fairly sure
way of finding out which is which...

But why not just expose everything to the outside world?  What if the
developer
_wants_ to expose all of the classes?

Anyway, it is not the interfaces which are missing because this code:

        URL urls[] = new URL[1];
        urls[0] = new URL( "http://localhost:8083" );
        ClassLoader cl = new URLClassLoader( urls );
        Thread.currentThread().setContextClassLoader( cl );
        System.setSecurityManager( new RMISecurityManager );
        System.out.println( "Set class loader and security manager." );

        URL classResource = cl.getResource( "my.home.interface" );
        System.out.println( classResource.toString() );

        Class homeClass = cl.loadClass( "my.home.interface" );
        System.out.println( "Home interface class loaded." );

        InitialContext ctx = new InitialContext();
        Object o = ctx.lookup( "my_home_interface_in_jndi" );
        my.home.interface if =
(my.home.interface)PortableRemoteObject.narrow( o, my.home.interface.class
);

gives this output:

        Set class loader and security manager.
        http://localhost:8083/my/home/interface.class
        Home interface class loaded
        java.lang.ClassNotFoundException: my.home.interface at...

which is very strange indeed, I know, but there it is.  I thought that when
I
ran it in a debugger, it failed loading javax.ejb.EJBHome or something like
that, but maybe I was wrong.

> I seperate my EJBs in different jars
> for implementation and interface.
> EJB implementation jars go to deploy
> directory, while interface jars go
> in classpath.

Don't you have to restart the server every time you change an interface
then? 
Even Weblogic 5 gives that sort of re-deploy, doesn't it?

Tom


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to