Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB doubt

 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was going through the Sun article on JAXB. after downloading the required packages and sample codes, I tried to compile one example but getting the following error. can someone please advice what is wrong ?

C:\Sun\jwsdp-2.0\jaxb\samples\unmarshal-read>C:\Sun\jwsdp-2.0\jaxb\bin\xjc po.xs
d
parsing a schema...
compiling a schema...
Exception in thread "main" java.lang.IllegalArgumentException: Expected class ja
vax.xml.bind.annotation.XmlAccessType but found class javax.xml.bind.annotation.
AccessType
at com.sun.codemodel.TypedAnnotationWriter.checkType(TypedAnnotationWrit
er.java:187)
at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.
java:101)
at $Proxy0.value(Unknown Source)
at com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1.createClasse
s(ImplStructureStrategy.java:46)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassDef(BeanG
enerator.java:371)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator
.java:403)
at com.sun.tools.xjc.generator.bean.BeanGenerator$1.onBean(BeanGenerator
.java:291)
at com.sun.tools.xjc.generator.bean.BeanGenerator$1.onBean(BeanGenerator
.java:299)
at com.sun.tools.xjc.model.CClassInfo.accept(CClassInfo.java:359)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getContainer(BeanGener
ator.java:281)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getUsedPackages(BeanGe
nerator.java:337)
at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.j
ava:169)
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)
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question too difficult for"beginning Java". Moving thread.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The contents of that error message suggest that the class in question is in your classpath twice. Perhaps you're using Java 6 (where it is a built-in class) but you were reading an old tutorial which told you to download a jar file which contained it. If that's the case, take that jar file out of your classpath, you aren't going to need it.
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if there is any classpath setting. would you mind elaborating a bit more as I am totally new to JAXB..


C:\Sun\jwsdp-2.0\jaxb\samples\unmarshal-read>echo %CLASSPATH%
%CLASSPATH%

C:\Sun\jwsdp-2.0\jaxb\samples\unmarshal-read>C:\Sun\jwsdp-2.0\jaxb\bin\xjc po.xs
d
parsing a schema...
compiling a schema...
Exception in thread "main" java.lang.IllegalArgumentException: Expected class ja
vax.xml.bind.annotation.XmlAccessType but found class javax.xml.bind.annotation.
AccessType
at com.sun.codemodel.TypedAnnotationWriter.checkType(TypedAnnotationWrit
er.java:187)
at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.
java:101)
at $Proxy0.value(Unknown Source)
at com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1.createClasse
s(ImplStructureStrategy.java:46)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassDef(BeanG
enerator.java:371)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator
.java:403)
at com.sun.tools.xjc.generator.bean.BeanGenerator$1.onBean(BeanGenerator
.java:291)
at com.sun.tools.xjc.generator.bean.BeanGenerator$1.onBean(BeanGenerator
.java:299)
at com.sun.tools.xjc.model.CClassInfo.accept(CClassInfo.java:359)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getContainer(BeanGener
ator.java:281)
at com.sun.tools.xjc.generator.bean.BeanGenerator.getUsedPackages(BeanGe
nerator.java:337)
at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.j
ava:169)
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)

C:\Sun\jwsdp-2.0\jaxb\samples\unmarshal-read>
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't know how to set your classpath than you shouldn't really be messing about with advanced topics like JAXB. So go back and learn about the classpath. Don't run before you can crawl.
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand class path and other things pretty well. I was wondering whether any classpath is causing this issue. so I set it to null and then tried to compile the code again to see if I am getting the same error message or something different.
As I have got the same error message, I reposted the details. reason being that I am new to JAXB which I have posted earlier as well.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good. So your problem is solved then?
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not yet . I am planning to google more on this or check with some friends/colleagues or forum if I don't get succeed.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. I assumed that since you didn't respond to my earlier suggestion
Perhaps you're using Java 6 (where it is a built-in class) but you were reading an old tutorial which told you to download a jar file which contained it.

that you must have solved the problem already.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic