NullPointerException occuring when creating new instance for JAXBContext
I got Null pointer exception when creating the instance of JAXBContext for unmarshalling. The below line is inside a function, which will be called each time when I upload a XML which needs to be unmarshalled.
JAXBContext jc = JAXBCon开发者_如何学编程text.newInstance("com.foo.bar");
After sometime it is started throwing NullPointerException.The exception itself is not clear. Please let me know if any of you come across this scenario.
Exception trace:
java.lang.NullPointerException
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
I am using JDK 1.6.0_18 version. And for JAXB also I am using the JDK which has JAXB in it.
Regards, Sakthi. S
Seems like the package "com.foo.bar" is not accessible. Have you tried something like:
JAXBContext jc = JAXBCOntext.newInstance(MyClass.class);
If this compiles, you know you have it in your classpath.
精彩评论