2 zshcomeon zshcomeon 于 2016.09.07 16:43 提问

创建JAXBContext.newInstance报NullPointerException

Jdk 1.6.0 跑的一个多线程本地应用服务,基于AIX平台,运行好几年了, 今年(2016)报错2次创建对象失败的问题。
项目的基本情况是使用jaxb解析和组装xml格式的报文,每个线程每次独立完成一个报文的解析或组装,发生问题的过程是在组装过程,2次出错都是组装同一类报文。
以下是错误日志,跟了整个过程的源代码,没有发现可疑点,放出来碰碰运行,是否有遇到类似问题的朋友:
Caused by: java.lang.NullPointerException
at com.ibm.oti.reflect.Field.getAnnotation(Field.java:21)
at java.lang.reflect.Field.getAnnotation(Field.java:1034)
at com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getFieldAnnotation(RuntimeInlineAnnotationReader.java:21)
at com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getFieldAnnotation(RuntimeInlineAnnotationReader.java:17)
at com.sun.xml.bind.v2.model.impl.EnumLeafInfoImpl.calcConstants(EnumLeafInfoImpl.java:88)
at com.sun.xml.bind.v2.model.impl.EnumLeafInfoImpl.getConstants(EnumLeafInfoImpl.java:140)
at com.sun.xml.bind.v2.model.impl.EnumLeafInfoImpl.link(EnumLeafInfoImpl.java:146)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.link(ModelBuilder.java:273)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.link(RuntimeModelBuilder.java:83)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:354)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:350)
at java.security.AccessController.doPrivileged(AccessController.java:228)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:349)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:215)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:213)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:374)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:585)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:533)
at com.cnapsms.process.proc.util.JaxbBinder.(Unknown Source)

1个回答

zshcomeon
zshcomeon   2016.09.07 16:43

调用的代码, 传入的参数都是自动生成的类
public JaxbBinder(Class<?>... types) {
try {
jaxbContext = JAXBContext.newInstance(types);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}

Csdn user default icon
上传中...
上传图片
插入图片