I\'ve got a problem running a batch job on my server, whereas it runs fine from Eclipse on my development workstation.
I\'ve got my Spring environment set up using R
In Eclipse:
If you are using the spring jars
as user library(Say SpringLib), see if the user library for spring is added(or checked)
as System Library(added to the boot class path). If yes, remove
the check mark.`
The cause of problem is -Djava.endorsed.dirs=$PROJECTHOME/target/lib
org.springframework.beans.factory.support.DefaultListableBeanFactory
contains the following code:
static {
ClassLoader cl = DefaultListableBeanFactory.class.getClassLoader();
try {
javaxInjectProviderClass = cl.loadClass("javax.inject.Provider"); //Line 103
}
catch (ClassNotFoundException ex) {
// JSR-330 API not available - Provider interface simply not supported then.
}
}
It causes a NullPointerException
, because getClassLoader()
returns null
when class is loaded via -Djava.endorsed.dirs
. From javadoc:
Some implementations may use null to represent the bootstrap class loader.
So, use -classpath
(with explicit specification of all jars) instead of -Djava.endorsed.dirs
Just add the jars to referenced libraries and not to user library. It worked for me!
Exception in thread "main" java.lang.ExceptionInInitializerError is occurs while adding User Library. I faced same problem in Hibernate and Spring as well. So i removed User Library say "Spring" then i add jars manually it work perfectly.