Details
-
Bug
-
Resolution: Done
-
Major
-
EJB 3.0 RC6 - PFD
-
None
-
None
Description
The container does not inject resources in Stateful SessionBean at @PostActivate methods.
According to EJB 3 spec final draft:
5.1.5 Dependency Injection
If a stateful session bean uses dependency injection mechanisms for the acquisition of references to
resources or other objects in its environment, the container injects these references
before any business methods or lifecycle callback interceptor methods are invoked on the bean instance.
@Stateful
@Remote(value=BonusProcess.class)
public class BonusProcessBean implements BonusProcess {
short year;
double total;
TreeMap ranking = null;
@Resource SessionContext sessionCtx;
@Resource(mappedName="java:/dataSourceRH") public javax.sql.DataSource dataSourceRH;
@Resource(mappedName="java:/ConnectionFactory") public javax.jms.QueueConnectionFactory jmsQConnFactory;
@Resource(mappedName="queue/A") public javax.jms.Queue queue;
public void openProcess(short year, double bonusTotal)
{ ... }...
@PrePassivate
public void releaseResources()
@PostActivate
public void recoverResources()
@Remove(retainIfException=true)
public void deliverBonus() {
try
{ javax.jms.QueueConnection qConn = jmsQConnFactory.createQueueConnection(); javax.jms.QueueSession qSession = qConn.createQueueSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); javax.jms.QueueSender qSender = qSession.createSender(queue); javax.jms.ObjectMessage objMsg = qSession.createObjectMessage(); objMsg.setDoubleProperty("bonusTotal", total); objMsg.setShortProperty("year", year); objMsg.setObject(ranking); qSender.send(objMsg); qConn.close(); }catch (javax.jms.JMSException e)
{ throw new EJBException(e); }}
}
From the server console:
( some business methods calls, and wait for passivation )
14:14:11,015 INFO [STDOUT] passivanting
14:14:11,109 INFO [FieldsManager] FieldsManager in use = org.jboss.serial.classmetamodel.UnsafeFieldsManager
( calling more business methods )
14:19:07,234 INFO [STDOUT] activating
14:19:07,234 INFO [STDOUT] true
14:19:07,234 INFO [STDOUT] true
14:19:07,234 INFO [STDOUT] true
From the remote client view, calling business methods after passivation
java.lang.NullPointerException
javax.ejb.EJBException: java.lang.NullPointerException
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateful.StatefulRemoveInterceptor.invoke(StatefulRemoveInterceptor.java:80)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:308)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:104)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
at org.jboss.remoting.Client.invoke(Client.java:525)
at org.jboss.remoting.Client.invoke(Client.java:488)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:133)
at $Proxy2.deliverBonus(Unknown Source)