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

          Hide
          Joe Fialli added a comment -

          Created an attachment (id=699)
          Web Service EJB with resource injection of JMS connection factory and a @PostConstruct annotated method

          Show
          Joe Fialli added a comment - Created an attachment (id=699) Web Service EJB with resource injection of JMS connection factory and a @PostConstruct annotated method
          Hide
          Joe Fialli added a comment -

          Created an attachment (id=700)
          EJB jar to recreate this issue. Just deploy ejb jar and look at server log for reported error to recreate. Error will not print if resource injection of connectionFactory instance occurs BEFORE the @PostConstruct method is called.

          Show
          Joe Fialli added a comment - Created an attachment (id=700) EJB jar to recreate this issue. Just deploy ejb jar and look at server log for reported error to recreate. Error will not print if resource injection of connectionFactory instance occurs BEFORE the @PostConstruct method is called.
          Hide
          Joe Fialli added a comment -

          Created an attachment (id=701)
          Java EE tutorial sample that JMS Connection idiom was adapted from.

          Show
          Joe Fialli added a comment - Created an attachment (id=701) Java EE tutorial sample that JMS Connection idiom was adapted from.
          Hide
          vijaysr added a comment -

          reassigning

          Show
          vijaysr added a comment - reassigning
          Hide
          gfbugbridge added a comment -

          <BT6543271>

          Show
          gfbugbridge added a comment - <BT6543271>
          Hide
          mikeg added a comment -

          Fixed in build b50.

          Show
          mikeg added a comment - Fixed in build b50.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: