在使用jaxb时,报如下错误:
parsing a schema...
compiling a schema...
Exception in thread "main" java.lang.IllegalArgumentException: Expected class javax.xml.bind.annotation.XmlAccessType but found class javax.xml.bind.annotation.AccessType
at com.sun.codemodel.TypedAnnotationWriter.checkType(TypedAnnotationWriter.java:187)
at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.java:101)
at $Proxy21.value(Unknown Source)
at com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1.createClasses(ImplStructureStrategy.java:46)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassDef(BeanGenerator.java:371)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator.java:403)
at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:178)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:151)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:228)
at com.sun.tools.xjc.Driver.run(Driver.java:293)
at com.sun.tools.xjc.Driver.run(Driver.java:170)
at com.sun.tools.xjc.Driver._main(Driver.java:95)
at com.sun.tools.xjc.Driver.access$000(Driver.java:53)
at com.sun.tools.xjc.Driver$1.run(Driver.java:75)
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
百度了很多也没找到原因,后来在google中查到了原因:
原来是下载的jaxb包本身有问题。该包中的jaxb是有问题的,之后下载了更高版本的jaxb后就搞定了。
参考网址:
说明一下:
1.Sun被Oracle收购后,链接的网址很多都不能打开或已经变换了位置了,可以找到主页之后往下找
2.google在查询英文方面的确牛叉很多,不过,现在的google动不动就被封了。
3.查询时由于有字数限制,可以搜索:but found class javax.xml.bind.annotation.AccessType
parsing a schema...
compiling a schema...
Exception in thread "main" java.lang.IllegalArgumentException: Expected class javax.xml.bind.annotation.XmlAccessType but found class javax.xml.bind.annotation.AccessType
at com.sun.codemodel.TypedAnnotationWriter.checkType(TypedAnnotationWriter.java:187)
at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.java:101)
at $Proxy21.value(Unknown Source)
at com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1.createClasses(ImplStructureStrategy.java:46)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassDef(BeanGenerator.java:371)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator.java:403)
at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:178)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:151)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:228)
at com.sun.tools.xjc.Driver.run(Driver.java:293)
at com.sun.tools.xjc.Driver.run(Driver.java:170)
at com.sun.tools.xjc.Driver._main(Driver.java:95)
at com.sun.tools.xjc.Driver.access$000(Driver.java:53)
at com.sun.tools.xjc.Driver$1.run(Driver.java:75)
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
百度了很多也没找到原因,后来在google中查到了原因:
原来是下载的jaxb包本身有问题。该包中的jaxb是有问题的,之后下载了更高版本的jaxb后就搞定了。
参考网址:
说明一下:
1.Sun被Oracle收购后,链接的网址很多都不能打开或已经变换了位置了,可以找到主页之后往下找
2.google在查询英文方面的确牛叉很多,不过,现在的google动不动就被封了。
3.查询时由于有字数限制,可以搜索:but found class javax.xml.bind.annotation.AccessType