glassfish
  1. glassfish
  2. GLASSFISH-6854

NullPointerException occurs if "optional" <log-service> element is not included the sun-acc.xml file

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 9.1.1
    • Fix Version/s: 9.1.1_dev
    • Component/s: standalone_client
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      6,854

      Description

      Problem Description:
      ====================

      According to Sun's ACC DTD
      (http://www.sun.com/software/appserver/dtds/sun-application-client-container_1_2.dtd)
      the "log-service" element is optional.
      But if it is not included in the sun-acc.xml file, then a NullPointerException
      occurs in the com.sun.enterprise.server.logging.ACCLogManager class when the
      "appclient" command is used to run a client application.

      How to reproduce the problem:
      =============================

      1) Deploy sample "cart.ear" application, taken from Sun's own JavaEE5 tutorial
      (see attachment).

      asadmin deploy cart.ear

      2) Extract client stubs:

      asadmin get-client-stubs --appname cart .

      3) Make a local copy of the domain's sun-acc.xml file
      (glassfish/domains/domain1/config/sun-acc.xml) and comment out the <log-service>
      element:

      <!-log-service file="" level="WARNING"/->

      4) Run the client using the modified sun-acc.xml file (which now doesn't have a
      <log-service> element)

      appclient -client cartClient.jar -xml sun-acc.xml

      The following is output:

      28/11/2008 15:08:32 javax.enterprise.system.core
      SEVERE: ACC018: Failed to create client side logger
      java.lang.NullPointerException
      at
      com.sun.enterprise.server.logging.ACCLogManager.init(ACCLogManager.java:99)
      at
      com.sun.enterprise.appclient.MainWithModuleSupport.prepareLogging(MainWithModuleSupport.java:640)
      at
      com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:303)
      at
      com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
      at com.sun.enterprise.appclient.Main.main(Main.java:200)
      28/11/2008 15:08:32 com.sun.enterprise.appclient.MainWithModuleSupport
      prepareSecurity
      INFO: Security Manager is OFF.
      28/11/2008 15:08:32 com.sun.enterprise.appclient.MainWithModuleSupport
      setTargetServerProperties
      INFO: ACC001:Using ClientContainer file: [sun-acc.xml].
      28/11/2008 15:08:32 com.sun.enterprise.appclient.MainWithModuleSupport <init>
      INFO: ACC024: IIOP endpoint(s) = HOST001:3700
      28/11/2008 15:08:34 com.sun.enterprise.appclient.MainWithModuleSupport
      loadMainClientClass
      INFO: ACC009: Load Application Class: [cart.client.CartClient]
      Retrieving book title from cart: Infinite Jest
      Retrieving book title from cart: Bel Canto
      Retrieving book title from cart: Kafka on the Shore
      Removing "Gravity's Rainbow" from cart.
      Caught a BookException: "Gravity's Rainbow" not in cart.
      28/11/2008 15:08:34 com.sun.enterprise.appclient.MainWithModuleSupport$Cleanup run
      INFO: Clean-up starting

      Proposed Fix:
      =============

      In the "com.sun.enterprise.server.logging.ACCLogManager" class
      (glassfish/appserv-core/src/java), make the following modification:

      BEFORE:

      String logLevel = cc.getLogService().getLevel();
      if (logLevel != null && !logLevel.equals(""))

      { _logLevel = Level.parse(logLevel); }

      String logFileName = cc.getLogService().getFile();
      if (logFileName != null && !logFileName.equals(""))

      { _clientHandler = new FileHandler(logFileName, true); _clientHandler.setFormatter(new SimpleFormatter()); // workaround to delete lockfile upon exit File lockFile = new File(logFileName + ".lck"); lockFile.deleteOnExit(); }

      AFTER:

      import com.sun.enterprise.config.clientbeans.LogService;;

      ...

      LogService logService = cc.getLogService();

      if(logService != null) {
      String logLevel = logService.getLevel();
      if (logLevel != null && !logLevel.equals(""))

      { _logLevel = Level.parse(logLevel); }

      String logFileName = logService.getFile();
      if (logFileName != null && !logFileName.equals(""))

      { _clientHandler = new FileHandler(logFileName, true); _clientHandler.setFormatter(new UniformACCLogFormatter()); // workaround to delete lockfile upon exit File lockFile = new File(logFileName + ".lck"); lockFile.deleteOnExit(); }

      }

        Activity

        Hide
        gregn123 added a comment -

        Created an attachment (id=2122)
        Simple app for reproducing the NullPointerException

        Show
        gregn123 added a comment - Created an attachment (id=2122) Simple app for reproducing the NullPointerException
        Hide
        sanandal added a comment -

        "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1
        release whose primary release driver is SailFin.
        This issue will be scrubbed after this release and will be given the right
        priority for the next release."

        Show
        sanandal added a comment - "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1 release whose primary release driver is SailFin. This issue will be scrubbed after this release and will be given the right priority for the next release."
        Hide
        Dies Koper added a comment -

        Fixed in "GFv2.1-next".
        At this moment, Tim has not incorporated the log-service settings from sun-
        acc.xml into the logging in V3. When he does, he'll make sure not to
        reintroduce this issue.

        Checking in logging/ACCLogManager.java;
        /cvs/glassfish/appserv-
        core/src/java/com/sun/enterprise/server/logging/ACCLogManager.java,v <-- AC
        CLogManager.java
        new revision: 1.4.6.1; previous revision: 1.4
        done

        Show
        Dies Koper added a comment - Fixed in "GFv2.1-next". At this moment, Tim has not incorporated the log-service settings from sun- acc.xml into the logging in V3. When he does, he'll make sure not to reintroduce this issue. Checking in logging/ACCLogManager.java; /cvs/glassfish/appserv- core/src/java/com/sun/enterprise/server/logging/ACCLogManager.java,v <-- AC CLogManager.java new revision: 1.4.6.1; previous revision: 1.4 done

          People

          • Assignee:
            Tim Quinn
            Reporter:
            gregn123
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: