JBoss EAP 7.2 Error java.lang.NoClassDefFoundError NamespaceContextSelector When Using Weld Transactions
Environment
- Red Hat JBoss Enterprise Application Platform (JBoss EAP) 7.1+
- Contexts and Dependency Injection (CDI)
- CDI Transaction management
Issue
- JBoss EAP 7.2 Error java.lang.NoClassDefFoundError NamespaceContextSelector When Using Weld Transactions
- Stack Trace in log:
Caused by: java.lang.NoClassDefFoundError: org/jboss/as/naming/context/NamespaceContextSelector
at org.jboss.as.weld.services.bootstrap.JTSSynchronizationWrapper.<init>(JTSSynchronizationWrapper.java:44)
at org.jboss.as.weld.services.bootstrap.WeldTransactionServices.registerSynchronization(WeldTransactionServices.java:95)
at org.jboss.weld.module.jta.TransactionalObserverNotifier.notifyTransactionObservers(TransactionalObserverNotifier.java:86)
at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:274)
at org.jboss.weld.event.EventImpl.fire(EventImpl.java:96)
at com.jboss.examples.filter.ExampleFilter.filter(ExampleFilter.java:12)
Resolution
You can workaround the issue by adding the dependency on "org.jboss.as.naming" to the module "org.jboss.as.weld.transactions". It is suggested to make a copy of the module in the root of {JBOSS_HOME}/modules, for example:
$ cp -R modules/system/layers/base/org/jboss/as/weld/transactions modules/org/jboss/as/weld/transaction
Then edit modules/org/jboss/as/weld/transaction/main/module.xml
<module name="org.jboss.as.ee"/>
+ <module name="org.jboss.as.naming"/>
<module name="org.jboss.as.security"/>
Once the issue is corrected, remove the module copy, but until then, patches won't overwrite the change.
An issue report has been filed: Content from issues.jboss.org is not included.JBEAP-18033.
Root Cause
This is caused by a missing dependency on "org.jboss.as.naming" in the "org.jboss.as.weld.transactions" module. Specifically JTSSynchronizationWrapper imports NamespaceContextSelector.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.