Discussions

EJB programming & troubleshooting: Client side EJB communication and custom class loader

  1. Hello.

    I have a problem with my application. I've created a "client framework" that dynamically discovers GUI classes that are registered by using a descriptor file. The GUI stuff can be communicating with an EJB server (JBoss) in which case the usual practice would be to also add a jar file containing the Home and Remote interfaces to the "plugin directory" which is dynamically discovered by the custom class loader.

    Now the problem is that when I try to communicate with the EJB server through a plugin, it seems as if the lookup stuff is actually only searching the system class loader for its classes!

    Does anybody have any idea how I can either 1) add the classes to the system class path dynamically or 2) have the EJB lookup stuff use my custom class loader?

    Kind regards, Stefan Freyr.
  2. I have a similar application using JBoss. I just do the following:

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(myClassLoader);

    try {
    ...
    ... Do Stuff
    ...
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }

    This also works with WebSphere.