[jboss-jira] [JBoss JIRA] (AS7-5257) Constructor injection on EJB interceptors not working

Stuart Douglas (JIRA) jira-events at lists.jboss.org
Thu Jul 26 22:40:06 EDT 2012


    [ https://issues.jboss.org/browse/AS7-5257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12708217#comment-12708217 ] 

Stuart Douglas commented on AS7-5257:
-------------------------------------

If you add a default constructor as well constructor injection should work. 

The spec actually says: "An interceptor class must have a public no-arg constructor."

We should actually be able to relax this restriction though as a non standard extension.
                
> Constructor injection on EJB interceptors not working
> -----------------------------------------------------
>
>                 Key: AS7-5257
>                 URL: https://issues.jboss.org/browse/AS7-5257
>             Project: Application Server 7
>          Issue Type: Bug
>          Components: CDI / Weld
>    Affects Versions: 7.1.2.Final (EAP)
>            Reporter: Patrick Ruckstuhl
>            Assignee: Stuart Douglas
>
> Using JBoss 7.1 I use an EJB intercepter and would like to use constructor inject. This does not seem to work, but normal injection works fine.
> This one fails with
> Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011056: No default constructor for interceptor class
> public class CacheInterceptor {
>     private final DummyCache myCache;
>     @Inject
>     public CacheInterceptor(final DummyCache myCache) {
>         this.myCache = myCache;
>     }
>     @AroundInvoke
>     public Object intercept(final InvocationContext ctx) throws Exception {
> ....
>     }
> }
> but this works fine and DummyCache gets injected
> public class CacheInterceptor {
>     @Inject
>     private DummyCache myCache;
>     public CacheInterceptor() {
>     }
>     @AroundInvoke
>     public Object intercept(final InvocationContext ctx) throws Exception {
> ....
>     }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list