JAXB issue in JDK 8

北慕城南 提交于 2021-02-20 02:13:52

问题


I am trying to unmarshall XML String payload using JAXB in jdk1.8.0_162, while trying to get JAXBContext.newInstance, I am getting javax.xml.bind.JAXBException - with linked exception:[java.lang.ClassNotFoundException: oracle.xml.jaxb.JaxbContextImpl], any input would be great!

I have tried adding following dependencies in my pom.xml based on different suggestions from various stackoverflow forums, nothing seems to work :

<groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.8</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.0.2</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.2</version>
</dependency>
<dependency> 
    <groupId>javax.activation</groupId> 
    <artifactId>activation</artifactId> 
    <version>1.1.1</version> 
</dependency>

Here is the code snippet : 

String xml = DownloadTDRReport.downloadTDRReport(sdate);
 jc = JAXBContext.newInstance(Report.class);
 StringReader reader = new StringReader(xml);
 Unmarshaller u = jc.createUnmarshaller();
 Report report = (Report)u.unmarshal(reader);

Here is the stack trace :

javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.ClassNotFoundException: oracle.xml.jaxb.JaxbContextImpl]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:226)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:390)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    at edu.nyu.paygate.batch.RemittanceProcessEBC20.startProcess(RemittanceProcessEBC20.java:350)
    at edu.nyu.paygate.batch.RemittanceProcess.startRemittanceProcess(RemittanceProcess.java:141)
    at edu.nyu.paygate.batch.BatchClient.main(BatchClient.java:64)
Caused by: java.lang.ClassNotFoundException: oracle.xml.jaxb.JaxbContextImpl
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:579)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:224)

来源:https://stackoverflow.com/questions/56297220/jaxb-issue-in-jdk-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!