For Programmers: Free Programming Magazines  


Home > Archive > Java Help > June 2007 > Problem with xjc utility (JAXB)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem with xjc utility (JAXB)
Alejandro

2007-06-08, 8:08 am

I'm trying to generate Java classes from a XML Schema using the xjc
utility, but i get :

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 $Proxy0.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
$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(BeanGenerator.java:
281)
at
com.sun.tools.xjc.generator.bean.BeanGenerator.getUsedPackages(BeanGenerator.java:
337)
at
com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:
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)



I'm using Windows XP version 2002 service pack 2
Java version 1.6.0_01
Java Web Services Developer Pack 2.0

my environment variables
JAVA_HOME = C:\Program Files\Java\jdk1.6.0_01
JWSDP_HOME = C:\Sun\jwsdp-2.0
PATH = C:\Sun\jwsdp-2.0\jwsdp-shared\bin;C:\Sun\jwsdp-2.0\jaxb\bin



my XML schema:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="flux">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="fichier" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="regleNommage">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="regleDescription" type="xsd:string"/>
<xsd:element name="regleDetails" type="xsd:string"
minOccurs="0"/>
<xsd:element name="regexIdentification" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="repertoireCible" minOccurs="1" maxOccurs="2">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="cheminEnvironemment" type="xsd:string"/>
<xsd:element name="cheminFixe" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="applicationCible" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="mcf1|mcf2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="traitement" minOccurs="0" maxOccurs="2">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="commandeInvocation" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="applicationCible" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="mcf1|mcf2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="sens" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="acquisition|restitution|technique"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="canal" type="xsd:string" use="required"/>
<xsd:attribute name="format" type="xsd:string" use="required"/>
<xsd:attribute name="nature" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>


what's wrong? Any ideas?

Thanks

checkmessage@gmail.com

2007-06-16, 7:09 pm

On Jun 8, 8:51 am, Alejandro <altud...@gmail.com> wrote:
> I'm trying to generate Java classes from a XML Schema using the xjc
> utility, but i get :
>
> 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.j=

av=ADa:
> 187)
> at
> com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.java:
> 101)
> at $Proxy0.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(BeanGener=

at=ADor.java:
> 371)
> at
> com.sun.tools.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator.jav=

a:
> 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(BeanGenerator=

..j=ADava:
> 281)
> at
> com.sun.tools.xjc.generator.bean.BeanGenerator.getUsedPackages(BeanGenera=

to=ADr.java:
> 337)
> at
> com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:
> 169)
> at
> com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.jav=

a:
> 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)
>
> I'm using Windows XP version 2002 service pack 2
> Java version 1.6.0_01
> Java Web Services Developer Pack 2.0
>
> my environment variables
> JAVA_HOME =3D C:\Program Files\Java\jdk1.6.0_01
> JWSDP_HOME =3D C:\Sun\jwsdp-2.0
> PATH =3D C:\Sun\jwsdp-2.0\jwsdp-shared\bin;C:\Sun\jwsdp-2.0\jaxb\bin
>
> my XML schema:
>
> <?xml version=3D"1.0"?>
> <xsd:schema xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema">
> <xsd:element name=3D"flux">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name=3D"fichier" maxOccurs=3D"unboun=

ded">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name=3D"regl=

eNommage">
> <xsd:complexType>
> <xsd:sequ=

ence>
> <=

xsd:element name=3D"regleDescription" type=3D"xsd:string"/>
> <=

xsd:element name=3D"regleDetails" type=3D"xsd:string"
> minOccurs=3D"0"/>
> <=

xsd:element name=3D"regexIdentification" type=3D"xsd:string"/>
> </xsd:seq=

uence>
> </xsd:complexType>
> </xsd:element>
> <xsd:element name=3D"repe=

rtoireCible" minOccurs=3D"1" maxOccurs=3D"2">
> <xsd:complexType>
> <xsd:sequ=

ence>
> <=

xsd:element name=3D"cheminEnvironemment" type=3D"xsd:string"/>
> <=

xsd:element name=3D"cheminFixe" type=3D"xsd:string"/>
> </xsd:seq=

uence>
> <xsd:attr=

ibute name=3D"applicationCible" use=3D"required">
> <=

xsd:simpleType>
> =

<xsd:restriction base=3D"xsd:string">
> =

<xsd:pattern value=3D"mcf1|mcf2"/>
> =

</xsd:restriction>
> <=

/xsd:simpleType>
> </xsd:att=

ribute>
> </xsd:complexType>
> </xsd:element>
> <xsd:element name=3D"trai=

tement" minOccurs=3D"0" maxOccurs=3D"2">
> <xsd:complexType>
> <xsd:sequ=

ence>
> <=

xsd:element name=3D"commandeInvocation" type=3D"xsd:string"/>
> </xsd:seq=

uence>
> <xsd:attr=

ibute name=3D"applicationCible" use=3D"required">
> <=

xsd:simpleType>
> =

<xsd:restriction base=3D"xsd:string">
> =

<xsd:pattern value=3D"mcf1|mcf2"/>
> =

</xsd:restriction>
> <=

/xsd:simpleType>
> </xsd:att=

ribute>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> <xsd:attribute name=3D"sens" use=

=3D"required">
> <xsd:simpleType>
> <xsd:restriction =

base=3D"xsd:string">
> <xsd:patt=

ern value=3D"acquisition|restitution|technique"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name=3D"canal" typ=

e=3D"xsd:string" use=3D"required"/>
> <xsd:attribute name=3D"format" ty=

pe=3D"xsd:string" use=3D"required"/>
> <xsd:attribute name=3D"nature" ty=

pe=3D"xsd:string"/>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> what's wrong? Any ideas?
>
> Thanks


probably you found the answer by now. Anyhow this seems to be the
problem with windows using JRE 1.6. Change the PATH to use JRE 1.5

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com