Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java error with JAXB and Java 1.6

Tags:

java

version

jaxb

I'm trying to start the Octopus Arm Benchmark (a reinforcement learning benchmark). I downloaded the octopus-code-distribution.zip and started the octopus-environment.jar with

java -jar octopus-environment.jar internal settings.xml

and I got the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.bind.annotation.XmlAccessorType.value()Ljavax/xml/bind/annotation/AccessType;
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getAccessType(ClassInfoImpl.java:339)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getProperties(ClassInfoImpl.java:228)
at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getProperties(RuntimeClassInfoImpl.java:87)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:127)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:204)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:327)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:198)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at Main.main(Main.java:41)

I already googled the error message and it seems to be a problem with my Java version. I'm using Java 1.6, which somehow causes conflicts with the JAXB library. I think it would work with Java 1.5. But I didn't figure out any workaround yet.

I hope you can help me here. Some background information: I'm using Ubuntu 11.04 and my Java version is 1.6.0_26.

like image 215
alfa Avatar asked Jan 15 '12 22:01

alfa


1 Answers

In JAXB 2.0, AccessType is renamed to XmlAccessType (AccessorType is also renamed to XmlAccessorType). Thus, users of early snapshots of JAXB are exposed to this problem. So you have two options:

  1. Update the source code so you can use JAXB shipped with Java 6.

  2. Override the JAXB implementation with the one used in your environment. The MANIFEST file of the file octopus-environment.jar shows the files needed are stored under /lib folder, so you can run

java -Djava.endorsed.dirs=./lib -jar octopus-environment.jar internal settings.xml

This leverages the Java Endorsed Standards Override Mechanism so you can override the default JAXB shipped in Java 6.

like image 117
jalopaba Avatar answered Sep 23 '22 06:09

jalopaba