Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Problem with Classloader switch and narrow Object
Problem with Classloader switch and narrow Object [message #44155] Tue, 29 June 2004 12:14
Beat Schaller is currently offline Beat SchallerFriend
Messages: 2
Registered: July 2009
Junior Member
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:RCP Splash Screen
Next Topic:Problem with Classloader switch and narrow Object
Goto Forum:
  


Current Time: Thu Apr 25 07:34:18 GMT 2024

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

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

Back to the top