1. glassfish
  2. GLASSFISH-2105

EJB Web Service resource injection occuring after @PostConstruct method is invoked


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.1pe
    • Fix Version/s: 9.1pe
    • Component/s: web_services
    • Labels:
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:


      Copying a JMS Connection Factory idiom used by a Stateless EJB in Java EE
      tutorial, this idion does not work for a Web Service EJB. The resource injected
      connection factory is null, when the @PostConstruct method is called. Here
      is app server log trace of issue.

      Component versions involved:
      Glassfish promoted build 30.
      Developer build of latest WSIT libraries from 1/19/2007.

      Begin app server log trace of deployment of web service:

      wsgen successful
      wsgen successful
      DPL5306:EJB Web Service Endpoint [Simple] listening at address
      DPL5306:EJB Web Service Endpoint [Bank] listening at address
      deployed with moduleid = wstxSampleService-ejb
      ADM1041:Sent the event to instance:[ModuleDeployEvent – enable
      acquiring JMS connection for instance wstx.sample.service.Simple@173d72d
      assertion failure: connectionFactory should not be null, resource injection for
      connectionFactory has not occurred yet.
      Simple.makeConnection:Exception: java.lang.NullPointerException

      End app server log file.

      Workaround for this problem is to call makeConnection()
      once within one of the EJB methods when it notices that
      connection has not been set yet.

      Will attach source file and ejb jar file for this issue.

      Fragment of web service ejb illustrating key components

      @WebService(portName = "SimpleServiceBinding",
      targetNamespace = ""
      public class Simple {

      private Connection connection = null;

      @Resource(mappedName = "jms/ConnectionFactory")
      private ConnectionFactory connectionFactory;


      • Creates the connection.
        public void makeConnection() {"acquiring JMS connection for instance " + this.toString());
        Unknown macro: { if (connectionFactory == null) { System.out.println("assertion failure: connectionFactory should not be null, resource injection for connectionFactory has not occurred yet."); } connection = connectionFactory.createConnection(); }

        catch (Throwable t)

        { // JMSException could be thrown logger.severe("Simple.makeConnection:" + "Exception: +t.toString()); }


        Issue Links


          Joe Fialli created issue -
          kenaiadmin made changes -
          Field Original Value New Value
          issue.field.bugzillaimportkey 2105 33709
          Cheng Fang made changes -
          Link This issue is related to GLASSFISH-18406 [ GLASSFISH-18406 ]


            • Assignee:
              Joe Fialli
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: