[GLASSFISH-20667] EAR deployment fails with WELD-001417: Enabled interceptor (...) is neither annotated @Interceptor nor registered through a portable extension Created: 26/Jun/13  Updated: 23/Sep/13  Resolved: 23/Sep/13

Status: Resolved
Project: glassfish
Component/s: cdi
Affects Version/s: 4.0_b89_RC5
Fix Version/s: None

Type: Bug Priority: Blocker
Reporter: synti Assignee: jjsnyder83
Resolution: Works as designed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 8
Glassfish 4 b89 (bundled with NetBeans 7.3.1)



 Description   

In a maven enterprise application with EJB and WEB modules, deployment fails if the EJB module declares a CDI interceptor.

Btw, implicit CDI is disabled. Not sure it matters.

The beans.xml in the EJB module:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="annotated">
    <interceptors>
        <class>com.foo.BarInterceptor</class>
    </interceptors>
</beans>

Interceptor and binding:

@Interceptor @Bar
public class BarInterceptor implements Serializable {

    public BarInterceptor() {}
    
    @AroundInvoke
    public Object log(InvocationContext context) throws Exception {
        return context.proceed();
    }
    
    private static final long serialVersionUID = 1L;
}
@Inherited
@InterceptorBinding
@Retention(RUNTIME)
@Target({METHOD, TYPE})
public @interface Bar {}

Server log

[2013-06-26T20:17:10.522-0300] [glassfish 4.0] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=38 _ThreadName=admin-listener(4)] [timeMillis: 1372288630522] [levelValue: 1000] [[
  Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001417 Enabled interceptor class <class>com.foo.BarInterceptor</class> in file:/E:/.../Interceptor-ear/Interceptor-ejb-1.0-SNAPSHOT_jar/META-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension
	at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:225)
	at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
	at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:356)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
	at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
	at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
	at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
	at java.lang.Thread.run(Thread.java:722)
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>com.foo.BarInterceptor</class> in file:/E:/.../Interceptor-ear/Interceptor-ejb-1.0-SNAPSHOT_jar/META-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension
	at org.jboss.weld.bootstrap.Validator.validateEnabledInterceptorClasses(Validator.java:656)
	at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:482)
	at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:536)
	at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:216)
	... 36 more
]]
[2013-06-26T20:17:10.527-0300] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=38 _ThreadName=admin-listener(4)] [timeMillis: 1372288630527] [levelValue: 1000] [[
  Exception while loading the app]]
[2013-06-26T20:17:10.556-0300] [glassfish 4.0] [SEVERE] [AS-WEB-GLUE-00192] [javax.enterprise.web] [tid: _ThreadID=38 _ThreadName=admin-listener(4)] [timeMillis: 1372288630556] [levelValue: 1000] [[
  Undeployment failed for context /Interceptor-web]]
[2013-06-26T20:17:10.650-0300] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=38 _ThreadName=admin-listener(4)] [timeMillis: 1372288630650] [levelValue: 1000] [[
  Exception while loading the app : CDI deployment failure:WELD-001417 Enabled interceptor class <class>com.foo.BarInterceptor</class> in file:/E:/.../Interceptor-ear/Interceptor-ejb-1.0-SNAPSHOT_jar/META-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension
org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>com.foo.BarInterceptor</class> in file:/E:/.../gfdeploy/Interceptor-ear/Interceptor-ejb-1.0-SNAPSHOT_jar/META-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension
	at org.jboss.weld.bootstrap.Validator.validateEnabledInterceptorClasses(Validator.java:656)
	at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:482)
	at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:536)
	at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:216)
	at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
	at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:356)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
	at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
	at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
	at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
	at java.lang.Thread.run(Thread.java:722)
]]


 Comments   
Comment by synti [ 28/Jun/13 ]

The problem is the new namespace. Both deployment and interception works fine after changing it back to:

<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
Comment by jjsnyder83 [ 03/Jul/13 ]

Please attach the app and source code (if possible) that demonstrates the failure.

Comment by synti [ 05/Jul/13 ]

Contains source and app:
https://dl.dropboxusercontent.com/u/91581899/Interceptor.zip

Comment by laurent_bauchau [ 14/Aug/13 ]

The problem is the new namespace. Both deployment and interception works fine after changing it back to:

<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

This change doesn't solve the problem for me.

I've "solved" the problem with: bean-discovery-mode="all" instead of "annotated"

Comment by synti [ 20/Aug/13 ]

Just confirming. Using the 1.1 beans.xml with bean-discovery-mode="all" also worked here.

Comment by javadon [ 22/Sep/13 ]

I too have same problem,

Environment: eclipse kepler, java-ee7, cdi 1.1, Glass Fish 4.0.1,..etc.

http://stackoverflow.com/questions/17258639/interceptor-issue-with-java-ee7

any help will be appreciated.

Comment by TangYong [ 23/Sep/13 ]

JJ
CC: All

The issue should be right behavior on current CDI Spec. I have done a confirmation on wildfly-8.0.0.Alpha4 and the same WELD-001417
exception is thrown. You can confirm with JBOSS guys.

The issue has two workarounds :

1. backing CDI 1.0
using http://java.sun.com/xml/ns/javaee/beans_1_0.xsd

2. using bean-discovery-mode="all"

So, if being the such case, the issue should be closed.

Thanks
Tang

Comment by jjsnyder83 [ 23/Sep/13 ]

I believe the deployment exception is accurate for CDI 1.1. The beans.xml for the jar with the interceptor contains:
bean-discovery-mode="annotated"

This means that only classes with bean-defining annotations will be managed by CDI. Since the interceptor does not contain a bean-defining annotation it is not managed by CDI. bean-defining annotations and implicit CDI is new with CDI 1.1.

Changing bean-discover-mode to "all" is the correct solution.

Generated at Mon Mar 30 14:52:40 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.