CDI interceptors with Wildfly 10 in multi module maven projects
csaba.sarkadi Apr 19, 2016 1:53 PMHi,
I am having problems with using CDI interceptors in a multi module maven project.
I have created a minimalistic project, showing what I am trying to accomplish. I may have a misunderstanding on how should I writer the interceptors or maybe I have found another wildfly 10 bug?
Long story short: I want to create an api module in my bigger maven project. I need a generic interceptor that should do the logging, when calling an EJB method (the EJB is injected via @Inject).
So:
1. Root pom (test-interceptor)
1.1 interceptor-api module : this one contains the interceptor (EJBInterceptor.java) and the annotation (@InterceptedLogging.java)
1.2 interceptor-ejb module: and ejb jar module, containing a single @Stateless EJB (InterceptedEJB.java)
1.3 test-web module: simple web module, containing a @WebServlet, that has the above EJB injected via @Inject
I have attached the sample project.
Thanks everyone for the help!
Error message from Wildfly 10 console (after trying to deploy the test-web module):
19:37:48,035 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) WFLYDS0004: Found test-web.war in deployment directory. To trigger deployment create a file called test-web.war.dodeploy
19:37:48,067 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0028: Stopped deployment test-web.war (runtime-name: test-web.war) in 15ms
19:37:48,071 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "test-web.war" (runtime-name: "test-web.war")
19:37:48,525 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."test-web.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."test-web.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "test-web.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.test.web.InterceptingWebServlet with ClassLoader ModuleClassLoader for Module "deployment.test-web.war:main" from Service Module Loader
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)
at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:57)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:106)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:91)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
... 5 more
Caused by: java.lang.NoClassDefFoundError: Ltest/ejb/InterceptedEJB;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:72)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)
... 10 more
Caused by: java.lang.ClassNotFoundException: test.ejb.InterceptedEJB from [Module "deployment.test-web.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 15 more
19:37:48,526 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"test-web.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"test-web.war\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"test-web.war\"
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.test.web.InterceptingWebServlet with ClassLoader ModuleClassLoader for Module \"deployment.test-web.war:main\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: Ltest/ejb/InterceptedEJB;
Caused by: java.lang.ClassNotFoundException: test.ejb.InterceptedEJB from [Module \"deployment.test-web.war:main\" from Service Module Loader]"}}
19:37:48,551 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "test-web.war" with deployment "test-web.war"
19:37:48,552 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."test-web.war".POST_MODULE
service jboss.deployment.unit."test-web.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."test-web.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "test-web.war"
-
test-interceptor.zip 22.2 KB