-
Bug
-
Resolution: Done
-
Major
-
3.1.1.Final
-
None
Using the following code to produce JCR Repository and Session instances causes Weld to throw NoClassDefFoundError when my web application is loaded by JBoss AS.
Stacktrace:
Caused by: java.lang.ClassNotFoundException: org.xml.sax.ContentHandler from [Module "javax.jcr:main" from local module
CDI Producer Code:
@Resource(mappedName="java:/jcr/myrepo") @Produces private Repository repository; @RequestScoped @Produces public Session getCurrentSession(final Repository repository) throws RepositoryException { return repository.login(); } public void logoutSession(@Disposes final Session session) { session.logout(); }
CDI Consumer Code:
@Inject private Session session; // ClassNotFoundException occurs when this class is loaded
On brief inspection, it seems that the JCR Session object has a method that depends on ContentHandler, and thus when Weld tries to access that method by reflection, it was unable to find ContentHandler. (Probably due to the classloader not having loaded the javax.xml dependencies yet)
It seems that the JBoss AS 7 kit is missing the following in jboss/modules/javax/jcr/main/module.xml:
<dependencies>
<module name="javax.api"/>
</dependencies>
I believe that GTNPORTAL-2593 had the same issue.
- is related to
-
AS7-6545 @RequestScoped producer method causes NoClassDefFoundError on an implicit dependency during injection
- Resolved