eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
386 stars 144 forks source link

Unable to get @InterceptorBinding working #20914

Closed glassfishrobot closed 10 years ago

glassfishrobot commented 10 years ago

I have created a InterceptorBinding annotation

@Inherited @InterceptorBinding @Target(

{ TYPE, METHOD }

) @Retention(RUNTIME) public @interface BusinessMethod { }

And the following interceptor

@BusinessMethod @Interceptor public class LoggingInterceptor { private static final Logger log = Logger.getLogger("net.trajano.app"); @AroundInvoke public Object log(final InvocationContext ctx) throws Throwable { log.warning("around invoke " + ctx.getMethod()); try

{ return ctx.proceed(); }

catch (final Throwable e)

{ log.severe("Error calling ctx.proceed in " + ctx.getMethod()); throw e; }

} }

In my SLSB I have added the annotation

@Stateless @BusinessMethod public class PersistedBeans

However, the interceptor methods do not work. Explicitly listing the interceptor using @Interceptors(LoggingInterceptor.class) works thouhg.

Affected Versions

[4.0]

glassfishrobot commented 6 years ago
glassfishrobot commented 10 years ago

@glassfishrobot Commented atrajano said: Seems you require adding it to the beans.xml

<?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" version="1.1" bean-discovery-mode="annotated">

net.trajano.app.internal.LoggingInterceptor

Not sure if that is required by the spec or not, it didn't seem to take the CDI scopes into consideration.

Please close if that is the expected behaviour.

glassfishrobot commented 10 years ago

@glassfishrobot Commented reza_rahman said: This is unfortunately a known issue with the CDI spec: https://issues.jboss.org/browse/CDI-404. Hope this helps.

glassfishrobot commented 10 years ago

@glassfishrobot Commented @jjsnyder said: Add @Dependent to your interceptor definition. As stated previously there is a problem with the spec but according to the previously mentioned jira adding @Dependent should resolve your issue.

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-20914

glassfishrobot commented 10 years ago

@glassfishrobot Commented Reported by atrajano

glassfishrobot commented 10 years ago

@glassfishrobot Commented Marked as fixed on Wednesday, April 16th 2014, 12:27:36 pm