aspose file tools*
The moose likes XML and Related Technologies and the fly likes JAXB doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB doubt" Watch "JAXB doubt" New topic
Author

JAXB doubt

nitinram agarwal
Ranch Hand

Joined: Jan 29, 2009
Posts: 83
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

Joined: Oct 13, 2005
Posts: 36578
    
  16
Question too difficult for"beginning Java". Moving thread.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

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

Joined: Jan 29, 2009
Posts: 83
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
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

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

Joined: Jan 29, 2009
Posts: 83
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
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Good. So your problem is solved then?
nitinram agarwal
Ranch Hand

Joined: Jan 29, 2009
Posts: 83
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
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB doubt
 
Similar Threads
JAXB Binding problem
jaxb - getting InvocationTargetException during parsing
Schema not works with xjc and java lang reflect Invocation Target Exception error
jaxb-xjc
unmarshal-read with JAXB 2.0 and jwsdp 2.0