Skip to main content



      Home
Home » Eclipse Projects » Equinox » Problem with Classloader switch and narrow Object
Problem with Classloader switch and narrow Object [message #44186] Tue, 29 June 2004 08:15
Eclipse UserFriend
We are using different plugins in our application. The main one depends on a library plugin containing the weblogic jar. To get the InitialContext from the weblogic jar we need to switch the Classloader (without we get an javax.naming.NoInitialContextException). If we wan't to get the RemoteHomeObject of another plugin we get an ClassCastException, Cannot narrow....
Can anyone help me on this subject? Is the Classloader switch still needing? If yes how does it work if I have to switch between different plugins?

code
==========
public ServiceLocator() throws ServiceLocatorException
{
try
{
ClassloaderSwitch.switch2CL();
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://myhost:8880");
ic = new InitialContext(env);
}
catch (NamingException ne)
{
throw new ServiceLocatorException(ne);
}
catch (Exception e)
{
throw new ServiceLocatorException(e);
}
finally
{
ClassloaderSwitch.switch2Normal();
}
}

...

public EJBHome getRemoteHome(String jndiHomeName, Class className)
throws ServiceLocatorException
{
EJBHome home = null;
try
{
Object objref = ic.lookup(jndiHomeName);
Object obj = PortableRemoteObject.narrow(objref, className);
home = (EJBHome) obj;
}
catch (NamingException ne)
{
throw new ServiceLocatorException(ne);
}
catch (Exception e)
{
throw new ServiceLocatorException(e);
}
return home;
}
===========

Beat
Previous Topic:Problem with Classloader switch and narrow Object
Next Topic:Bundle debug for NoClassDefFoundErrors
Goto Forum:
  


Current Time: Sun May 11 04:41:09 EDT 2025

Powered by FUDForum. Page generated in 0.02534 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top