[jboss-jira] [JBoss JIRA] Created: (JBAS-7190) 'More than one post-construct method'-Exception when @PostContruct method is overloaded

Mathias Arens (JIRA) jira-events at lists.jboss.org
Thu Aug 20 06:12:26 EDT 2009


'More than one post-construct method'-Exception when @PostContruct method is overloaded
---------------------------------------------------------------------------------------

                 Key: JBAS-7190
                 URL: https://jira.jboss.org/jira/browse/JBAS-7190
             Project: JBoss Application Server
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: EJB3
    Affects Versions: JBossAS-5.1.0.GA
         Environment: JBoss 5.1.0.GA, JDK6
            Reporter: Mathias Arens
            Assignee: Carlo de Wolf


I have a stateless session bean with a initialize() routine that is annotated with a @PostConstruct annotation. The intialize() routine is overloaded but the overloaded routine doesn't have a @PostConstruct annotation, like this:

@Stateless
public class AccessorBean  implements AccessorLocal {
   public AccessorBean() {
    }

    @PostConstruct
    public void initialize() {
        this.initialize(em, cache);
    }

    private void initialize(EntityManager em, Cache cache) {
        accessor = new EntityAccessorJPA(em);
        accessor.setCache(cache);
    }
   [..]
}

When I access my bean I get the following RuntimeException:

javax.ejb.EJBTransactionRolledbackException: java.lang.RuntimeException: More than one 'post-construct' method in AccessorBean
        at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)
        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
        at org.jboss.ejb3.security.RunAsSecurityInterceptorv2.invoke(RunAsSecurityInterceptorv2.java:94)
        [...]  
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: More than one 'post-construct' method in AccessorBean
        at org.jboss.ejb3.EJBContainer.invokeCallback(EJBContainer.java:1123)
        at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:1133)
        at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:1144)
        at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:93)
        at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:56)
        at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:51)
        at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:53)
        at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:93)
        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:58)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
        ... 82 more
Caused by: java.lang.RuntimeException: More than one 'post-construct' method in AccessorBean
        at org.jboss.ejb3.interceptors.aop.LifecycleCallbacks.checkClass(LifecycleCallbacks.java:135)
        at org.jboss.ejb3.interceptors.aop.LifecycleCallbacks.createLifecycleCallbackInterceptors(LifecycleCallbacks.java:103)
        at org.jboss.ejb3.EJBContainer.invokeCallback(EJBContainer.java:1112)
        ... 92 more

But I annotated only one routine with the @PostContruct annotation. The reason for this seams to be the overloaded initialize() routine. If I don't overload it everything is fine.

This seems to be a bug in JBoss5. Maybe the checkClass() routine in the LifecycleCallbacks class assumes that every overloaded method of a with an @PostConstruct annotated method has also a @PostContruct annotation.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list