Skip to main content



      Home
Home » Eclipse Projects » Equinox » narrowing problem in my plugin using jmx
narrowing problem in my plugin using jmx [message #45831] Tue, 19 October 2004 10:19 Go to next message
Eclipse UserFriend
Originally posted by: buhla2.hta-bi.bfh.ch

hello!

i have a problem in my plugin when i try to narrow (using the
PortableRemoteObject.narrow() method) an object to a
javax.management.j2ee.ManagementHome instance.

InitialContext context = new InitialContext(props);
Object object = context.lookup(props.getProperty(JSR77Connector.CONTEXT));
Class homeClass =
Thread.currentThread().getContextClassLoader().loadClass(MAN AGEMENT_HOME);
Object o = PortableRemoteObject.narrow (object, homeClass);
ManagementHome home = (ManagementHome) o;

loading the ManagementHome class works without any problem, but the narrow()
method rises a ClassCastException.

the same code works fine as a non plugin standalone java programm.

the bundle manifest file looks like that:

Bundle-Activator: ch.bfh.jmxconsole.connectors.jsr77.internal.ConnectionImpl
Bundle-ClassPath: /ConnectionImpl.jar, /jbossall-client.jar
Import-Package: ch.bfh.jmxconsole.core.connection,
ch.bfh.jmxconsole.connectors.jsr77, org.osgi.framework
Export-Package: ch.bfh.jmxconsole.connectors.jsr77.internal

the classpath should be ok because the class can be found and loaded from
the library jar.
does someone have any ideas?

thanx alex
Re: narrowing problem in my plugin using jmx [message #45864 is a reply to message #45831] Tue, 19 October 2004 13:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com

I would start by trying to find if there is someone else who can supply the
class you are trying to narrow to. I suspect that the context classloader
is finding a different one than you expect.

BTW, who is setting up the context classloader? What are you expecting it
to be?

Jeff

"Alex B
Re: narrowing problem in my plugin using jmx [message #45885 is a reply to message #45864] Thu, 21 October 2004 00:44 Go to previous message
Eclipse UserFriend
Originally posted by: buhla2.hta-bi.bfh.ch

thanks for your help jeff... actually the contextclassloader was wrong...
before using my own custom urlclassloader i tryied to instantiate some
objects without setting the current thread's contextclassloader because i
assumed it was set to the bundle's own classloader... this led to
problems... later i found that when the current thread's classloader is not
explicitly set, then it was null. so i used my own custom url classloader to
handle that... without any success.

to fix the problem i just have to set the current thread's
contextclassloader to the bundle's own classloader and now the following
works:

Thread.currentThread().setContextClassLoader(this.getClass() .getClassLoader());

InitialContext ic = new InitialContext(props); Object ref =
ic.lookup(props.getProperty(JSR77Connector.CONTEXT));

Class mgmtHomeClass = bundleContext.getBundle().loadClass(MANAGEMENT_HOME);

ManagementHome mgmtHome = (ManagementHome)PortableRemoteObject.narrow(ref,
mgmtHomeClass);



alex



"Jeff McAffer" <jeff_mcaffer@REMOVE.ca.ibm.com> schrieb im Newsbeitrag
news:cl3jtu$5ec$1@eclipse.org...
>I would start by trying to find if there is someone else who can supply the
>class you are trying to narrow to. I suspect that the context classloader
>is finding a different one than you expect.
>
> BTW, who is setting up the context classloader? What are you expecting it
> to be?
>
> Jeff
>
> "Alex B
Previous Topic:regarding plugin loading
Next Topic:OSGi - How can a UPnPStateVariable generate an event?
Goto Forum:
  


Current Time: Sat May 10 14:31:55 EDT 2025

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

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

Back to the top