[jboss-jira] [JBoss JIRA] Created: (JBAS-9391) EJB3.1 spec 4.8.4: destroying singleton because of error during initialization is not honored

Pierre Kobylanski (JIRA) jira-events at lists.jboss.org
Sat May 21 15:32:00 EDT 2011


EJB3.1 spec 4.8.4: destroying singleton because of error during initialization is not honored
---------------------------------------------------------------------------------------------

                 Key: JBAS-9391
                 URL: https://issues.jboss.org/browse/JBAS-9391
             Project: Legacy JBoss Application Server 6 
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: EJB
    Affects Versions: 6.0.0.Final
         Environment: $ uname -a
Linux tumlatum 2.6.38-2-686-bigmem #1 SMP Sun May 8 15:43:39 UTC 2011 i686 GNU/Linux
            Reporter: Pierre Kobylanski
            Assignee: Carlo de Wolf


ejb 3.1 spec [4.8.4 Singleton Error Handling] says that "Errors occurring during Singleton initialization are considered fatal and must result in the discarding of the Singleton instance."
I tried to raise a system exception in the @PostConstruct method of a singleton bean. Logs show the deployment error. But I then can access and call the singleton methods.


-- Full paragraph 4.8.4: -----------------------------
Errors occurring during Singleton initialization are considered fatal and must result in the discarding of the Singleton instance. Possible initialization errors include injection failure, a system exception thrown from a PostConstruct method, or the failure of a PostConstruct method container-managed transaction to successfully commit. If a singleton fails to initialize, attempted invocations on the Singleton result in an exception as defined by Section 3.4.3 and Section 3.4.4.
------------------------------------------------------

I tested to raise a system exception (throw new RuntimeException()) in the @PostConstruct method.

-- Logs show the error -------------------------------
ERROR [AbstractKernelController] Error installing to Start: name=startup-singleton-initiator:topLevelUnit=ts.ear,unit=testSingletonEjb.jar,bean=counter aliases=[startup-singleton-initiator:bean=counter,topLevelUnit=ts.ear,unit=testSingletonEjb.jar] state=Create: java.lang.RuntimeException: Could not invoke PostConstruct on the newly created bean instance
  at org.jboss.ejb3.singleton.impl.container.SingletonEJBInstanceManagerImpl.create(SingletonEJBInstanceManagerImpl.java:137) [:1.0.0-alpha-28]
...
Caused by: testsingleton.exn.SE // class SE extends RuntimeException{}
        at testsingleton.ejb.CounterEjb.pc(CounterEjb.java:28)

DEPLOYMENTS IN ERROR:
  Deployment "startup-singleton-initiator:topLevelUnit=ts.ear,unit=testSingletonEjb.jar,bean=counter" is in error due to the following reason(s): testsingleton.exn.SE
        at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1228) [:2.2.0.GA]
------------------------------------------------------

However, it is after that possible to access the singleton through a JNDI lookup and successfully call its methods.


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list