Reputation: 126
I'm testing / switching to Java EE7 (Glassfish 4) and one of the issues I have is with Interceptors, whenever I try to run the project I am getting the following error.
SEVERE: Exception while loading the app : CDI deployment failure:WELD-001417 Enabled interceptor class com.xxxxxx.security.SecuredInterceptor in file:/home/xxxxxx/xxxxxx/target/xxxxxx/WEB-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension
I'm looking at section 1.3.6 of the CDI 1.1 specification it doesn't look like anything has changed, so what am I doing wrong?
Here is the code I am using;
@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Secured {}
@Secured
@Interceptor
public class SecuredInterceptor implements Serializable
{
@AroundInvoke
public Object interceptSecured(InvocationContext ic) throws Exception
{
// Do Stuff
}
}
<?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.xxxxxx.security.SecuredInterceptor</class>
</interceptors>
</beans>
Upvotes: 7
Views: 3033
Reputation: 1367
From section 12.1 of the CDI spec.
A bean archive which contains a beans.xml file with no version has a default bean discovery mode of all.
Your version 1.1 beans.xml has bean-discovery-mode="annotated"
. Change beans.xml to bean-discovery-mode="all"
and my guess is it will work just like it does when you remove the version from beans.xml and use the old namespace, as in a CDI 1.0.
Upvotes: 5
Reputation: 126
Seems to be Glassfish bug related to 1.1 version of beans.xml
https://java.net/jira/browse/GLASSFISH-20667
Upvotes: 1