-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
7u9
-
windows_7
FULL PRODUCT VERSION :
java version " 1.7.0_09 "
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
GlassFish Server Open Source Edition 3.1.2 (build 23)
A DESCRIPTION OF THE PROBLEM :
The LogManager$Cleaner used to close all handlers on shutdown has a null context classloader to avoid a leak. If the Handler being closed needs to load classes, like javax.activation, the operation can fail when the supporting classes are not in the system class path (Glassfish).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attach com.sun.mail.util.logging.MailHandler to logger in Glassfish. Add a log record to the handler. Shutdown Glassfish.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using the test case bellow, it should report:
No recipient addresses.
javax.mail.MessagingException: No recipient addresses.
ACTUAL -
The LogManager$Cleaner is unable to load the JAF classes.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.logging.ErrorManager: 3: SEVERE: no object DCH for MIME type multipart/mixed;
boundary= " ----=_Part_17_1192843904.1354830098405 "
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
boundary= " ----=_Part_17_1192843904.1354830098405 "
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:891)
at javax.activation.DataHandler.writeTo(DataHandler.java:317)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1476)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1772)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1748)
at com.sun.mail.util.logging.MailHandler.toRawString(MailHandler.java:2196)
at com.sun.mail.util.logging.MailHandler.send(MailHandler.java:1597)
at com.sun.mail.util.logging.MailHandler.close(MailHandler.java:552)
at java.util.logging.LogManager.resetLogger(LogManager.java:860)
at java.util.logging.LogManager.reset(LogManager.java:843)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
@WebServlet(name = " MailTest " , urlPatterns = { " /MailTest " })
public class MailTest extends HttpServlet {
private static final Logger logger = Logger.getLogger( " " );
@Override
public void init() throws ServletException {
logger.addHandler(new MailHandler());
logger.warning( " init " );
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Flush all handlers in a servlet context listener when the context is destroyed.
The current workaround is to set the context class loader to the MailHandler class in the close method of the MailHandler.
The JDK fix should be to change LogManager.resetLogger to detect that the cleaner thread is the current thread and use the classloader of the current handler or the target of a MemoryHandler as the context class loader during the close operation.
java version " 1.7.0_09 "
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
GlassFish Server Open Source Edition 3.1.2 (build 23)
A DESCRIPTION OF THE PROBLEM :
The LogManager$Cleaner used to close all handlers on shutdown has a null context classloader to avoid a leak. If the Handler being closed needs to load classes, like javax.activation, the operation can fail when the supporting classes are not in the system class path (Glassfish).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attach com.sun.mail.util.logging.MailHandler to logger in Glassfish. Add a log record to the handler. Shutdown Glassfish.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using the test case bellow, it should report:
No recipient addresses.
javax.mail.MessagingException: No recipient addresses.
ACTUAL -
The LogManager$Cleaner is unable to load the JAF classes.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.logging.ErrorManager: 3: SEVERE: no object DCH for MIME type multipart/mixed;
boundary= " ----=_Part_17_1192843904.1354830098405 "
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
boundary= " ----=_Part_17_1192843904.1354830098405 "
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:891)
at javax.activation.DataHandler.writeTo(DataHandler.java:317)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1476)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1772)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1748)
at com.sun.mail.util.logging.MailHandler.toRawString(MailHandler.java:2196)
at com.sun.mail.util.logging.MailHandler.send(MailHandler.java:1597)
at com.sun.mail.util.logging.MailHandler.close(MailHandler.java:552)
at java.util.logging.LogManager.resetLogger(LogManager.java:860)
at java.util.logging.LogManager.reset(LogManager.java:843)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
@WebServlet(name = " MailTest " , urlPatterns = { " /MailTest " })
public class MailTest extends HttpServlet {
private static final Logger logger = Logger.getLogger( " " );
@Override
public void init() throws ServletException {
logger.addHandler(new MailHandler());
logger.warning( " init " );
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Flush all handlers in a servlet context listener when the context is destroyed.
The current workaround is to set the context class loader to the MailHandler class in the close method of the MailHandler.
The JDK fix should be to change LogManager.resetLogger to detect that the cleaner thread is the current thread and use the classloader of the current handler or the target of a MemoryHandler as the context class loader during the close operation.