glassfish
  1. glassfish
  2. GLASSFISH-2105

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

    Details

    • 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:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      2,105

      Description

      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
      http://scarry-nt.east.sun.com:8080/SimpleService/Simple
      DPL5306:EJB Web Service Endpoint [Bank] listening at address
      http://scarry-nt.east.sun.com:8080/BankService/Bank
      deployed with moduleid = wstxSampleService-ejb
      ADM1041:Sent the event to instance:[ModuleDeployEvent – enable
      ejb/wstxSampleService-ejb]
      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 = "http://tempuri.org/"
      )
      @Stateless
      @TransactionManagement(TransactionManagementType.CONTAINER)
      @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
      public class Simple {

      private Connection connection = null;

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

      /**

      • Creates the connection.
        */
        @PostConstruct
        public void makeConnection() {
        logger.info("acquiring JMS connection for instance " + this.toString());
        try
        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

          Activity

          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 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved: