JBoss Community

Issues with modular classloading

created by Brian Stansberry in JBoss AS7 Development - View the full discussion

I've been experimenting with deploying managed bean jars and with sars, and am finding some classloading related problems. These don't show up in the tests in the sar and managedbean modules, probably because those tests aren't using a modular classpath.

 

First involves deploying a jar with managed beans:

 

22:52:37,610 INFO  [deployment] Activating deployment: managedBeanDeployment.jar
22:52:44,689 INFO  [managedbean] Starting managed bean service jboss.managed.bean.managedBeanDeployment_jar.TestBean
23:03:53,377 ERROR [deployment] Caught exception handling update (param is 13fde2d1-661b-499f-87e4-c955493c4a56): org.jboss.msc.service.StartException in service service jboss.managed.bean.managedBeanDeployment_jar.TestBeanWithInjection: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1037)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_20]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_20]
    at java.lang.Thread.run(Thread.java:637) [:1.6.0_20]
Caused by: org.jboss.msc.inject.InjectionException: Injecting the wrong type (expected class org.jboss.as.deployment.managedbean.TestManagedBean, got class javax.naming.Reference)
    at org.jboss.msc.inject.CastingInjector.inject(CastingInjector.java:51)
    at org.jboss.msc.service.ServiceControllerImpl.doInject(ServiceControllerImpl.java:729)
    at org.jboss.msc.service.ServiceControllerImpl.access$1100(ServiceControllerImpl.java:122)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:986)
    ... 3 more
Caused by: java.lang.ClassCastException
    at java.lang.Class.cast(Class.java:2990) [:1.6.0_20]
    at org.jboss.msc.inject.CastingInjector.inject(CastingInjector.java:49)
    ... 6 more

 

What's happening here is during start of a ManagedBeanService, an injection from a ResourceBinder is occuring. ResourceBinder.getValue() is doing a naming lookup. The lookup finds a LinkRef and tries to resolve it. Resolving it fails because the LinkRef points to a Reference. Reference has a classfactory "org.jboss.as.deployment.managedbean.container.ManagedBeanObjectFactory".  NamingManager tries to load that class and can't.

 

Tricky bit here is the thread involved is an MSC start task thread, so it's not a user request thread where we can readily set the TCCL.

 

The problem could be that we are doing this injection at this point in the first place? I haven't looked enough at how this service works to say.

 

If the lookup actually needs to happen during the start task, then we need some more smarts to get the classloading right. Perhaps in ResourceBinder.getValue(), perhaps with a custom ObjectFactoryBuilder that can do modular classloading, perhaps...

Reply to this message by going to Community

Start a new discussion in JBoss AS7 Development at Community