开发者

NullPointerException occuring when creating new instance for JAXBContext

开发者 https://www.devze.com 2023-04-02 16:25 出处:网络
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 unma

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号