-
Bug
-
Resolution: Obsolete
-
Major
-
JBossAS-5.1.0.GA
-
None
-
JBoss 5.1.0.GA, JDK6
-
Workaround Exists
-
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()
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.