我试图在jdk1.8.0_162中使用JAXB解组XML字符串有效负载,同时尝试获取JAXBContext.newInstance,同时我正在获取javax.xml.bind.JAXBException-具有链接的异常:[java.lang.ClassNotFoundException:oracle .xml.jaxb.JaxbContextImpl],任何输入都很棒!
我曾尝试根据各种stackoverflow论坛的不同建议在pom.xml中添加以下依赖项,但似乎没有任何效果:
<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)