<< Back to previous view

[GLASSFISH-6854] NullPointerException occurs if "optional" <log-service> element is not included the sun-acc.xml file Created: 27/Nov/08  Updated: 01/Dec/10  Resolved: 07/Apr/09

Status: Resolved
Project: glassfish
Component/s: standalone_client
Affects Version/s: 9.1.1
Fix Version/s: 9.1.1_dev

Type: Bug Priority: Minor
Reporter: gregn123 Assignee: Tim Quinn
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


File Attachments: File cart.ear    
Issuezilla Id: 6,854
Tags:
Participants: Dies Koper, gregn123, sanandal and Tim Quinn

 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(); }
}



 Comments   
Comment by gregn123 [ 27/Nov/08 08:47 PM ]

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

Comment by sanandal [ 11/Jan/09 07:01 AM ]

"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."

Comment by Dies Koper [ 07/Apr/09 08:04 PM ]

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

Generated at Sat Apr 19 08:46:38 UTC 2014 using JIRA 4.0.2#472.