-
1. Re: Same JNDI Lookup from different MBeans (but same ClassLo
jpyorre May 25, 2006 12:09 PM (in response to jpyorre)Forgot to tell that I'm using JBoss AS 4.0.4GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)
-
2. Re: Same JNDI Lookup from different MBeans (but same ClassLo
jpyorre May 25, 2006 1:18 PM (in response to jpyorre)Still one more observation:
If the MBean is deployed using jboss-service.xml, JNDI lookup works. If the same MBean is deployed using createMBean method from another MBean, an exception occurs.
So, the way the MBean is deployed seems to make the difference. -
3. Re: Same JNDI Lookup from different MBeans (but same ClassLo
jpyorre May 25, 2006 5:00 PM (in response to jpyorre)The monologue continues: I have managed to resolve that the problem is in the context class loader.
When invoking methods in MBeans deployed by the SARDeployer the context class loader is UnifiedClassLoader3 instance defined by the loader-repository element in jboss-service.xml.
When an MBean creates another MBean, the Context ClassLoader is set to some other when invoking a method in the MBean.
How can I set the context classloader of the MBean? I can easily performThread.currentThread().setContextClassLoader(this.getClass().getClassLoader())
but this is not an elegant solution as the context class loader should be automatically set (as it is when deploying an MBean using SARDeployer). -
4. Re: Same JNDI Lookup from different MBeans (but same ClassLo
starksm64 May 25, 2006 7:03 PM (in response to jpyorre)There is more than one createMBean signature. Think about those that take a loaderName.
-
5. Re: Same JNDI Lookup from different MBeans (but same ClassLo
jpyorre May 26, 2006 5:22 AM (in response to jpyorre)The loaderName for createMBean is not directly available, so I use the following trick (because UnifiedClassLoader3 is implementing an MBean interface):
ObjectName loaderName = ObjectName.getInstance("my.dot.com:service=MyClassLoader"); if (!getServer().isRegistered(loaderName)) { getServer().registerMBean(this.getClass().getClassLoader(), loaderName); }
I suppose this is the only way to do it, bacause all methods that would accept ClassLoader instance directly are protected in MBeanServerImpl.
Thanks for the advice, Scott!
Regards,
Jussi