Hi guys,
in cdi-integration I don't get how the deployment can work cause the thread
local bus is not set
Here what i did to ensure i use a single bus (and prevented the cxf one to
run):
public class JAXRSCdiResourceExtensionWorkaround extends
JAXRSCdiResourceExtension {
@Override
public void load(@Observes final AfterDeploymentValidation event,
final BeanManager beanManager) {
final Bus bus =
Bus.class.cast(beanManager.getReference(beanManager.resolve(beanManager.getBeans(Bus.class)),
Bus.class, null));
BusFactory.setThreadDefaultBus(bus); // cause app class will
rely on that and would create multiple bus and then deployment would
be broken
try {
super.load(event, beanManager);
} finally {
BusFactory.clearDefaultBusForAnyThread(bus);
}
}
}
Issue was caused by JAXRSCdiResourceExtension#createFactoryInstance which
calls ResourceUtils.createApplication which uses the thread bus which is
not set by the extension leading to 2 buses.
Did I miss something?
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>