[ mx4j-Bugs-1596697 ] NPE on MBeanServerFactory when running as Windows Services

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <[email protected]>
Bugs item #1596697, was opened at 2006-11-14 16:01
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=1596697&group_id=47745

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: JMX implementation
Group: Release 3.0.1
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: jefflin (jefflin2004)
Assigned to: Nobody/Anonymous (nobody)
Summary: NPE on MBeanServerFactory when running as Windows Services

Initial Comment:
Using Tomcat 5.5.9 and configured -Djavax.management.builder.initial=mx4j.server.MX4JMBeanServerBuilder for running as windows services. The following NullPointerException is thrown:

Nov 14, 2006 3:51:23 PM org.apache.catalina.startup.Bootstrap initClassLoaders
SEVERE: Class loader creation threw exception
java.lang.NullPointerException
        at javax.management.MBeanServerFactory.loadMBeanServerBuilderClass(MBean
ServerFactory.java:266)
        at javax.management.MBeanServerFactory.createMBeanServerBuilder(MBeanSer
verFactory.java:229)
        at javax.management.MBeanServerFactory.createMBeanServerImpl(MBeanServer
Factory.java:195)
        at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFact
ory.java:44)
        at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFact
ory.java:39)
        at org.apache.catalina.startup.Bootstrap.createClassLoader(Bootstrap.jav
a:188)
        at org.apache.catalina.startup.Bootstrap.initClassLoaders(Bootstrap.java
:97)
        at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:212)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
        
==

I noticed that inside MBeanServerFactory.loadMBeanServerBuilderClass(),  Thread.currentThread().getContextClassLoader() is null when it runs as a Widnows Services. The following code was added into MBeanServerFactory.java to fix the problem:

try
{
	 // new code - start
	 if (Thread.currentThread().getContextClassLoader() == null) {
		 Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
	 }
	 // new code - end

 return Thread.currentThread().getContextClassLoader().loadClass(builderClassName);
}

Please 1) patch mx4j or 2) find out when Thread.currentThread().getContextClassLoader() == null



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=1596697&group_id=47745

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.