[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xmlblaster-devel] latest cvs refuses to start as a WIN-NT Service on W2000 due to NullPointerException in JAXPFactory



Hi,

the latest cvs release of today refuses to start as a WIN-NT Service on a
WIN 2000 mashine using SUN JDK 1.3.1

When starting, it throws a NullPointerException from package
org.xmlBlaster.util.JAXPFactory.newInstance(String className).

This is caused by Thread.currentThread().getContextClassLoader();
returning null when starting it as NT-Service.

Running in the regular environment works fine.
In both configurations there is no additional class in the CLASSPATH.

See below a work around, how we managed it getting it running.

Any comments or ideas are welcome.
We can provide more details if necessary.

   /**
    * Load the given classname from the thread context classloader.
    */
   private static Object newInstance(String className)
      throws InstanceException{
      try {
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         if (classLoader == null) {
            System.err.println("first Null!!!!!!!!!!!!");
            return Class.forName(className).newInstance();
         }
         Class fac = classLoader.loadClass(className);
         if (fac == null) {
            System.err.println("second Null!!!!!!!!!!!!");
         }
         return fac.newInstance();
      } catch (ClassNotFoundException e) {
         throw new InstanceException("Could not find class: "+className,e);
      } catch(Exception e) {
         System.err.println("!!!!!!!!" + e.toString() + "!!!!!!!!");
         throw new InstanceException("Could not load factory: "+className,e);
      }
   }

regards

Heinrich