You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Monica Ferrero <mf...@accelrys.com> on 2008/01/04 19:29:25 UTC

WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'


Hi!

I'm getting this error:

WSDLToJava Error : Thrown by JAXB : undefined element declaration
'ns1:orderBy'

when trying to generate java stubs from the wsdl.


This is my original service:

@WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
public interface MyService {

    [...]

    @WebResult(name="MyList")
    @WebMethod
    MyList getItems( @WebParam(name="listId") int listId);

    [...]
}


the MyList class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"items"})
@XmlRootElement(name = "myList")
public class MyList {

    @XmlElement(required = true)
    private List<Item> items;

    public List<Item> getItems() {
        if (items == null) {
            items = new ArrayList<Item>();
        }
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }
}


The Item is a JAXB generated file from a schema:


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "attributesPD",
    "orderBy"
})
@XmlRootElement(name = "item")
public class Item {

    @XmlElement(name = "attributes", required = true)
    protected AttributesPD attributesPD;
    protected Item.OrderBy orderBy;
    @XmlAttribute
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "token")
    protected String id;
    @XmlAttribute
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "token")
    protected String createdBy;
    @XmlAttribute
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar creationDate;

    public AttributesPD getAttributesPD() {
        return attributesPD;
    }

    public void setAttributesPD(AttributesPD value) {
        this.attributesPD = value;
    }

    public Item.OrderBy getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(Item.OrderBy value) {
        this.orderBy = value;
    }

    public String getId() {
        return id;
    }

    public void setId(String value) {
        this.id = value;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String value) {
        this.createdBy = value;
    }

    public XMLGregorianCalendar getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(XMLGregorianCalendar value) {
        this.creationDate = value;
    }


    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "orderedAttributeRef"
    })
    public static class OrderBy {

        @XmlElement(required = true)
        protected List<OrderedAttributeRefType> orderedAttributeRef;

        public List<OrderedAttributeRefType> getOrderedAttributeRef() {
            if (orderedAttributeRef == null) {
                orderedAttributeRef = new
ArrayList<OrderedAttributeRefType>();
            }
            return this.orderedAttributeRef;
        }
    }
}



The wsdl generated by cxf:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://myservice.bbb.aaa.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MyServiceImplService"
targetNamespace="http://myservice.bbb.aaa.com/">
      <wsdl:types>
            <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.aaa.com/AaaOtherService"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://www.aaa.com/AaaOtherService">
[...]
                  <xs:element name="item">
                        <xs:complexType>
                              <xs:sequence>
                                    <xs:element ref="tns:attributes"/>
                                    <xs:element minOccurs="0"
name="orderBy">
                                          <xs:complexType>
                                                <xs:sequence>
                                                      <xs:element
maxOccurs="unbounded" name="orderedAttributeRef"
type="tns:orderedAttributeRefType"/>
                                                </xs:sequence>
                                          </xs:complexType>
                                    </xs:element>
                              </xs:sequence>
                              <xs:attribute name="id" type="xs:token"/>
                              <xs:attribute name="createdBy"
type="xs:token"/>
                              <xs:attribute name="creationDate"
type="xs:date"/>
                        </xs:complexType>
                  </xs:element>
[...]
            </xs:schema>
            <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://myservice.bbb.aaa.com/"
xmlns:ns1="http://www.aaa.com/AaaOtherService"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://myservice.bbb.aaa.com/">
                  <xs:import
namespace="http://www.aaa.com/AaaOtherService"/>
                  <xs:element name="myList">
                        <xs:complexType>
                              <xs:sequence>
                                    <xs:element maxOccurs="unbounded"
name="items">
                                          <xs:complexType>
                                                <xs:sequence>
                                                      <xs:element
ref="ns1:attributes"/>
                                                      <xs:element
minOccurs="0" ref="ns1:orderBy"/>
                                                </xs:sequence>
                                                <xs:attribute name="id"
type="xs:token"/>
                                                <xs:attribute
name="createdBy" type="xs:token"/>
                                                <xs:attribute
name="creationDate" type="xs:date"/>
                                          </xs:complexType>
                                    </xs:element>
                              </xs:sequence>
                        </xs:complexType>
                  </xs:element>
[...]
                  <xs:element name="getItemsResponse"
type="getItemsResponse"/>
                  <xs:complexType name="getItemsResponse">
                        <xs:sequence>
                              <xs:element minOccurs="0" ref="myList"/>
                        </xs:sequence>
                  </xs:complexType>
[...]
            </xs:schema>
      </wsdl:types>
[...]
</wsdl:definitions>



I think it's a bit weird that it defines myList as a sequence of the
elements that form an Item, instead of a sequence of items.
Anyway I'm not sure why it does not work if it is mostly all generated
code.
Any ideas?

Help or pointers very much appreciated!


MonicaAccelrys Limited (http://www.accelrys.com) 
Registered office: 334 Cambridge Science Park, Cambridge, CB4 0WN, UK 
Registered in England: 2326316   

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Monica Ferrero <mf...@accelrys.com>.
Hi!

Can someone please help and give me some indication of what is wrong with
this?
Thanks a lot,

Monica


                                                                                                                              
  From:       "Monica Ferrero" <mf...@accelrys.com>                                                                        
                                                                                                                              
  To:         cxf-user@incubator.apache.org                                                                                   
                                                                                                                              
  Date:       09/01/2008 16:07                                                                                                
                                                                                                                              
  Subject:    Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'                             
                                                                                                                              





Hi Jim!


The wsdl gets generated by cxf from the Java SEI, ie is the wsdl coming
from the URL:

http://localhost:8080/myContext/ws/MyService?wsdl


So either the java2wsdl does not work properly in this case or more likely
there is something wrong in my SEI :)


I guess the wsdl in the http://localhost:8080/myContext/ws/MyService?wsdl
URL is generated with the java2wsdl tool, so I've tried to replicate its
behaviour:

java2wsdl -verbose -o j2wps.wsdl -cp pathToMySercice;pathToZZZ
com.aaa.bbb.myservice.MyService

It complained about the endpointInterface in the WebService annotation (
@WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")) so I've taken
it out.


In the output from this command, I can see the classes known to this
context and OrderBy is there just fine.

FINE: Created JAXBContext
"jar:file:/C:/[snip]/apache-cxf-2.0.3-incubator/lib/jaxb-impl-2.0.5.jar!/com/sun/xml/bind/v2/runtime/JAXBContextImpl.class
 Build-Id: 2.0.5
Classes known to this context:
[B
boolean
byte
char
[snip]
com.aaa.bbb.zzz..jaxb.OrderBy
com.aaa.bbb.zzz.jaxb.Item
[snip]
short
void
" with classes [ [snip] class com.aaa.bbb.zzz.jaxb.OrderBy, class
com.aaa.bbb.zzz.jaxb.Item, class com.aaa.bbb.ccc.MyList].


I've compared the wsdl generated through the URL and by java2wsdl and I
think they are practically the same, apart of some minor changes in order.
And if I tried to use the wsdl from java2wsdl to be the source for the
wsdl2java and I get the same error

WSDLToJava Error : Thrown by JAXB : undefined element declaration
'ns1:orderBy'


I include again the SEI if it's helpful to see anything that can be wrong
with it:

@WebService
public interface MyService {

    [...]

    @WebResult(name="MyList")
    @WebMethod
    MyList getItems( @WebParam(name="listId") int listId);

    [...]
}


the MyList class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"items"})
@XmlRootElement(name = "myList")
public class MyList {

     @XmlElement(required = true)
    private List<Item> items;

   public List<Item> getItems() {
       if (items == null) {
           items = new ArrayList<Item>();
       }
       return items;
   }

   public void setItems(List<Item> items) {
       this.items = items;
   }
}


The Item, JAXB generated from a schema, now modified to have OrderBy in a
different class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"attributesPD",
"orderBy"
})
@XmlRootElement(name = "item")
public class Item {

@XmlElement(name = "attributes", required = true)
protected AttributesPD attributesPD;
protected OrderBy orderBy;
@XmlAttribute
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "token")
protected String id;
@XmlAttribute
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "token")
protected String createdBy;
@XmlAttribute
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar creationDate;

public AttributesPD getAttributesPD() {
return attributesPD;
}

public void setAttributesPD(AttributesPD value) {
this.attributesPD = value;
}

public OrderBy getOrderBy() {
return orderBy;
}

public void setOrderBy(OrderBy value) {
this.orderBy = value;
}

public String getId() {
return id;
}

public void setId(String value) {
this.id = value;
}

public String getCreatedBy() {
return createdBy;
}

public void setCreatedBy(String value) {
this.createdBy = value;
}

public XMLGregorianCalendar getCreationDate() {
return creationDate;
}

public void setCreationDate(XMLGregorianCalendar value) {
this.creationDate = value;
}


OrderBy class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"orderedAttributeRef"
})
public class OrderBy {

@XmlElement(required = true)
protected List<OrderedAttributeRefType> orderedAttributeRef;

public List<OrderedAttributeRefType> getOrderedAttributeRef() {
if (orderedAttributeRef == null) {
orderedAttributeRef = new ArrayList<OrderedAttributeRefType>();
}
return this.orderedAttributeRef;
}

}

Thanks a mill for all the help,


Monica


Inactive hide details for Jim Ma ---09/01/2008 13:40:14---Hi Monica,Jim Ma
---09/01/2008 13:40:14---Hi Monica,
                                                                           
                                                                           
 From:        Jim Ma <em...@iona.com>                                        
                                                                           
                                                                           
 To:          cxf-user@incubator.apache.org                                
                                                                           
                                                                           
 Date:        09/01/2008 13:40                                             
                                                                           
                                                                           
 Subject:     Re: WSDLToJava Error : Thrown by JAXB : undefined element    
              declaration 'ns1:orderBy'                                    
                                                                           





Hi Monica,

How did you get this wsdl ? Is this wsdl  generated with CXF java to
wsdl tool  ?
Since the generated wsdl is an invalid wsdl , cxf wsdl to java tool  is
failed to generate code for it.
I think the problem is in wsdl generation, so we need to know if the
right classes is loaded in
jaxb context during java to wsdl execution.

Regards
Jim





Monica Ferrero wrote:
>
> Hi Jim,
>
> I'm not sure I follow you. I can't see any wsdl to java log...
> The logging.properties in ${CXF_HOME}/etc/logging.properties indicate
> the output is taking to the console. Even if I activate the file
> appender there is no information about the 'Classes known to this
> context' there.
> If I run the wsdl to java in verbose mode, I get a bit more
> information (see below), but no what we are looking for...
>
> Thanks,
>
> Monica
>
>
> [exec] Loading FrontEnd jaxws ...
> [exec] Loading DataBinding jaxb ...
> [exec] <command xmlns="http://cxf.apache.org/Xutil/Command"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http:/
> /cxf.apache.org/Xutil/Command
> http://cxf.apache.org/schema/xutil/command.xsd">
> [exec] <option name="verbose"/>
> [exec] <option name="packagename">com.aaa.bbb.myservice</option>
> [exec] <option name="binding">bindingsPD.xjb</option>
> [exec] <argument name="wsdlurl">MyService.wsdl</argument>
> [exec] </command>
> [exec] wsdl2java -verbose -p com.aaa.bbb.myservice -b bindingsPD.xjb
> MyService.wsdl
> [exec] wsdl2java - Apache CXF (incubator) 2.0.3-incubator
> [exec]
> [exec]
> [exec] WSDLToJava Error : Thrown by JAXB : undefined element
> declaration 'ns1:orderBy'
> [exec]
> [exec] org.apache.cxf.tools.common.ToolException: Thrown by JAXB :
> undefined element declaration 'ns1:orderBy'
> [exec] at
>
org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBBindErrorListener.error(JAXBBindErrorListener.java:34)

> [exec] at
>
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.error(SchemaCompilerImpl.java:245)

> [exec] at
>
com.sun.tools.xjc.util.ErrorReceiverFilter.error(ErrorReceiverFilter.java:61)

> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext$2.error(ParserContext.java:188)
> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:166)

> [exec] at
>
com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:103)

> [exec] at
> com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:91)
> [exec] at com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:66)
> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:126)

> [exec] at
> com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:172)
> [exec] at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:488)
> [exec] at
>
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:197)

> [exec] at
>
org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:209)

> [exec] at
>
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:504)

> [exec] at
>
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:183)

> [exec] at
>
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:229)

> [exec] at
>
org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:83)
> [exec] at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:102)
> [exec] at
org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> [exec] Caused by: org.xml.sax.SAXParseException: undefined element
> declaration 'ns1:orderBy'
> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:162)

> [exec] ... 14 more
>
> Inactive hide details for Jim Ma ---09/01/2008 02:18:56---Hi
> Monica,Jim Ma ---09/01/2008 02:18:56---Hi Monica,
>
>
> From:
> Jim Ma <em...@iona.com>
>
> To:
> cxf-user@incubator.apache.org
>
> Date:
> 09/01/2008 02:18
>
> Subject:
> Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> 'ns1:orderBy'
>
> ------------------------------------------------------------------------
>
>
>
> Hi Monica,
>
> Forget to mention .  Search it in  java to wsdl 's log .
>
> Regards
>
> Jim
>
> Monica Ferrero wrote:
> >
> > Hi Jim,
> >
> > Changed the logging level to FINE as you indicated and run the wsdl to
> > java on my wsdl, but there is no such a message in there as "Classes
> > known to this context:". I've search for "classes" and " context" as
> > well and there is nothing on those lines.
> > There are some exceptions that I'm not sure there are relevant. I add
> > here the last one before the error.
> >
> > Thanks for your help,
> >
> > Monica
> >
> >
> > [exec] 08-Jan-2008 10:19:57
> > com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory get
> > [exec] FINE: Using optimized Accessor for
> >
>
com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding

>
> > com.sun.tools.xjc.re
> > ader.xmlschema.bindinfo.BIGlobalBinding.getUnderscoreBinding() and
> > void
> >
> com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.setUnderscore
> >
>
Binding(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding)

> > [exec] 08-Jan-2008 10:19:57
> > com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
> > [exec] FINE: Unable to inject
> >
>
com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType

> > [exec] java.lang.reflect.InvocationTargetException
> > [exec] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
> > [exec] at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

> > [exec] at java.lang.reflect.Method.invoke(Method.java:597)
> > [exec] at
> >
>
com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:125)
> > [...]
> > [exec] at
> org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> > [exec] Caused by: java.lang.LinkageError: loader (instance of
> > sun/misc/Launcher$AppClassLoader): attempted duplicate class
> > definition for
> > name:
> >
>
"com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType"

> > [exec] at java.lang.ClassLoader.defineClass1(Native Method)
> > [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> > [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
> > [exec] ... 84 more
> >
> > Inactive hide details for Jim Ma ---08/01/2008 02:56:05---Hi
> > Monica,Jim Ma ---08/01/2008 02:56:05---Hi Monica,
> >
> >
> > From:
> > Jim Ma <em...@iona.com>
> >
> > To:
> > cxf-user@incubator.apache.org
> >
> > Date:
> > 08/01/2008 02:56
> >
> > Subject:
> > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > 'ns1:orderBy'
> >
> >
------------------------------------------------------------------------
> >
> >
> >
> > Hi Monica,
> >
> > You can change the log level to FINE (modify the log configuration file
> > under ${CXF_HOME}/etc/logging.properties)
> > to see if the OrderBy classes added to JAXB Context when you run
> > java2wsdl tool .
> >
> > Search "Classes known to this context:" in the log file to see  if this
> > class is known to JAXB.
> >
> > Regards
> >
> > Jim
> >
> >
> > Monica Ferrero wrote:
> > >
> > > Hi Jim,
> > >
> > > Thank you for your reply.
> > >
> > > Item and OrderBy are generated by JAXB from a schema.xsd file.
> > > I have followed your advice to see if it behaves any different but I
> > > still get the same error.
> > >
> > > The Item and therefore OrderBy classes belong to a different JAXB
> > > context: com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?
> > >
> > > Thanks for your help,
> > >
> > > Monica
> > >
> > > Inactive hide details for Jim Ma ---07/01/2008 02:22:26---Hi ,Jim Ma
> > > ---07/01/2008 02:22:26---Hi ,
> > >
> > >
> > > From:
> > > Jim Ma <em...@iona.com>
> > >
> > > To:
> > > cxf-user@incubator.apache.org
> > >
> > > Date:
> > > 07/01/2008 02:22
> > >
> > > Subject:
> > > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > 'ns1:orderBy'
> > >
> > >
> ------------------------------------------------------------------------
> > >
> > >
> > >
> > > Hi ,
> > >
> > > From the error message , I think this is caused by the inner class
> > > OrderBy is not loaded into
> > > JAXB context . Can you modify this class as a outer class and try it
> > > again ?
> > > I will look it further to see if the JAXB can not load the inner
> static
> > > class .
> > >
> > > Thanks
> > >
> > > Jim
> > >
> > >
> > > Monica Ferrero wrote:
> > > > Hi!
> > > >
> > > > I'm getting this error:
> > > >
> > > > WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > > 'ns1:orderBy'
> > > >
> > > > when trying to generate java stubs from the wsdl.
> > > >
> > > >
> > > > This is my original service:
> > > >
> > > > @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> > > > public interface MyService {
> > > >
> > > >     [...]
> > > >
> > > >     @WebResult(name="MyList")
> > > >     @WebMethod
> > > >     MyList getItems( @WebParam(name="listId") int listId);
> > > >
> > > >     [...]
> > > > }
> > > >
> > > >
> > > > the MyList class:
> > > >
> > > > @XmlAccessorType(XmlAccessType.FIELD)
> > > > @XmlType(name = "", propOrder = {"items"})
> > > > @XmlRootElement(name = "myList")
> > > > public class MyList {
> > > >
> > > >     @XmlElement(required = true)
> > > >     private List<Item> items;
> > > >
> > > >     public List<Item> getItems() {
> > > >         if (items == null) {
> > > >             items = new ArrayList<Item>();
> > > >         }
> > > >         return items;
> > > >     }
> > > >
> > > >     public void setItems(List<Item> items) {
> > > >         this.items = items;
> > > >     }
> > > > }
> > > >
> > > >
> > > > The Item is a JAXB generated file from a schema:
> > > >
> > > >
> > > > @XmlAccessorType(XmlAccessType.FIELD)
> > > > @XmlType(name = "", propOrder = {
> > > >     "attributesPD",
> > > >     "orderBy"
> > > > })
> > > > @XmlRootElement(name = "item")
> > > > public class Item {
> > > >
> > > >     @XmlElement(name = "attributes", required = true)
> > > >     protected AttributesPD attributesPD;
> > > >     protected Item.OrderBy orderBy;
> > > >     @XmlAttribute
> > > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > > >     @XmlSchemaType(name = "token")
> > > >     protected String id;
> > > >     @XmlAttribute
> > > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > > >     @XmlSchemaType(name = "token")
> > > >     protected String createdBy;
> > > >     @XmlAttribute
> > > >     @XmlSchemaType(name = "date")
> > > >     protected XMLGregorianCalendar creationDate;
> > > >
> > > >     public AttributesPD getAttributesPD() {
> > > >         return attributesPD;
> > > >     }
> > > >
> > > >     public void setAttributesPD(AttributesPD value) {
> > > >         this.attributesPD = value;
> > > >     }
> > > >
> > > >     public Item.OrderBy getOrderBy() {
> > > >         return orderBy;
> > > >     }
> > > >
> > > >     public void setOrderBy(Item.OrderBy value) {
> > > >         this.orderBy = value;
> > > >     }
> > > >
> > > >     public String getId() {
> > > >         return id;
> > > >     }
> > > >
> > > >     public void setId(String value) {
> > > >         this.id = value;
> > > >     }
> > > >
> > > >     public String getCreatedBy() {
> > > >         return createdBy;
> > > >     }
> > > >
> > > >     public void setCreatedBy(String value) {
> > > >         this.createdBy = value;
> > > >     }
> > > >
> > > >     public XMLGregorianCalendar getCreationDate() {
> > > >         return creationDate;
> > > >     }
> > > >
> > > >     public void setCreationDate(XMLGregorianCalendar value) {
> > > >         this.creationDate = value;
> > > >     }
> > > >
> > > >
> > > >     @XmlAccessorType(XmlAccessType.FIELD)
> > > >     @XmlType(name = "", propOrder = {
> > > >         "orderedAttributeRef"
> > > >     })
> > > >     public static class OrderBy {
> > > >
> > > >         @XmlElement(required = true)
> > > >         protected List<OrderedAttributeRefType>
orderedAttributeRef;
> > > >
> > > >         public List<OrderedAttributeRefType>
> > getOrderedAttributeRef() {
> > > >             if (orderedAttributeRef == null) {
> > > >                 orderedAttributeRef = new
> > > > ArrayList<OrderedAttributeRefType>();
> > > >             }
> > > >             return this.orderedAttributeRef;
> > > >         }
> > > >     }
> > > > }
> > > >
> > > >
> > > >
> > > > The wsdl generated by cxf:
> > > >
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > > > xmlns:tns="http://myservice.bbb.aaa.com/"
> > > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > name="MyServiceImplService"
> > > > targetNamespace="http://myservice.bbb.aaa.com/">
> > > >       <wsdl:types>
> > > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > xmlns:tns="http://www.aaa.com/AaaOtherService"
> > > > attributeFormDefault="unqualified" elementFormDefault="qualified"
> > > > targetNamespace="http://www.aaa.com/AaaOtherService">
> > > > [...]
> > > >                   <xs:element name="item">
> > > >                         <xs:complexType>
> > > >                               <xs:sequence>
> > > >                                     <xs:element
> ref="tns:attributes"/>
> > > >                                     <xs:element minOccurs="0"
> > > > name="orderBy">
> > > >                                           <xs:complexType>
> > > >                                                 <xs:sequence>
> > > >                                                       <xs:element
> > > > maxOccurs="unbounded" name="orderedAttributeRef"
> > > > type="tns:orderedAttributeRefType"/>
> > > >                                                 </xs:sequence>
> > > >                                           </xs:complexType>
> > > >                                     </xs:element>
> > > >                               </xs:sequence>
> > > >                               <xs:attribute name="id"
> > type="xs:token"/>
> > > >                               <xs:attribute name="createdBy"
> > > > type="xs:token"/>
> > > >                               <xs:attribute name="creationDate"
> > > > type="xs:date"/>
> > > >                         </xs:complexType>
> > > >                   </xs:element>
> > > > [...]
> > > >             </xs:schema>
> > > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > xmlns="http://myservice.bbb.aaa.com/"
> > > > xmlns:ns1="http://www.aaa.com/AaaOtherService"
> > > > attributeFormDefault="unqualified" elementFormDefault="unqualified"
> > > > targetNamespace="http://myservice.bbb.aaa.com/">
> > > >                   <xs:import
> > > > namespace="http://www.aaa.com/AaaOtherService"/>
> > > >                   <xs:element name="myList">
> > > >                         <xs:complexType>
> > > >                               <xs:sequence>
> > > >                                     <xs:element
> maxOccurs="unbounded"
> > > > name="items">
> > > >                                           <xs:complexType>
> > > >                     &nbs p;                           <xs:sequence>
> > > >                                                       <xs:element
> > > > ref="ns1:attributes"/>
> > > >                                                       <xs:element
> > > > minOccurs="0" ref="ns1:orderBy"/>
> > > >                                                 </xs:sequence>
> > > >                                                 <xs:attribute
> > name="id"
> > > > type="xs:token"/>
> > > >                                                 <xs:attribute
> > > > name="createdBy" type="xs:token"/>
> > > >                                                 <xs:attribute
> > > > name="creationDate" type="xs:date"/>
> > > >                                           </xs:complexType>
> > > >                                     </xs:element>
> > > >                               </xs:sequence>
> > > >                         </xs:complexType>
> > > >                   </xs:element>
> > > > [...]
> > > >                   <xs:element name="getItemsResponse"
> > > > type="getItemsResponse"/>
> > > >                   <xs:complexType name="getItemsResponse">
> > > >                         <xs:sequence>
> > > >                               <xs:element minOccurs="0"
> ref="myList"/>
> > > >                         </xs:sequence>
> > > >                   </xs:complexType>
> > > > [...]
> > > >             </xs:schema>
> > > >       </wsdl:types>
> > > > [...]
> > > > </wsdl:definitions>
> > > >
> > > >
> > > >
> > > > I think it's a bit weird that it defines myList as a sequence of
the
> > > > elements that form an Item, instead of a sequence of items.
> > > > Anyway I'm not sure why it does not work if it is mostly all
> generated
> > > > code.
> > > > Any ideas?
> > > >
> > > > Help or pointers very much appreciated!
> > > >
> > > >
> > > > Monica


Accelrys Limited (http://www.accelrys.com) 
Registered office: 334 Cambridge Science Park, Cambridge, CB4 0WN, UK 
Registered in England: 2326316   

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Monica Ferrero <mf...@accelrys.com>.
Hi Jim!


The wsdl gets generated by cxf from the Java SEI, ie is the wsdl coming
from the URL:

http://localhost:8080/myContext/ws/MyService?wsdl


So either the java2wsdl does not work properly in this case or more likely
there is something wrong in my SEI :)


I guess the wsdl in the http://localhost:8080/myContext/ws/MyService?wsdl
URL is generated with the java2wsdl tool, so I've tried to replicate its
behaviour:

java2wsdl  -verbose -o j2wps.wsdl -cp pathToMySercice;pathToZZZ
com.aaa.bbb.myservice.MyService

It complained about the endpointInterface in the WebService annotation (
@WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")) so I've taken
it out.


In the output from this command, I can see the classes known to this
context and OrderBy is there just fine.

FINE: Created JAXBContext
"jar:file:/C:/[snip]/apache-cxf-2.0.3-incubator/lib/jaxb-impl-2.0.5.jar!/com/sun/xml/bind/v2/runtime/JAXBContextImpl.class
 Build-Id: 2.0.5
Classes known to this context:
  [B
  boolean
  byte
  char
[snip]
  com.aaa.bbb.zzz..jaxb.OrderBy
  com.aaa.bbb.zzz.jaxb.Item
[snip]
  short
  void
" with classes [ [snip] class com.aaa.bbb.zzz.jaxb.OrderBy, class
com.aaa.bbb.zzz.jaxb.Item, class com.aaa.bbb.ccc.MyList].


I've compared the wsdl generated through the URL and by java2wsdl and I
think they are practically the same, apart of some minor changes in order.
And if I tried to use the wsdl from java2wsdl to be the source for the
wsdl2java and I get the same error

WSDLToJava Error : Thrown by JAXB : undefined element declaration
'ns1:orderBy'


I include again the SEI if it's helpful to see anything that can be wrong
with it:

@WebService
public interface MyService {

     [...]

     @WebResult(name="MyList")
     @WebMethod
     MyList getItems( @WebParam(name="listId") int listId);

     [...]
 }


the MyList class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"items"})
@XmlRootElement(name = "myList")
public class MyList {

     @XmlElement(required = true)
     private List<Item> items;

    public List<Item> getItems() {
        if (items == null) {
            items = new ArrayList<Item>();
        }
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }
}


The Item, JAXB generated from a schema, now modified to have OrderBy in a
different class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "attributesPD",
    "orderBy"
})
@XmlRootElement(name = "item")
public class Item {

    @XmlElement(name = "attributes", required = true)
    protected AttributesPD attributesPD;
    protected OrderBy orderBy;
    @XmlAttribute
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "token")
    protected String id;
    @XmlAttribute
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "token")
    protected String createdBy;
    @XmlAttribute
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar creationDate;

    public AttributesPD getAttributesPD() {
        return attributesPD;
    }

    public void setAttributesPD(AttributesPD value) {
        this.attributesPD = value;
    }

    public OrderBy getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(OrderBy value) {
        this.orderBy = value;
    }

    public String getId() {
        return id;
    }

    public void setId(String value) {
        this.id = value;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String value) {
        this.createdBy = value;
    }

    public XMLGregorianCalendar getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(XMLGregorianCalendar value) {
        this.creationDate = value;
    }


OrderBy class:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "orderedAttributeRef"
    })
    public class OrderBy {

        @XmlElement(required = true)
        protected List<OrderedAttributeRefType> orderedAttributeRef;

        public List<OrderedAttributeRefType> getOrderedAttributeRef() {
            if (orderedAttributeRef == null) {
                orderedAttributeRef = new
ArrayList<OrderedAttributeRefType>();
            }
            return this.orderedAttributeRef;
        }

    }

Thanks a mill for all the help,


Monica



                                                                                                                              
  From:       Jim Ma <em...@iona.com>                                                                                           
                                                                                                                              
  To:         cxf-user@incubator.apache.org                                                                                   
                                                                                                                              
  Date:       09/01/2008 13:40                                                                                                
                                                                                                                              
  Subject:    Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'                             
                                                                                                                              





Hi Monica,

How did you get this wsdl ? Is this wsdl  generated with CXF java to
wsdl tool  ?
Since the generated wsdl is an invalid wsdl , cxf wsdl to java tool  is
failed to generate code for it.
I think the problem is in wsdl generation, so we need to know if the
right classes is loaded in
jaxb context during java to wsdl execution.

Regards
Jim





Monica Ferrero wrote:
>
> Hi Jim,
>
> I'm not sure I follow you. I can't see any wsdl to java log...
> The logging.properties in ${CXF_HOME}/etc/logging.properties indicate
> the output is taking to the console. Even if I activate the file
> appender there is no information about the 'Classes known to this
> context' there.
> If I run the wsdl to java in verbose mode, I get a bit more
> information (see below), but no what we are looking for...
>
> Thanks,
>
> Monica
>
>
> [exec] Loading FrontEnd jaxws ...
> [exec] Loading DataBinding jaxb ...
> [exec] <command xmlns="http://cxf.apache.org/Xutil/Command"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http:/
> /cxf.apache.org/Xutil/Command
> http://cxf.apache.org/schema/xutil/command.xsd">
> [exec] <option name="verbose"/>
> [exec] <option name="packagename">com.aaa.bbb.myservice</option>
> [exec] <option name="binding">bindingsPD.xjb</option>
> [exec] <argument name="wsdlurl">MyService.wsdl</argument>
> [exec] </command>
> [exec] wsdl2java -verbose -p com.aaa.bbb.myservice -b bindingsPD.xjb
> MyService.wsdl
> [exec] wsdl2java - Apache CXF (incubator) 2.0.3-incubator
> [exec]
> [exec]
> [exec] WSDLToJava Error : Thrown by JAXB : undefined element
> declaration 'ns1:orderBy'
> [exec]
> [exec] org.apache.cxf.tools.common.ToolException: Thrown by JAXB :
> undefined element declaration 'ns1:orderBy'
> [exec] at
>
org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBBindErrorListener.error(JAXBBindErrorListener.java:34)

> [exec] at
>
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.error(SchemaCompilerImpl.java:245)

> [exec] at
>
com.sun.tools.xjc.util.ErrorReceiverFilter.error(ErrorReceiverFilter.java:61)

> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext$2.error(ParserContext.java:188)
> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:166)

> [exec] at
>
com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:103)

> [exec] at
> com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:91)
> [exec] at com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:66)
> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:126)

> [exec] at
> com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:172)
> [exec] at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:488)
> [exec] at
>
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:197)

> [exec] at
>
org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:209)

> [exec] at
>
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:504)

> [exec] at
>
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:183)

> [exec] at
>
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:229)

> [exec] at
>
org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:83)
> [exec] at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:102)
> [exec] at
org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> [exec] Caused by: org.xml.sax.SAXParseException: undefined element
> declaration 'ns1:orderBy'
> [exec] at
>
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:162)

> [exec] ... 14 more
>
> Inactive hide details for Jim Ma ---09/01/2008 02:18:56---Hi
> Monica,Jim Ma ---09/01/2008 02:18:56---Hi Monica,
>
>
> From:
> Jim Ma <em...@iona.com>
>
> To:
> cxf-user@incubator.apache.org
>
> Date:
> 09/01/2008 02:18
>
> Subject:
> Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> 'ns1:orderBy'
>
> ------------------------------------------------------------------------
>
>
>
> Hi Monica,
>
> Forget to mention .  Search it in  java to wsdl 's log .
>
> Regards
>
> Jim
>
> Monica Ferrero wrote:
> >
> > Hi Jim,
> >
> > Changed the logging level to FINE as you indicated and run the wsdl to
> > java on my wsdl, but there is no such a message in there as "Classes
> > known to this context:". I've search for "classes" and " context" as
> > well and there is nothing on those lines.
> > There are some exceptions that I'm not sure there are relevant. I add
> > here the last one before the error.
> >
> > Thanks for your help,
> >
> > Monica
> >
> >
> > [exec] 08-Jan-2008 10:19:57
> > com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory get
> > [exec] FINE: Using optimized Accessor for
> >
>
com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding

>
> > com.sun.tools.xjc.re
> > ader.xmlschema.bindinfo.BIGlobalBinding.getUnderscoreBinding() and
> > void
> >
> com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.setUnderscore
> >
>
Binding(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding)

> > [exec] 08-Jan-2008 10:19:57
> > com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
> > [exec] FINE: Unable to inject
> >
>
com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType

> > [exec] java.lang.reflect.InvocationTargetException
> > [exec] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
> > [exec] at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

> > [exec] at java.lang.reflect.Method.invoke(Method.java:597)
> > [exec] at
> >
>
com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:125)
> > [...]
> > [exec] at
> org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> > [exec] Caused by: java.lang.LinkageError: loader (instance of
> > sun/misc/Launcher$AppClassLoader): attempted duplicate class
> > definition for
> > name:
> >
>
"com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType"

> > [exec] at java.lang.ClassLoader.defineClass1(Native Method)
> > [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> > [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
> > [exec] ... 84 more
> >
> > Inactive hide details for Jim Ma ---08/01/2008 02:56:05---Hi
> > Monica,Jim Ma ---08/01/2008 02:56:05---Hi Monica,
> >
> >
> > From:
> > Jim Ma <em...@iona.com>
> >
> > To:
> > cxf-user@incubator.apache.org
> >
> > Date:
> > 08/01/2008 02:56
> >
> > Subject:
> > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > 'ns1:orderBy'
> >
> >
------------------------------------------------------------------------
> >
> >
> >
> > Hi Monica,
> >
> > You can change the log level to FINE (modify the log configuration file
> > under ${CXF_HOME}/etc/logging.properties)
> > to see if the OrderBy classes added to JAXB Context when you run
> > java2wsdl tool .
> >
> > Search "Classes known to this context:" in the log file to see  if this
> > class is known to JAXB.
> >
> > Regards
> >
> > Jim
> >
> >
> > Monica Ferrero wrote:
> > >
> > > Hi Jim,
> > >
> > > Thank you for your reply.
> > >
> > > Item and OrderBy are generated by JAXB from a schema.xsd file.
> > > I have followed your advice to see if it behaves any different but I
> > > still get the same error.
> > >
> > > The Item and therefore OrderBy classes belong to a different JAXB
> > > context: com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?
> > >
> > > Thanks for your help,
> > >
> > > Monica
> > >
> > > Inactive hide details for Jim Ma ---07/01/2008 02:22:26---Hi ,Jim Ma
> > > ---07/01/2008 02:22:26---Hi ,
> > >
> > >
> > > From:
> > > Jim Ma <em...@iona.com>
> > >
> > > To:
> > > cxf-user@incubator.apache.org
> > >
> > > Date:
> > > 07/01/2008 02:22
> > >
> > > Subject:
> > > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > 'ns1:orderBy'
> > >
> > >
> ------------------------------------------------------------------------
> > >
> > >
> > >
> > > Hi ,
> > >
> > > From the error message , I think this is caused by the inner class
> > > OrderBy is not loaded into
> > > JAXB context . Can you modify this class as a outer class and try it
> > > again ?
> > > I will look it further to see if the JAXB can not load the inner
> static
> > > class .
> > >
> > > Thanks
> > >
> > > Jim
> > >
> > >
> > > Monica Ferrero wrote:
> > > > Hi!
> > > >
> > > > I'm getting this error:
> > > >
> > > > WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > > 'ns1:orderBy'
> > > >
> > > > when trying to generate java stubs from the wsdl.
> > > >
> > > >
> > > > This is my original service:
> > > >
> > > > @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> > > > public interface MyService {
> > > >
> > > >     [...]
> > > >
> > > >     @WebResult(name="MyList")
> > > >     @WebMethod
> > > >     MyList getItems( @WebParam(name="listId") int listId);
> > > >
> > > >     [...]
> > > > }
> > > >
> > > >
> > > > the MyList class:
> > > >
> > > > @XmlAccessorType(XmlAccessType.FIELD)
> > > > @XmlType(name = "", propOrder = {"items"})
> > > > @XmlRootElement(name = "myList")
> > > > public class MyList {
> > > >
> > > >     @XmlElement(required = true)
> > > >     private List<Item> items;
> > > >
> > > >     public List<Item> getItems() {
> > > >         if (items == null) {
> > > >             items = new ArrayList<Item>();
> > > >         }
> > > >         return items;
> > > >     }
> > > >
> > > >     public void setItems(List<Item> items) {
> > > >         this.items = items;
> > > >     }
> > > > }
> > > >
> > > >
> > > > The Item is a JAXB generated file from a schema:
> > > >
> > > >
> > > > @XmlAccessorType(XmlAccessType.FIELD)
> > > > @XmlType(name = "", propOrder = {
> > > >     "attributesPD",
> > > >     "orderBy"
> > > > })
> > > > @XmlRootElement(name = "item")
> > > > public class Item {
> > > >
> > > >     @XmlElement(name = "attributes", required = true)
> > > >     protected AttributesPD attributesPD;
> > > >     protected Item.OrderBy orderBy;
> > > >     @XmlAttribute
> > > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > > >     @XmlSchemaType(name = "token")
> > > >     protected String id;
> > > >     @XmlAttribute
> > > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > > >     @XmlSchemaType(name = "token")
> > > >     protected String createdBy;
> > > >     @XmlAttribute
> > > >     @XmlSchemaType(name = "date")
> > > >     protected XMLGregorianCalendar creationDate;
> > > >
> > > >     public AttributesPD getAttributesPD() {
> > > >         return attributesPD;
> > > >     }
> > > >
> > > >     public void setAttributesPD(AttributesPD value) {
> > > >         this.attributesPD = value;
> > > >     }
> > > >
> > > >     public Item.OrderBy getOrderBy() {
> > > >         return orderBy;
> > > >     }
> > > >
> > > >     public void setOrderBy(Item.OrderBy value) {
> > > >         this.orderBy = value;
> > > >     }
> > > >
> > > >     public String getId() {
> > > >         return id;
> > > >     }
> > > >
> > > >     public void setId(String value) {
> > > >         this.id = value;
> > > >     }
> > > >
> > > >     public String getCreatedBy() {
> > > >         return createdBy;
> > > >     }
> > > >
> > > >     public void setCreatedBy(String value) {
> > > >         this.createdBy = value;
> > > >     }
> > > >
> > > >     public XMLGregorianCalendar getCreationDate() {
> > > >         return creationDate;
> > > >     }
> > > >
> > > >     public void setCreationDate(XMLGregorianCalendar value) {
> > > >         this.creationDate = value;
> > > >     }
> > > >
> > > >
> > > >     @XmlAccessorType(XmlAccessType.FIELD)
> > > >     @XmlType(name = "", propOrder = {
> > > >         "orderedAttributeRef"
> > > >     })
> > > >     public static class OrderBy {
> > > >
> > > >         @XmlElement(required = true)
> > > >         protected List<OrderedAttributeRefType>
orderedAttributeRef;
> > > >
> > > >         public List<OrderedAttributeRefType>
> > getOrderedAttributeRef() {
> > > >             if (orderedAttributeRef == null) {
> > > >                 orderedAttributeRef = new
> > > > ArrayList<OrderedAttributeRefType>();
> > > >             }
> > > >             return this.orderedAttributeRef;
> > > >         }
> > > >     }
> > > > }
> > > >
> > > >
> > > >
> > > > The wsdl generated by cxf:
> > > >
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > > > xmlns:tns="http://myservice.bbb.aaa.com/"
> > > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > name="MyServiceImplService"
> > > > targetNamespace="http://myservice.bbb.aaa.com/">
> > > >       <wsdl:types>
> > > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > xmlns:tns="http://www.aaa.com/AaaOtherService"
> > > > attributeFormDefault="unqualified" elementFormDefault="qualified"
> > > > targetNamespace="http://www.aaa.com/AaaOtherService">
> > > > [...]
> > > >                   <xs:element name="item">
> > > >                         <xs:complexType>
> > > >                               <xs:sequence>
> > > >                                     <xs:element
> ref="tns:attributes"/>
> > > >                                     <xs:element minOccurs="0"
> > > > name="orderBy">
> > > >                                           <xs:complexType>
> > > >                                                 <xs:sequence>
> > > >                                                       <xs:element
> > > > maxOccurs="unbounded" name="orderedAttributeRef"
> > > > type="tns:orderedAttributeRefType"/>
> > > >                                                 </xs:sequence>
> > > >                                           </xs:complexType>
> > > >                                     </xs:element>
> > > >                               </xs:sequence>
> > > >                               <xs:attribute name="id"
> > type="xs:token"/>
> > > >                               <xs:attribute name="createdBy"
> > > > type="xs:token"/>
> > > >                               <xs:attribute name="creationDate"
> > > > type="xs:date"/>
> > > >                         </xs:complexType>
> > > >                   </xs:element>
> > > > [...]
> > > >             </xs:schema>
> > > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > xmlns="http://myservice.bbb.aaa.com/"
> > > > xmlns:ns1="http://www.aaa.com/AaaOtherService"
> > > > attributeFormDefault="unqualified" elementFormDefault="unqualified"
> > > > targetNamespace="http://myservice.bbb.aaa.com/">
> > > >                   <xs:import
> > > > namespace="http://www.aaa.com/AaaOtherService"/>
> > > >                   <xs:element name="myList">
> > > >                         <xs:complexType>
> > > >                               <xs:sequence>
> > > >                                     <xs:element
> maxOccurs="unbounded"
> > > > name="items">
> > > >                                           <xs:complexType>
> > > >                                                 <xs:sequence>
> > > >                                                       <xs:element
> > > > ref="ns1:attributes"/>
> > > >                                                       <xs:element
> > > > minOccurs="0" ref="ns1:orderBy"/>
> > > >                                                 </xs:sequence>
> > > >                                                 <xs:attribute
> > name="id"
> > > > type="xs:token"/>
> > > >                                                 <xs:attribute
> > > > name="createdBy" type="xs:token"/>
> > > >                                                 <xs:attribute
> > > > name="creationDate" type="xs:date"/>
> > > >                                           </xs:complexType>
> > > >                                     </xs:element>
> > > >                               </xs:sequence>
> > > >                         </xs:complexType>
> > > >                   </xs:element>
> > > > [...]
> > > >                   <xs:element name="getItemsResponse"
> > > > type="getItemsResponse"/>
> > > >                   <xs:complexType name="getItemsResponse">
> > > >                         <xs:sequence>
> > > >                               <xs:element minOccurs="0"
> ref="myList"/>
> > > >                         </xs:sequence>
> > > >                   </xs:complexType>
> > > > [...]
> > > >             </xs:schema>
> > > >       </wsdl:types>
> > > > [...]
> > > > </wsdl:definitions>
> > > >
> > > >
> > > >
> > > > I think it's a bit weird that it defines myList as a sequence of
the
> > > > elements that form an Item, instead of a sequence of items.
> > > > Anyway I'm not sure why it does not work if it is mostly all
> generated
> > > > code.
> > > > Any ideas?
> > > >
> > > > Help or pointers very much appreciated!
> > > >
> > > >
> > > > Monica
Accelrys Limited (http://www.accelrys.com) 
Registered office: 334 Cambridge Science Park, Cambridge, CB4 0WN, UK 
Registered in England: 2326316   

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Jim Ma <em...@iona.com>.
Hi Monica,

How did you get this wsdl ? Is this wsdl  generated with CXF java to 
wsdl tool  ?
Since the generated wsdl is an invalid wsdl , cxf wsdl to java tool  is 
failed to generate code for it.
I think the problem is in wsdl generation, so we need to know if the 
right classes is loaded in
jaxb context during java to wsdl execution.

Regards
Jim





Monica Ferrero wrote:
>
> Hi Jim,
>
> I'm not sure I follow you. I can't see any wsdl to java log...
> The logging.properties in ${CXF_HOME}/etc/logging.properties indicate 
> the output is taking to the console. Even if I activate the file 
> appender there is no information about the 'Classes known to this 
> context' there.
> If I run the wsdl to java in verbose mode, I get a bit more 
> information (see below), but no what we are looking for...
>
> Thanks,
>
> Monica
>
>
> [exec] Loading FrontEnd jaxws ...
> [exec] Loading DataBinding jaxb ...
> [exec] <command xmlns="http://cxf.apache.org/Xutil/Command" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:schemaLocation="http:/
> /cxf.apache.org/Xutil/Command 
> http://cxf.apache.org/schema/xutil/command.xsd">
> [exec] <option name="verbose"/>
> [exec] <option name="packagename">com.aaa.bbb.myservice</option>
> [exec] <option name="binding">bindingsPD.xjb</option>
> [exec] <argument name="wsdlurl">MyService.wsdl</argument>
> [exec] </command>
> [exec] wsdl2java -verbose -p com.aaa.bbb.myservice -b bindingsPD.xjb 
> MyService.wsdl
> [exec] wsdl2java - Apache CXF (incubator) 2.0.3-incubator
> [exec]
> [exec]
> [exec] WSDLToJava Error : Thrown by JAXB : undefined element 
> declaration 'ns1:orderBy'
> [exec]
> [exec] org.apache.cxf.tools.common.ToolException: Thrown by JAXB : 
> undefined element declaration 'ns1:orderBy'
> [exec] at 
> org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBBindErrorListener.error(JAXBBindErrorListener.java:34)
> [exec] at 
> com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.error(SchemaCompilerImpl.java:245)
> [exec] at 
> com.sun.tools.xjc.util.ErrorReceiverFilter.error(ErrorReceiverFilter.java:61)
> [exec] at 
> com.sun.xml.xsom.impl.parser.ParserContext$2.error(ParserContext.java:188)
> [exec] at 
> com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:166)
> [exec] at 
> com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:103)
> [exec] at 
> com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:91)
> [exec] at com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:66)
> [exec] at 
> com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:126)
> [exec] at 
> com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:172)
> [exec] at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:488)
> [exec] at 
> com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:197)
> [exec] at 
> org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:209)
> [exec] at 
> org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:504)
> [exec] at 
> org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:183)
> [exec] at 
> org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:229)
> [exec] at 
> org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:83)
> [exec] at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:102)
> [exec] at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> [exec] Caused by: org.xml.sax.SAXParseException: undefined element 
> declaration 'ns1:orderBy'
> [exec] at 
> com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:162)
> [exec] ... 14 more
>
> Inactive hide details for Jim Ma ---09/01/2008 02:18:56---Hi 
> Monica,Jim Ma ---09/01/2008 02:18:56---Hi Monica,
>
>
> From: 	
> Jim Ma <em...@iona.com>
>
> To: 	
> cxf-user@incubator.apache.org
>
> Date: 	
> 09/01/2008 02:18
>
> Subject: 	
> Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 
> 'ns1:orderBy'
>
> ------------------------------------------------------------------------
>
>
>
> Hi Monica,
>
> Forget to mention .  Search it in  java to wsdl 's log .
>
> Regards
>
> Jim
>
> Monica Ferrero wrote:
> >
> > Hi Jim,
> >
> > Changed the logging level to FINE as you indicated and run the wsdl to
> > java on my wsdl, but there is no such a message in there as "Classes
> > known to this context:". I've search for "classes" and " context" as
> > well and there is nothing on those lines.
> > There are some exceptions that I'm not sure there are relevant. I add
> > here the last one before the error.
> >
> > Thanks for your help,
> >
> > Monica
> >
> >
> > [exec] 08-Jan-2008 10:19:57
> > com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory get
> > [exec] FINE: Using optimized Accessor for
> > 
> com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding 
>
> > com.sun.tools.xjc.re
> > ader.xmlschema.bindinfo.BIGlobalBinding.getUnderscoreBinding() and
> > void
> > 
> com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.setUnderscore
> > 
> Binding(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding)
> > [exec] 08-Jan-2008 10:19:57
> > com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
> > [exec] FINE: Unable to inject
> > 
> com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType
> > [exec] java.lang.reflect.InvocationTargetException
> > [exec] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
> > [exec] at
> > 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > [exec] at java.lang.reflect.Method.invoke(Method.java:597)
> > [exec] at
> > 
> com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:125)
> > [...]
> > [exec] at 
> org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> > [exec] Caused by: java.lang.LinkageError: loader (instance of
> > sun/misc/Launcher$AppClassLoader): attempted duplicate class
> > definition for
> > name:
> > 
> "com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType"
> > [exec] at java.lang.ClassLoader.defineClass1(Native Method)
> > [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> > [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
> > [exec] ... 84 more
> >
> > Inactive hide details for Jim Ma ---08/01/2008 02:56:05---Hi
> > Monica,Jim Ma ---08/01/2008 02:56:05---Hi Monica,
> >
> >
> > From:
> > Jim Ma <em...@iona.com>
> >
> > To:
> > cxf-user@incubator.apache.org
> >
> > Date:
> > 08/01/2008 02:56
> >
> > Subject:
> > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > 'ns1:orderBy'
> >
> > ------------------------------------------------------------------------
> >
> >
> >
> > Hi Monica,
> >
> > You can change the log level to FINE (modify the log configuration file
> > under ${CXF_HOME}/etc/logging.properties)
> > to see if the OrderBy classes added to JAXB Context when you run
> > java2wsdl tool .
> >
> > Search "Classes known to this context:" in the log file to see  if this
> > class is known to JAXB.
> >
> > Regards
> >
> > Jim
> >
> >
> > Monica Ferrero wrote:
> > >
> > > Hi Jim,
> > >
> > > Thank you for your reply.
> > >
> > > Item and OrderBy are generated by JAXB from a schema.xsd file.
> > > I have followed your advice to see if it behaves any different but I
> > > still get the same error.
> > >
> > > The Item and therefore OrderBy classes belong to a different JAXB
> > > context: com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?
> > >
> > > Thanks for your help,
> > >
> > > Monica
> > >
> > > Inactive hide details for Jim Ma ---07/01/2008 02:22:26---Hi ,Jim Ma
> > > ---07/01/2008 02:22:26---Hi ,
> > >
> > >
> > > From:
> > > Jim Ma <em...@iona.com>
> > >
> > > To:
> > > cxf-user@incubator.apache.org
> > >
> > > Date:
> > > 07/01/2008 02:22
> > >
> > > Subject:
> > > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > 'ns1:orderBy'
> > >
> > > 
> ------------------------------------------------------------------------
> > >
> > >
> > >
> > > Hi ,
> > >
> > > From the error message , I think this is caused by the inner class
> > > OrderBy is not loaded into
> > > JAXB context . Can you modify this class as a outer class and try it
> > > again ?
> > > I will look it further to see if the JAXB can not load the inner 
> static
> > > class .
> > >
> > > Thanks
> > >
> > > Jim
> > >
> > >
> > > Monica Ferrero wrote:
> > > > Hi!
> > > >
> > > > I'm getting this error:
> > > >
> > > > WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > > 'ns1:orderBy'
> > > >
> > > > when trying to generate java stubs from the wsdl.
> > > >
> > > >
> > > > This is my original service:
> > > >
> > > > @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> > > > public interface MyService {
> > > >
> > > >     [...]
> > > >
> > > >     @WebResult(name="MyList")
> > > >     @WebMethod
> > > >     MyList getItems( @WebParam(name="listId") int listId);
> > > >
> > > >     [...]
> > > > }
> > > >
> > > >
> > > > the MyList class:
> > > >
> > > > @XmlAccessorType(XmlAccessType.FIELD)
> > > > @XmlType(name = "", propOrder = {"items"})
> > > > @XmlRootElement(name = "myList")
> > > > public class MyList {
> > > >
> > > >     @XmlElement(required = true)
> > > >     private List<Item> items;
> > > >
> > > >     public List<Item> getItems() {
> > > >         if (items == null) {
> > > >             items = new ArrayList<Item>();
> > > >         }
> > > >         return items;
> > > >     }
> > > >
> > > >     public void setItems(List<Item> items) {
> > > >         this.items = items;
> > > >     }
> > > > }
> > > >
> > > >
> > > > The Item is a JAXB generated file from a schema:
> > > >
> > > >
> > > > @XmlAccessorType(XmlAccessType.FIELD)
> > > > @XmlType(name = "", propOrder = {
> > > >     "attributesPD",
> > > >     "orderBy"
> > > > })
> > > > @XmlRootElement(name = "item")
> > > > public class Item {
> > > >
> > > >     @XmlElement(name = "attributes", required = true)
> > > >     protected AttributesPD attributesPD;
> > > >     protected Item.OrderBy orderBy;
> > > >     @XmlAttribute
> > > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > > >     @XmlSchemaType(name = "token")
> > > >     protected String id;
> > > >     @XmlAttribute
> > > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > > >     @XmlSchemaType(name = "token")
> > > >     protected String createdBy;
> > > >     @XmlAttribute
> > > >     @XmlSchemaType(name = "date")
> > > >     protected XMLGregorianCalendar creationDate;
> > > >
> > > >     public AttributesPD getAttributesPD() {
> > > >         return attributesPD;
> > > >     }
> > > >
> > > >     public void setAttributesPD(AttributesPD value) {
> > > >         this.attributesPD = value;
> > > >     }
> > > >
> > > >     public Item.OrderBy getOrderBy() {
> > > >         return orderBy;
> > > >     }
> > > >
> > > >     public void setOrderBy(Item.OrderBy value) {
> > > >         this.orderBy = value;
> > > >     }
> > > >
> > > >     public String getId() {
> > > >         return id;
> > > >     }
> > > >
> > > >     public void setId(String value) {
> > > >         this.id = value;
> > > >     }
> > > >
> > > >     public String getCreatedBy() {
> > > >         return createdBy;
> > > >     }
> > > >
> > > >     public void setCreatedBy(String value) {
> > > >         this.createdBy = value;
> > > >     }
> > > >
> > > >     public XMLGregorianCalendar getCreationDate() {
> > > >         return creationDate;
> > > >     }
> > > >
> > > >     public void setCreationDate(XMLGregorianCalendar value) {
> > > >         this.creationDate = value;
> > > >     }
> > > >
> > > >
> > > >     @XmlAccessorType(XmlAccessType.FIELD)
> > > >     @XmlType(name = "", propOrder = {
> > > >         "orderedAttributeRef"
> > > >     })
> > > >     public static class OrderBy {
> > > >
> > > >         @XmlElement(required = true)
> > > >         protected List<OrderedAttributeRefType> orderedAttributeRef;
> > > >
> > > >         public List<OrderedAttributeRefType>
> > getOrderedAttributeRef() {
> > > >             if (orderedAttributeRef == null) {
> > > >                 orderedAttributeRef = new
> > > > ArrayList<OrderedAttributeRefType>();
> > > >             }
> > > >             return this.orderedAttributeRef;
> > > >         }
> > > >     }
> > > > }
> > > >
> > > >
> > > >
> > > > The wsdl generated by cxf:
> > > >
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > > > xmlns:tns="http://myservice.bbb.aaa.com/"
> > > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > name="MyServiceImplService"
> > > > targetNamespace="http://myservice.bbb.aaa.com/">
> > > >       <wsdl:types>
> > > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > xmlns:tns="http://www.aaa.com/AaaOtherService"
> > > > attributeFormDefault="unqualified" elementFormDefault="qualified"
> > > > targetNamespace="http://www.aaa.com/AaaOtherService">
> > > > [...]
> > > >                   <xs:element name="item">
> > > >                         <xs:complexType>
> > > >                               <xs:sequence>
> > > >                                     <xs:element 
> ref="tns:attributes"/>
> > > >                                     <xs:element minOccurs="0"
> > > > name="orderBy">
> > > >                                           <xs:complexType>
> > > >                                                 <xs:sequence>
> > > >                                                       <xs:element
> > > > maxOccurs="unbounded" name="orderedAttributeRef"
> > > > type="tns:orderedAttributeRefType"/>
> > > >                                                 </xs:sequence>
> > > >                                           </xs:complexType>
> > > >                                     </xs:element>
> > > >                               </xs:sequence>
> > > >                               <xs:attribute name="id"
> > type="xs:token"/>
> > > >                               <xs:attribute name="createdBy"
> > > > type="xs:token"/>
> > > >                               <xs:attribute name="creationDate"
> > > > type="xs:date"/>
> > > >                         </xs:complexType>
> > > >                   </xs:element>
> > > > [...]
> > > >             </xs:schema>
> > > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > xmlns="http://myservice.bbb.aaa.com/"
> > > > xmlns:ns1="http://www.aaa.com/AaaOtherService"
> > > > attributeFormDefault="unqualified" elementFormDefault="unqualified"
> > > > targetNamespace="http://myservice.bbb.aaa.com/">
> > > >                   <xs:import
> > > > namespace="http://www.aaa.com/AaaOtherService"/>
> > > >                   <xs:element name="myList">
> > > >                         <xs:complexType>
> > > >                               <xs:sequence>
> > > >                                     <xs:element 
> maxOccurs="unbounded"
> > > > name="items">
> > > >                                           <xs:complexType>
> > > >                                                 <xs:sequence>
> > > >                                                       <xs:element
> > > > ref="ns1:attributes"/>
> > > >                                                       <xs:element
> > > > minOccurs="0" ref="ns1:orderBy"/>
> > > >                                                 </xs:sequence>
> > > >                                                 <xs:attribute
> > name="id"
> > > > type="xs:token"/>
> > > >                                                 <xs:attribute
> > > > name="createdBy" type="xs:token"/>
> > > >                                                 <xs:attribute
> > > > name="creationDate" type="xs:date"/>
> > > >                                           </xs:complexType>
> > > >                                     </xs:element>
> > > >                               </xs:sequence>
> > > >                         </xs:complexType>
> > > >                   </xs:element>
> > > > [...]
> > > >                   <xs:element name="getItemsResponse"
> > > > type="getItemsResponse"/>
> > > >                   <xs:complexType name="getItemsResponse">
> > > >                         <xs:sequence>
> > > >                               <xs:element minOccurs="0" 
> ref="myList"/>
> > > >                         </xs:sequence>
> > > >                   </xs:complexType>
> > > > [...]
> > > >             </xs:schema>
> > > >       </wsdl:types>
> > > > [...]
> > > > </wsdl:definitions>
> > > >
> > > >
> > > >
> > > > I think it's a bit weird that it defines myList as a sequence of the
> > > > elements that form an Item, instead of a sequence of items.
> > > > Anyway I'm not sure why it does not work if it is mostly all 
> generated
> > > > code.
> > > > Any ideas?
> > > >
> > > > Help or pointers very much appreciated!
> > > >
> > > >
> > > > Monica

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Monica Ferrero <mf...@accelrys.com>.
Hi Jim,

I'm not sure I follow you. I can't see any wsdl to java log...
The logging.properties in ${CXF_HOME}/etc/logging.properties indicate the
output is taking to the console. Even if I activate the file appender there
is no information about the 'Classes known to this context' there.
If I run the wsdl to java in verbose mode, I get a bit more information
(see below), but no what we are looking for...

Thanks,

Monica


     [exec] Loading FrontEnd jaxws ...
     [exec] Loading DataBinding jaxb ...
     [exec] <command xmlns="http://cxf.apache.org/Xutil/Command"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:/
/cxf.apache.org/Xutil/Command
http://cxf.apache.org/schema/xutil/command.xsd">
     [exec] <option name="verbose"/>
     [exec] <option name="packagename">com.aaa.bbb.myservice</option>
     [exec] <option name="binding">bindingsPD.xjb</option>
     [exec] <argument name="wsdlurl">MyService.wsdl</argument>
     [exec] </command>
     [exec] wsdl2java -verbose -p com.aaa.bbb.myservice -b bindingsPD.xjb
MyService.wsdl
     [exec] wsdl2java - Apache CXF (incubator) 2.0.3-incubator
     [exec]
     [exec]
     [exec] WSDLToJava Error : Thrown by JAXB : undefined element
declaration 'ns1:orderBy'
     [exec]
     [exec] org.apache.cxf.tools.common.ToolException: Thrown by JAXB :
undefined element declaration 'ns1:orderBy'
     [exec]     at
org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBBindErrorListener.error(JAXBBindErrorListener.java:34)
     [exec]     at
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.error(SchemaCompilerImpl.java:245)
     [exec]     at
com.sun.tools.xjc.util.ErrorReceiverFilter.error(ErrorReceiverFilter.java:61)
     [exec]     at
com.sun.xml.xsom.impl.parser.ParserContext$2.error(ParserContext.java:188)
     [exec]     at
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:166)
     [exec]     at
com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:103)
     [exec]     at
com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:91)
     [exec]     at
com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:66)
     [exec]     at
com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:126)
     [exec]     at
com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:172)
     [exec]     at
com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:488)
     [exec]     at
com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:197)
     [exec]     at
org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:209)
     [exec]     at
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:504)
     [exec]     at
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:183)
     [exec]     at
org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:229)
     [exec]     at
org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:83)
     [exec]     at
org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:102)
     [exec]     at
org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
     [exec] Caused by: org.xml.sax.SAXParseException: undefined element
declaration 'ns1:orderBy'
     [exec]     at
com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:162)
     [exec]     ... 14 more


                                                                                                                              
  From:       Jim Ma <em...@iona.com>                                                                                           
                                                                                                                              
  To:         cxf-user@incubator.apache.org                                                                                   
                                                                                                                              
  Date:       09/01/2008 02:18                                                                                                
                                                                                                                              
  Subject:    Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'                             
                                                                                                                              





Hi Monica,

Forget to mention .  Search it in  java to wsdl 's log .

Regards

Jim

Monica Ferrero wrote:
>
> Hi Jim,
>
> Changed the logging level to FINE as you indicated and run the wsdl to
> java on my wsdl, but there is no such a message in there as "Classes
> known to this context:". I've search for "classes" and " context" as
> well and there is nothing on those lines.
> There are some exceptions that I'm not sure there are relevant. I add
> here the last one before the error.
>
> Thanks for your help,
>
> Monica
>
>
> [exec] 08-Jan-2008 10:19:57
> com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory get
> [exec] FINE: Using optimized Accessor for
>
com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding

> com.sun.tools.xjc.re
> ader.xmlschema.bindinfo.BIGlobalBinding.getUnderscoreBinding() and
> void
> com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.setUnderscore
>
Binding(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding)

> [exec] 08-Jan-2008 10:19:57
> com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
> [exec] FINE: Unable to inject
>
com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType

> [exec] java.lang.reflect.InvocationTargetException
> [exec] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
> [exec] at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

> [exec] at java.lang.reflect.Method.invoke(Method.java:597)
> [exec] at
>
com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:125)
> [...]
> [exec] at
org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> [exec] Caused by: java.lang.LinkageError: loader (instance of
> sun/misc/Launcher$AppClassLoader): attempted duplicate class
> definition for
> name:
>
"com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType"

> [exec] at java.lang.ClassLoader.defineClass1(Native Method)
> [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
> [exec] ... 84 more
>
> Inactive hide details for Jim Ma ---08/01/2008 02:56:05---Hi
> Monica,Jim Ma ---08/01/2008 02:56:05---Hi Monica,
>
>
> From:
> Jim Ma <em...@iona.com>
>
> To:
> cxf-user@incubator.apache.org
>
> Date:
> 08/01/2008 02:56
>
> Subject:
> Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> 'ns1:orderBy'
>
> ------------------------------------------------------------------------
>
>
>
> Hi Monica,
>
> You can change the log level to FINE (modify the log configuration file
> under ${CXF_HOME}/etc/logging.properties)
> to see if the OrderBy classes added to JAXB Context when you run
> java2wsdl tool .
>
> Search "Classes known to this context:" in the log file to see  if this
> class is known to JAXB.
>
> Regards
>
> Jim
>
>
> Monica Ferrero wrote:
> >
> > Hi Jim,
> >
> > Thank you for your reply.
> >
> > Item and OrderBy are generated by JAXB from a schema.xsd file.
> > I have followed your advice to see if it behaves any different but I
> > still get the same error.
> >
> > The Item and therefore OrderBy classes belong to a different JAXB
> > context: com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?
> >
> > Thanks for your help,
> >
> > Monica
> >
> > Inactive hide details for Jim Ma ---07/01/2008 02:22:26---Hi ,Jim Ma
> > ---07/01/2008 02:22:26---Hi ,
> >
> >
> > From:
> > Jim Ma <em...@iona.com>
> >
> > To:
> > cxf-user@incubator.apache.org
> >
> > Date:
> > 07/01/2008 02:22
> >
> > Subject:
> > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > 'ns1:orderBy'
> >
> >
------------------------------------------------------------------------
> >
> >
> >
> > Hi ,
> >
> > From the error message , I think this is caused by the inner class
> > OrderBy is not loaded into
> > JAXB context . Can you modify this class as a outer class and try it
> > again ?
> > I will look it further to see if the JAXB can not load the inner static
> > class .
> >
> > Thanks
> >
> > Jim
> >
> >
> > Monica Ferrero wrote:
> > > Hi!
> > >
> > > I'm getting this error:
> > >
> > > WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > 'ns1:orderBy'
> > >
> > > when trying to generate java stubs from the wsdl.
> > >
> > >
> > > This is my original service:
> > >
> > > @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> > > public interface MyService {
> > >
> > >     [...]
> > >
> > >     @WebResult(name="MyList")
> > >     @WebMethod
> > >     MyList getItems( @WebParam(name="listId") int listId);
> > >
> > >     [...]
> > > }
> > >
> > >
> > > the MyList class:
> > >
> > > @XmlAccessorType(XmlAccessType.FIELD)
> > > @XmlType(name = "", propOrder = {"items"})
> > > @XmlRootElement(name = "myList")
> > > public class MyList {
> > >
> > >     @XmlElement(required = true)
> > >     private List<Item> items;
> > >
> > >     public List<Item> getItems() {
> > >         if (items == null) {
> > >             items = new ArrayList<Item>();
> > >         }
> > >         return items;
> > >     }
> > >
> > >     public void setItems(List<Item> items) {
> > >         this.items = items;
> > >     }
> > > }
> > >
> > >
> > > The Item is a JAXB generated file from a schema:
> > >
> > >
> > > @XmlAccessorType(XmlAccessType.FIELD)
> > > @XmlType(name = "", propOrder = {
> > >     "attributesPD",
> > >     "orderBy"
> > > })
> > > @XmlRootElement(name = "item")
> > > public class Item {
> > >
> > >     @XmlElement(name = "attributes", required = true)
> > >     protected AttributesPD attributesPD;
> > >     protected Item.OrderBy orderBy;
> > >     @XmlAttribute
> > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > >     @XmlSchemaType(name = "token")
> > >     protected String id;
> > >     @XmlAttribute
> > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > >     @XmlSchemaType(name = "token")
> > >     protected String createdBy;
> > >     @XmlAttribute
> > >     @XmlSchemaType(name = "date")
> > >     protected XMLGregorianCalendar creationDate;
> > >
> > >     public AttributesPD getAttributesPD() {
> > >         return attributesPD;
> > >     }
> > >
> > >     public void setAttributesPD(AttributesPD value) {
> > >         this.attributesPD = value;
> > >     }
> > >
> > >     public Item.OrderBy getOrderBy() {
> > >         return orderBy;
> > >     }
> > >
> > >     public void setOrderBy(Item.OrderBy value) {
> > >         this.orderBy = value;
> > >     }
> > >
> > >     public String getId() {
> > >         return id;
> > >     }
> > >
> > >     public void setId(String value) {
> > >         this.id = value;
> > >     }
> > >
> > >     public String getCreatedBy() {
> > >         return createdBy;
> > >     }
> > >
> > >     public void setCreatedBy(String value) {
> > >         this.createdBy = value;
> > >     }
> > >
> > >     public XMLGregorianCalendar getCreationDate() {
> > >         return creationDate;
> > >     }
> > >
> > >     public void setCreationDate(XMLGregorianCalendar value) {
> > >         this.creationDate = value;
> > >     }
> > >
> > >
> > >     @XmlAccessorType(XmlAccessType.FIELD)
> > >     @XmlType(name = "", propOrder = {
> > >         "orderedAttributeRef"
> > >     })
> > >     public static class OrderBy {
> > >
> > >         @XmlElement(required = true)
> > >         protected List<OrderedAttributeRefType> orderedAttributeRef;
> > >
> > >         public List<OrderedAttributeRefType>
> getOrderedAttributeRef() {
> > >             if (orderedAttributeRef == null) {
> > >                 orderedAttributeRef = new
> > > ArrayList<OrderedAttributeRefType>();
> > >             }
> > >             return this.orderedAttributeRef;
> > >         }
> > >     }
> > > }
> > >
> > >
> > >
> > > The wsdl generated by cxf:
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > > xmlns:tns="http://myservice.bbb.aaa.com/"
> > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> name="MyServiceImplService"
> > > targetNamespace="http://myservice.bbb.aaa.com/">
> > >       <wsdl:types>
> > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns:tns="http://www.aaa.com/AaaOtherService"
> > > attributeFormDefault="unqualified" elementFormDefault="qualified"
> > > targetNamespace="http://www.aaa.com/AaaOtherService">
> > > [...]
> > >                   <xs:element name="item">
> > >                         <xs:complexType>
> > >                               <xs:sequence>
> > >                                     <xs:element
ref="tns:attributes"/>
> > >                                     <xs:element minOccurs="0"
> > > name="orderBy">
> > >                                           <xs:complexType>
> > >                                                 <xs:sequence>
> > >                                                       <xs:element
> > > maxOccurs="unbounded" name="orderedAttributeRef"
> > > type="tns:orderedAttributeRefType"/>
> > >                                                 </xs:sequence>
> > >                                           </xs:complexType>
> > >                                     </xs:element>
> > >                               </xs:sequence>
> > >                               <xs:attribute name="id"
> type="xs:token"/>
> > >                               <xs:attribute name="createdBy"
> > > type="xs:token"/>
> > >                               <xs:attribute name="creationDate"
> > > type="xs:date"/>
> > >                         </xs:complexType>
> > >                   </xs:element>
> > > [...]
> > >             </xs:schema>
> > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns="http://myservice.bbb.aaa.com/"
> > > xmlns:ns1="http://www.aaa.com/AaaOtherService"
> > > attributeFormDefault="unqualified" elementFormDefault="unqualified"
> > > targetNamespace="http://myservice.bbb.aaa.com/">
> > >                   <xs:import
> > > namespace="http://www.aaa.com/AaaOtherService"/>
> > >                   <xs:element name="myList">
> > >                         <xs:complexType>
> > >                               <xs:sequence>
> > >                                     <xs:element maxOccurs="unbounded"
> > > name="items">
> > >                                           <xs:complexType>
> > >                                                 <xs:sequence>
> > >                                                       <xs:element
> > > ref="ns1:attributes"/>
> > >                                                       <xs:element
> > > minOccurs="0" ref="ns1:orderBy"/>
> > >                                                 </xs:sequence>
> > >                                                 <xs:attribute
> name="id"
> > > type="xs:token"/>
> > >                                                 <xs:attribute
> > > name="createdBy" type="xs:token"/>
> > >                                                 <xs:attribute
> > > name="creationDate" type="xs:date"/>
> > >                                           </xs:complexType>
> > >                                     </xs:element>
> > >                               </xs:sequence>
> > >                         </xs:complexType>
> > >                   </xs:element>
> > > [...]
> > >                   <xs:element name="getItemsResponse"
> > > type="getItemsResponse"/>
> > >                   <xs:complexType name="getItemsResponse">
> > >                         <xs:sequence>
> > >                               <xs:element minOccurs="0"
ref="myList"/>
> > >                         </xs:sequence>
> > >                   </xs:complexType>
> > > [...]
> > >             </xs:schema>
> > >       </wsdl:types>
> > > [...]
> > > </wsdl:definitions>
> > >
> > >
> > >
> > > I think it's a bit weird that it defines myList as a sequence of the
> > > elements that form an Item, instead of a sequence of items.
> > > Anyway I'm not sure why it does not work if it is mostly all
generated
> > > code.
> > > Any ideas?
> > >
> > > Help or pointers very much appreciated!
> > >
> > >
> > > Monica

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Jim Ma <em...@iona.com>.
Hi Monica,

Forget to mention .  Search it in  java to wsdl 's log .

Regards

Jim

Monica Ferrero wrote:
>
> Hi Jim,
>
> Changed the logging level to FINE as you indicated and run the wsdl to 
> java on my wsdl, but there is no such a message in there as "Classes 
> known to this context:". I've search for "classes" and " context" as 
> well and there is nothing on those lines.
> There are some exceptions that I'm not sure there are relevant. I add 
> here the last one before the error.
>
> Thanks for your help,
>
> Monica
>
>
> [exec] 08-Jan-2008 10:19:57 
> com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory get
> [exec] FINE: Using optimized Accessor for 
> com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding 
> com.sun.tools.xjc.re
> ader.xmlschema.bindinfo.BIGlobalBinding.getUnderscoreBinding() and 
> void 
> com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.setUnderscore
> Binding(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding)
> [exec] 08-Jan-2008 10:19:57 
> com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
> [exec] FINE: Unable to inject 
> com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType
> [exec] java.lang.reflect.InvocationTargetException
> [exec] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
> [exec] at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> [exec] at java.lang.reflect.Method.invoke(Method.java:597)
> [exec] at 
> com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:125)
> [...]
> [exec] at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
> [exec] Caused by: java.lang.LinkageError: loader (instance of 
> sun/misc/Launcher$AppClassLoader): attempted duplicate class 
> definition for
> name: 
> "com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType"
> [exec] at java.lang.ClassLoader.defineClass1(Native Method)
> [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> [exec] at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
> [exec] ... 84 more
>
> Inactive hide details for Jim Ma ---08/01/2008 02:56:05---Hi 
> Monica,Jim Ma ---08/01/2008 02:56:05---Hi Monica,
>
>
> From: 	
> Jim Ma <em...@iona.com>
>
> To: 	
> cxf-user@incubator.apache.org
>
> Date: 	
> 08/01/2008 02:56
>
> Subject: 	
> Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 
> 'ns1:orderBy'
>
> ------------------------------------------------------------------------
>
>
>
> Hi Monica,
>
> You can change the log level to FINE (modify the log configuration file
> under ${CXF_HOME}/etc/logging.properties)
> to see if the OrderBy classes added to JAXB Context when you run
> java2wsdl tool .
>
> Search "Classes known to this context:" in the log file to see  if this
> class is known to JAXB.
>
> Regards
>
> Jim
>
>
> Monica Ferrero wrote:
> >
> > Hi Jim,
> >
> > Thank you for your reply.
> >
> > Item and OrderBy are generated by JAXB from a schema.xsd file.
> > I have followed your advice to see if it behaves any different but I
> > still get the same error.
> >
> > The Item and therefore OrderBy classes belong to a different JAXB
> > context: com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?
> >
> > Thanks for your help,
> >
> > Monica
> >
> > Inactive hide details for Jim Ma ---07/01/2008 02:22:26---Hi ,Jim Ma
> > ---07/01/2008 02:22:26---Hi ,
> >
> >
> > From:
> > Jim Ma <em...@iona.com>
> >
> > To:
> > cxf-user@incubator.apache.org
> >
> > Date:
> > 07/01/2008 02:22
> >
> > Subject:
> > Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > 'ns1:orderBy'
> >
> > ------------------------------------------------------------------------
> >
> >
> >
> > Hi ,
> >
> > From the error message , I think this is caused by the inner class
> > OrderBy is not loaded into
> > JAXB context . Can you modify this class as a outer class and try it
> > again ?
> > I will look it further to see if the JAXB can not load the inner static
> > class .
> >
> > Thanks
> >
> > Jim
> >
> >
> > Monica Ferrero wrote:
> > > Hi!
> > >
> > > I'm getting this error:
> > >
> > > WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > > 'ns1:orderBy'
> > >
> > > when trying to generate java stubs from the wsdl.
> > >
> > >
> > > This is my original service:
> > >
> > > @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> > > public interface MyService {
> > >
> > >     [...]
> > >
> > >     @WebResult(name="MyList")
> > >     @WebMethod
> > >     MyList getItems( @WebParam(name="listId") int listId);
> > >
> > >     [...]
> > > }
> > >
> > >
> > > the MyList class:
> > >
> > > @XmlAccessorType(XmlAccessType.FIELD)
> > > @XmlType(name = "", propOrder = {"items"})
> > > @XmlRootElement(name = "myList")
> > > public class MyList {
> > >
> > >     @XmlElement(required = true)
> > >     private List<Item> items;
> > >
> > >     public List<Item> getItems() {
> > >         if (items == null) {
> > >             items = new ArrayList<Item>();
> > >         }
> > >         return items;
> > >     }
> > >
> > >     public void setItems(List<Item> items) {
> > >         this.items = items;
> > >     }
> > > }
> > >
> > >
> > > The Item is a JAXB generated file from a schema:
> > >
> > >
> > > @XmlAccessorType(XmlAccessType.FIELD)
> > > @XmlType(name = "", propOrder = {
> > >     "attributesPD",
> > >     "orderBy"
> > > })
> > > @XmlRootElement(name = "item")
> > > public class Item {
> > >
> > >     @XmlElement(name = "attributes", required = true)
> > >     protected AttributesPD attributesPD;
> > >     protected Item.OrderBy orderBy;
> > >     @XmlAttribute
> > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > >     @XmlSchemaType(name = "token")
> > >     protected String id;
> > >     @XmlAttribute
> > >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> > >     @XmlSchemaType(name = "token")
> > >     protected String createdBy;
> > >     @XmlAttribute
> > >     @XmlSchemaType(name = "date")
> > >     protected XMLGregorianCalendar creationDate;
> > >
> > >     public AttributesPD getAttributesPD() {
> > >         return attributesPD;
> > >     }
> > >
> > >     public void setAttributesPD(AttributesPD value) {
> > >         this.attributesPD = value;
> > >     }
> > >
> > >     public Item.OrderBy getOrderBy() {
> > >         return orderBy;
> > >     }
> > >
> > >     public void setOrderBy(Item.OrderBy value) {
> > >         this.orderBy = value;
> > >     }
> > >
> > >     public String getId() {
> > >         return id;
> > >     }
> > >
> > >     public void setId(String value) {
> > >         this.id = value;
> > >     }
> > >
> > >     public String getCreatedBy() {
> > >         return createdBy;
> > >     }
> > >
> > >     public void setCreatedBy(String value) {
> > >         this.createdBy = value;
> > >     }
> > >
> > >     public XMLGregorianCalendar getCreationDate() {
> > >         return creationDate;
> > >     }
> > >
> > >     public void setCreationDate(XMLGregorianCalendar value) {
> > >         this.creationDate = value;
> > >     }
> > >
> > >
> > >     @XmlAccessorType(XmlAccessType.FIELD)
> > >     @XmlType(name = "", propOrder = {
> > >         "orderedAttributeRef"
> > >     })
> > >     public static class OrderBy {
> > >
> > >         @XmlElement(required = true)
> > >         protected List<OrderedAttributeRefType> orderedAttributeRef;
> > >
> > >         public List<OrderedAttributeRefType> 
> getOrderedAttributeRef() {
> > >             if (orderedAttributeRef == null) {
> > >                 orderedAttributeRef = new
> > > ArrayList<OrderedAttributeRefType>();
> > >             }
> > >             return this.orderedAttributeRef;
> > >         }
> > >     }
> > > }
> > >
> > >
> > >
> > > The wsdl generated by cxf:
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > > xmlns:tns="http://myservice.bbb.aaa.com/"
> > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> name="MyServiceImplService"
> > > targetNamespace="http://myservice.bbb.aaa.com/">
> > >       <wsdl:types>
> > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns:tns="http://www.aaa.com/AaaOtherService"
> > > attributeFormDefault="unqualified" elementFormDefault="qualified"
> > > targetNamespace="http://www.aaa.com/AaaOtherService">
> > > [...]
> > >                   <xs:element name="item">
> > >                         <xs:complexType>
> > >                               <xs:sequence>
> > >                                     <xs:element ref="tns:attributes"/>
> > >                                     <xs:element minOccurs="0"
> > > name="orderBy">
> > >                                           <xs:complexType>
> > >                                                 <xs:sequence>
> > >                                                       <xs:element
> > > maxOccurs="unbounded" name="orderedAttributeRef"
> > > type="tns:orderedAttributeRefType"/>
> > >                                                 </xs:sequence>
> > >                                           </xs:complexType>
> > >                                     </xs:element>
> > >                               </xs:sequence>
> > >                               <xs:attribute name="id" 
> type="xs:token"/>
> > >                               <xs:attribute name="createdBy"
> > > type="xs:token"/>
> > >                               <xs:attribute name="creationDate"
> > > type="xs:date"/>
> > >                         </xs:complexType>
> > >                   </xs:element>
> > > [...]
> > >             </xs:schema>
> > >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns="http://myservice.bbb.aaa.com/"
> > > xmlns:ns1="http://www.aaa.com/AaaOtherService"
> > > attributeFormDefault="unqualified" elementFormDefault="unqualified"
> > > targetNamespace="http://myservice.bbb.aaa.com/">
> > >                   <xs:import
> > > namespace="http://www.aaa.com/AaaOtherService"/>
> > >                   <xs:element name="myList">
> > >                         <xs:complexType>
> > >                               <xs:sequence>
> > >                                     <xs:element maxOccurs="unbounded"
> > > name="items">
> > >                                           <xs:complexType>
> > >                                                 <xs:sequence>
> > >                                                       <xs:element
> > > ref="ns1:attributes"/>
> > >                                                       <xs:element
> > > minOccurs="0" ref="ns1:orderBy"/>
> > >                                                 </xs:sequence>
> > >                                                 <xs:attribute 
> name="id"
> > > type="xs:token"/>
> > >                                                 <xs:attribute
> > > name="createdBy" type="xs:token"/>
> > >                                                 <xs:attribute
> > > name="creationDate" type="xs:date"/>
> > >                                           </xs:complexType>
> > >                                     </xs:element>
> > >                               </xs:sequence>
> > >                         </xs:complexType>
> > >                   </xs:element>
> > > [...]
> > >                   <xs:element name="getItemsResponse"
> > > type="getItemsResponse"/>
> > >                   <xs:complexType name="getItemsResponse">
> > >                         <xs:sequence>
> > >                               <xs:element minOccurs="0" ref="myList"/>
> > >                         </xs:sequence>
> > >                   </xs:complexType>
> > > [...]
> > >             </xs:schema>
> > >       </wsdl:types>
> > > [...]
> > > </wsdl:definitions>
> > >
> > >
> > >
> > > I think it's a bit weird that it defines myList as a sequence of the
> > > elements that form an Item, instead of a sequence of items.
> > > Anyway I'm not sure why it does not work if it is mostly all generated
> > > code.
> > > Any ideas?
> > >
> > > Help or pointers very much appreciated!
> > >
> > >
> > > Monica

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Monica Ferrero <mf...@accelrys.com>.
Hi Jim,

Changed the logging level to FINE as you indicated and run the wsdl to java
on my wsdl, but there is no such a message in there as "Classes known to
this context:". I've search for "classes" and " context" as well and there
is nothing on those lines.
There are some exceptions that I'm not sure there are relevant. I add here
the last one before the error.

Thanks for your help,

Monica


     [exec] 08-Jan-2008 10:19:57
com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory get
     [exec] FINE: Using optimized Accessor for
com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding
 com.sun.tools.xjc.re
ader.xmlschema.bindinfo.BIGlobalBinding.getUnderscoreBinding() and void
com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.setUnderscore
Binding(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding$UnderscoreBinding)
     [exec] 08-Jan-2008 10:19:57
com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
     [exec] FINE: Unable to inject
com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType
     [exec] java.lang.reflect.InvocationTargetException
     [exec]     at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown
Source)
     [exec]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
     [exec]     at
com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:125)
     [...]
     [exec]     at
org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:171)
     [exec] Caused by: java.lang.LinkageError: loader (instance of
sun/misc/Launcher$AppClassLoader): attempted  duplicate class definition
for
name:
"com/sun/tools/xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute$JaxbAccessorF_collectionType"
     [exec]     at java.lang.ClassLoader.defineClass1(Native Method)
     [exec]     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
     [exec]     at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
     [exec]     ... 84 more


                                                                                                                              
  From:       Jim Ma <em...@iona.com>                                                                                           
                                                                                                                              
  To:         cxf-user@incubator.apache.org                                                                                   
                                                                                                                              
  Date:       08/01/2008 02:56                                                                                                
                                                                                                                              
  Subject:    Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'                             
                                                                                                                              





Hi Monica,

You can change the log level to FINE (modify the log configuration file
under ${CXF_HOME}/etc/logging.properties)
 to see if the OrderBy classes added to JAXB Context when you run
java2wsdl tool .

Search "Classes known to this context:" in the log file to see  if this
class is known to JAXB.

Regards

Jim


Monica Ferrero wrote:
>
> Hi Jim,
>
> Thank you for your reply.
>
> Item and OrderBy are generated by JAXB from a schema.xsd file.
> I have followed your advice to see if it behaves any different but I
> still get the same error.
>
> The Item and therefore OrderBy classes belong to a different JAXB
> context: com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?
>
> Thanks for your help,
>
> Monica
>
> Inactive hide details for Jim Ma ---07/01/2008 02:22:26---Hi ,Jim Ma
> ---07/01/2008 02:22:26---Hi ,
>
>
> From:
> Jim Ma <em...@iona.com>
>
> To:
> cxf-user@incubator.apache.org
>
> Date:
> 07/01/2008 02:22
>
> Subject:
> Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration
> 'ns1:orderBy'
>
> ------------------------------------------------------------------------
>
>
>
> Hi ,
>
> From the error message , I think this is caused by the inner class
> OrderBy is not loaded into
> JAXB context . Can you modify this class as a outer class and try it
> again ?
> I will look it further to see if the JAXB can not load the inner static
> class .
>
> Thanks
>
> Jim
>
>
> Monica Ferrero wrote:
> > Hi!
> >
> > I'm getting this error:
> >
> > WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > 'ns1:orderBy'
> >
> > when trying to generate java stubs from the wsdl.
> >
> >
> > This is my original service:
> >
> > @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> > public interface MyService {
> >
> >     [...]
> >
> >     @WebResult(name="MyList")
> >     @WebMethod
> >     MyList getItems( @WebParam(name="listId") int listId);
> >
> >     [...]
> > }
> >
> >
> > the MyList class:
> >
> > @XmlAccessorType(XmlAccessType.FIELD)
> > @XmlType(name = "", propOrder = {"items"})
> > @XmlRootElement(name = "myList")
> > public class MyList {
> >
> >     @XmlElement(required = true)
> >     private List<Item> items;
> >
> >     public List<Item> getItems() {
> >         if (items == null) {
> >             items = new ArrayList<Item>();
> >         }
> >         return items;
> >     }
> >
> >     public void setItems(List<Item> items) {
> >         this.items = items;
> >     }
> > }
> >
> >
> > The Item is a JAXB generated file from a schema:
> >
> >
> > @XmlAccessorType(XmlAccessType.FIELD)
> > @XmlType(name = "", propOrder = {
> >     "attributesPD",
> >     "orderBy"
> > })
> > @XmlRootElement(name = "item")
> > public class Item {
> >
> >     @XmlElement(name = "attributes", required = true)
> >     protected AttributesPD attributesPD;
> >     protected Item.OrderBy orderBy;
> >     @XmlAttribute
> >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> >     @XmlSchemaType(name = "token")
> >     protected String id;
> >     @XmlAttribute
> >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> >     @XmlSchemaType(name = "token")
> >     protected String createdBy;
> >     @XmlAttribute
> >     @XmlSchemaType(name = "date")
> >     protected XMLGregorianCalendar creationDate;
> >
> >     public AttributesPD getAttributesPD() {
> >         return attributesPD;
> >     }
> >
> >     public void setAttributesPD(AttributesPD value) {
> >         this.attributesPD = value;
> >     }
> >
> >     public Item.OrderBy getOrderBy() {
> >         return orderBy;
> >     }
> >
> >     public void setOrderBy(Item.OrderBy value) {
> >         this.orderBy = value;
> >     }
> >
> >     public String getId() {
> >         return id;
> >     }
> >
> >     public void setId(String value) {
> >         this.id = value;
> >     }
> >
> >     public String getCreatedBy() {
> >         return createdBy;
> >     }
> >
> >     public void setCreatedBy(String value) {
> >         this.createdBy = value;
> >     }
> >
> >     public XMLGregorianCalendar getCreationDate() {
> >         return creationDate;
> >     }
> >
> >     public void setCreationDate(XMLGregorianCalendar value) {
> >         this.creationDate = value;
> >     }
> >
> >
> >     @XmlAccessorType(XmlAccessType.FIELD)
> >     @XmlType(name = "", propOrder = {
> >         "orderedAttributeRef"
> >     })
> >     public static class OrderBy {
> >
> >         @XmlElement(required = true)
> >         protected List<OrderedAttributeRefType> orderedAttributeRef;
> >
> >         public List<OrderedAttributeRefType> getOrderedAttributeRef() {
> >             if (orderedAttributeRef == null) {
> >                 orderedAttributeRef = new
> > ArrayList<OrderedAttributeRefType>();
> >             }
> >             return this.orderedAttributeRef;
> >         }
> >     }
> > }
> >
> >
> >
> > The wsdl generated by cxf:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > xmlns:tns="http://myservice.bbb.aaa.com/"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="MyServiceImplService"
> > targetNamespace="http://myservice.bbb.aaa.com/">
> >       <wsdl:types>
> >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns:tns="http://www.aaa.com/AaaOtherService"
> > attributeFormDefault="unqualified" elementFormDefault="qualified"
> > targetNamespace="http://www.aaa.com/AaaOtherService">
> > [...]
> >                   <xs:element name="item">
> >                         <xs:complexType>
> >                               <xs:sequence>
> >                                     <xs:element ref="tns:attributes"/>
> >                                     <xs:element minOccurs="0"
> > name="orderBy">
> >                                           <xs:complexType>
> >                                                 <xs:sequence>
> >                                                       <xs:element
> > maxOccurs="unbounded" name="orderedAttributeRef"
> > type="tns:orderedAttributeRefType"/>
> >                                                 </xs:sequence>
> >                                           </xs:complexType>
> >                                     </xs:element>
> >                               </xs:sequence>
> >                               <xs:attribute name="id" type="xs:token"/>
> >                               <xs:attribute name="createdBy"
> > type="xs:token"/>
> >                               <xs:attribute name="creationDate"
> > type="xs:date"/>
> >                         </xs:complexType>
> >                   </xs:element>
> > [...]
> >             </xs:schema>
> >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns="http://myservice.bbb.aaa.com/"
> > xmlns:ns1="http://www.aaa.com/AaaOtherService"
> > attributeFormDefault="unqualified" elementFormDefault="unqualified"
> > targetNamespace="http://myservice.bbb.aaa.com/">
> >                   <xs:import
> > namespace="http://www.aaa.com/AaaOtherService"/>
> >                   <xs:element name="myList">
> >                         <xs:complexType>
> >                               <xs:sequence>
> >                                     <xs:element maxOccurs="unbounded"
> > name="items">
> >                                           <xs:complexType>
> >                                                 <xs:sequence>
> >                                                       <xs:element
> > ref="ns1:attributes"/>
> >                                                       <xs:element
> > minOccurs="0" ref="ns1:orderBy"/>
> >                                                 </xs:sequence>
> >                                                 <xs:attribute name="id"
> > type="xs:token"/>
> >                                                 <xs:attribute
> > name="createdBy" type="xs:token"/>
> >                                                 <xs:attribute
> > name="creationDate" type="xs:date"/>
> >                                           </xs:complexType>
> >                                     </xs:element>
> >                               </xs:sequence>
> >                         </xs:complexType>
> >                   </xs:element>
> > [...]
> >                   <xs:element name="getItemsResponse"
> > type="getItemsResponse"/>
> >                   <xs:complexType name="getItemsResponse">
> >                         <xs:sequence>
> >                               <xs:element minOccurs="0" ref="myList"/>
> >                         </xs:sequence>
> >                   </xs:complexType>
> > [...]
> >             </xs:schema>
> >       </wsdl:types>
> > [...]
> > </wsdl:definitions>
> >
> >
> >
> > I think it's a bit weird that it defines myList as a sequence of the
> > elements that form an Item, instead of a sequence of items.
> > Anyway I'm not sure why it does not work if it is mostly all generated
> > code.
> > Any ideas?
> >
> > Help or pointers very much appreciated!
> >
> >
> > Monica

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Jim Ma <em...@iona.com>.
Hi Monica,

You can change the log level to FINE (modify the log configuration file 
under ${CXF_HOME}/etc/logging.properties)
 to see if the OrderBy classes added to JAXB Context when you run 
java2wsdl tool .

Search "Classes known to this context:" in the log file to see  if this 
class is known to JAXB.

Regards

Jim


Monica Ferrero wrote:
>
> Hi Jim,
>
> Thank you for your reply.
>
> Item and OrderBy are generated by JAXB from a schema.xsd file.
> I have followed your advice to see if it behaves any different but I 
> still get the same error.
>
> The Item and therefore OrderBy classes belong to a different JAXB 
> context: com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?
>
> Thanks for your help,
>
> Monica
>
> Inactive hide details for Jim Ma ---07/01/2008 02:22:26---Hi ,Jim Ma 
> ---07/01/2008 02:22:26---Hi ,
>
>
> From: 	
> Jim Ma <em...@iona.com>
>
> To: 	
> cxf-user@incubator.apache.org
>
> Date: 	
> 07/01/2008 02:22
>
> Subject: 	
> Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 
> 'ns1:orderBy'
>
> ------------------------------------------------------------------------
>
>
>
> Hi ,
>
> From the error message , I think this is caused by the inner class
> OrderBy is not loaded into
> JAXB context . Can you modify this class as a outer class and try it
> again ?
> I will look it further to see if the JAXB can not load the inner static
> class .
>
> Thanks
>
> Jim
>
>
> Monica Ferrero wrote:
> > Hi!
> >
> > I'm getting this error:
> >
> > WSDLToJava Error : Thrown by JAXB : undefined element declaration
> > 'ns1:orderBy'
> >
> > when trying to generate java stubs from the wsdl.
> >
> >
> > This is my original service:
> >
> > @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> > public interface MyService {
> >
> >     [...]
> >
> >     @WebResult(name="MyList")
> >     @WebMethod
> >     MyList getItems( @WebParam(name="listId") int listId);
> >
> >     [...]
> > }
> >
> >
> > the MyList class:
> >
> > @XmlAccessorType(XmlAccessType.FIELD)
> > @XmlType(name = "", propOrder = {"items"})
> > @XmlRootElement(name = "myList")
> > public class MyList {
> >
> >     @XmlElement(required = true)
> >     private List<Item> items;
> >
> >     public List<Item> getItems() {
> >         if (items == null) {
> >             items = new ArrayList<Item>();
> >         }
> >         return items;
> >     }
> >
> >     public void setItems(List<Item> items) {
> >         this.items = items;
> >     }
> > }
> >
> >
> > The Item is a JAXB generated file from a schema:
> >
> >
> > @XmlAccessorType(XmlAccessType.FIELD)
> > @XmlType(name = "", propOrder = {
> >     "attributesPD",
> >     "orderBy"
> > })
> > @XmlRootElement(name = "item")
> > public class Item {
> >
> >     @XmlElement(name = "attributes", required = true)
> >     protected AttributesPD attributesPD;
> >     protected Item.OrderBy orderBy;
> >     @XmlAttribute
> >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> >     @XmlSchemaType(name = "token")
> >     protected String id;
> >     @XmlAttribute
> >     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> >     @XmlSchemaType(name = "token")
> >     protected String createdBy;
> >     @XmlAttribute
> >     @XmlSchemaType(name = "date")
> >     protected XMLGregorianCalendar creationDate;
> >
> >     public AttributesPD getAttributesPD() {
> >         return attributesPD;
> >     }
> >
> >     public void setAttributesPD(AttributesPD value) {
> >         this.attributesPD = value;
> >     }
> >
> >     public Item.OrderBy getOrderBy() {
> >         return orderBy;
> >     }
> >
> >     public void setOrderBy(Item.OrderBy value) {
> >         this.orderBy = value;
> >     }
> >
> >     public String getId() {
> >         return id;
> >     }
> >
> >     public void setId(String value) {
> >         this.id = value;
> >     }
> >
> >     public String getCreatedBy() {
> >         return createdBy;
> >     }
> >
> >     public void setCreatedBy(String value) {
> >         this.createdBy = value;
> >     }
> >
> >     public XMLGregorianCalendar getCreationDate() {
> >         return creationDate;
> >     }
> >
> >     public void setCreationDate(XMLGregorianCalendar value) {
> >         this.creationDate = value;
> >     }
> >
> >
> >     @XmlAccessorType(XmlAccessType.FIELD)
> >     @XmlType(name = "", propOrder = {
> >         "orderedAttributeRef"
> >     })
> >     public static class OrderBy {
> >
> >         @XmlElement(required = true)
> >         protected List<OrderedAttributeRefType> orderedAttributeRef;
> >
> >         public List<OrderedAttributeRefType> getOrderedAttributeRef() {
> >             if (orderedAttributeRef == null) {
> >                 orderedAttributeRef = new
> > ArrayList<OrderedAttributeRefType>();
> >             }
> >             return this.orderedAttributeRef;
> >         }
> >     }
> > }
> >
> >
> >
> > The wsdl generated by cxf:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > xmlns:tns="http://myservice.bbb.aaa.com/"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MyServiceImplService"
> > targetNamespace="http://myservice.bbb.aaa.com/">
> >       <wsdl:types>
> >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns:tns="http://www.aaa.com/AaaOtherService"
> > attributeFormDefault="unqualified" elementFormDefault="qualified"
> > targetNamespace="http://www.aaa.com/AaaOtherService">
> > [...]
> >                   <xs:element name="item">
> >                         <xs:complexType>
> >                               <xs:sequence>
> >                                     <xs:element ref="tns:attributes"/>
> >                                     <xs:element minOccurs="0"
> > name="orderBy">
> >                                           <xs:complexType>
> >                                                 <xs:sequence>
> >                                                       <xs:element
> > maxOccurs="unbounded" name="orderedAttributeRef"
> > type="tns:orderedAttributeRefType"/>
> >                                                 </xs:sequence>
> >                                           </xs:complexType>
> >                                     </xs:element>
> >                               </xs:sequence>
> >                               <xs:attribute name="id" type="xs:token"/>
> >                               <xs:attribute name="createdBy"
> > type="xs:token"/>
> >                               <xs:attribute name="creationDate"
> > type="xs:date"/>
> >                         </xs:complexType>
> >                   </xs:element>
> > [...]
> >             </xs:schema>
> >             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns="http://myservice.bbb.aaa.com/"
> > xmlns:ns1="http://www.aaa.com/AaaOtherService"
> > attributeFormDefault="unqualified" elementFormDefault="unqualified"
> > targetNamespace="http://myservice.bbb.aaa.com/">
> >                   <xs:import
> > namespace="http://www.aaa.com/AaaOtherService"/>
> >                   <xs:element name="myList">
> >                         <xs:complexType>
> >                               <xs:sequence>
> >                                     <xs:element maxOccurs="unbounded"
> > name="items">
> >                                           <xs:complexType>
> >                                                 <xs:sequence>
> >                                                       <xs:element
> > ref="ns1:attributes"/>
> >                                                       <xs:element
> > minOccurs="0" ref="ns1:orderBy"/>
> >                                                 </xs:sequence>
> >                                                 <xs:attribute name="id"
> > type="xs:token"/>
> >                                                 <xs:attribute
> > name="createdBy" type="xs:token"/>
> >                                                 <xs:attribute
> > name="creationDate" type="xs:date"/>
> >                                           </xs:complexType>
> >                                     </xs:element>
> >                               </xs:sequence>
> >                         </xs:complexType>
> >                   </xs:element>
> > [...]
> >                   <xs:element name="getItemsResponse"
> > type="getItemsResponse"/>
> >                   <xs:complexType name="getItemsResponse">
> >                         <xs:sequence>
> >                               <xs:element minOccurs="0" ref="myList"/>
> >                         </xs:sequence>
> >                   </xs:complexType>
> > [...]
> >             </xs:schema>
> >       </wsdl:types>
> > [...]
> > </wsdl:definitions>
> >
> >
> >
> > I think it's a bit weird that it defines myList as a sequence of the
> > elements that form an Item, instead of a sequence of items.
> > Anyway I'm not sure why it does not work if it is mostly all generated
> > code.
> > Any ideas?
> >
> > Help or pointers very much appreciated!
> >
> >
> > Monica

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Monica Ferrero <mf...@accelrys.com>.
Hi Jim,

Thank you for your reply.

Item and OrderBy are generated by JAXB from a schema.xsd file.
I have followed your advice to see if it behaves any different but I still
get the same error.

The Item and therefore OrderBy classes belong to a different JAXB context:
com.aaa.bbb.zzz.jaxb, but not sure if/how to indicate this?

Thanks for your help,

Monica


                                                                                                                              
  From:       Jim Ma <em...@iona.com>                                                                                           
                                                                                                                              
  To:         cxf-user@incubator.apache.org                                                                                   
                                                                                                                              
  Date:       07/01/2008 02:22                                                                                                
                                                                                                                              
  Subject:    Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'                             
                                                                                                                              





Hi ,

 From the error message , I think this is caused by the inner class
OrderBy is not loaded into
JAXB context . Can you modify this class as a outer class and try it
again ?
I will look it further to see if the JAXB can not load the inner static
class .

Thanks

Jim


Monica Ferrero wrote:
> Hi!
>
> I'm getting this error:
>
> WSDLToJava Error : Thrown by JAXB : undefined element declaration
> 'ns1:orderBy'
>
> when trying to generate java stubs from the wsdl.
>
>
> This is my original service:
>
> @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> public interface MyService {
>
>     [...]
>
>     @WebResult(name="MyList")
>     @WebMethod
>     MyList getItems( @WebParam(name="listId") int listId);
>
>     [...]
> }
>
>
> the MyList class:
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "", propOrder = {"items"})
> @XmlRootElement(name = "myList")
> public class MyList {
>
>     @XmlElement(required = true)
>     private List<Item> items;
>
>     public List<Item> getItems() {
>         if (items == null) {
>             items = new ArrayList<Item>();
>         }
>         return items;
>     }
>
>     public void setItems(List<Item> items) {
>         this.items = items;
>     }
> }
>
>
> The Item is a JAXB generated file from a schema:
>
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "", propOrder = {
>     "attributesPD",
>     "orderBy"
> })
> @XmlRootElement(name = "item")
> public class Item {
>
>     @XmlElement(name = "attributes", required = true)
>     protected AttributesPD attributesPD;
>     protected Item.OrderBy orderBy;
>     @XmlAttribute
>     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
>     @XmlSchemaType(name = "token")
>     protected String id;
>     @XmlAttribute
>     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
>     @XmlSchemaType(name = "token")
>     protected String createdBy;
>     @XmlAttribute
>     @XmlSchemaType(name = "date")
>     protected XMLGregorianCalendar creationDate;
>
>     public AttributesPD getAttributesPD() {
>         return attributesPD;
>     }
>
>     public void setAttributesPD(AttributesPD value) {
>         this.attributesPD = value;
>     }
>
>     public Item.OrderBy getOrderBy() {
>         return orderBy;
>     }
>
>     public void setOrderBy(Item.OrderBy value) {
>         this.orderBy = value;
>     }
>
>     public String getId() {
>         return id;
>     }
>
>     public void setId(String value) {
>         this.id = value;
>     }
>
>     public String getCreatedBy() {
>         return createdBy;
>     }
>
>     public void setCreatedBy(String value) {
>         this.createdBy = value;
>     }
>
>     public XMLGregorianCalendar getCreationDate() {
>         return creationDate;
>     }
>
>     public void setCreationDate(XMLGregorianCalendar value) {
>         this.creationDate = value;
>     }
>
>
>     @XmlAccessorType(XmlAccessType.FIELD)
>     @XmlType(name = "", propOrder = {
>         "orderedAttributeRef"
>     })
>     public static class OrderBy {
>
>         @XmlElement(required = true)
>         protected List<OrderedAttributeRefType> orderedAttributeRef;
>
>         public List<OrderedAttributeRefType> getOrderedAttributeRef() {
>             if (orderedAttributeRef == null) {
>                 orderedAttributeRef = new
> ArrayList<OrderedAttributeRefType>();
>             }
>             return this.orderedAttributeRef;
>         }
>     }
> }
>
>
>
> The wsdl generated by cxf:
>
> <?xml version="1.0" encoding="utf-8"?>
> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://myservice.bbb.aaa.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MyServiceImplService"
> targetNamespace="http://myservice.bbb.aaa.com/">
>       <wsdl:types>
>             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:tns="http://www.aaa.com/AaaOtherService"
> attributeFormDefault="unqualified" elementFormDefault="qualified"
> targetNamespace="http://www.aaa.com/AaaOtherService">
> [...]
>                   <xs:element name="item">
>                         <xs:complexType>
>                               <xs:sequence>
>                                     <xs:element ref="tns:attributes"/>
>                                     <xs:element minOccurs="0"
> name="orderBy">
>                                           <xs:complexType>
>                                                 <xs:sequence>
>                                                       <xs:element
> maxOccurs="unbounded" name="orderedAttributeRef"
> type="tns:orderedAttributeRefType"/>
>                                                 </xs:sequence>
>                                           </xs:complexType>
>                                     </xs:element>
>                               </xs:sequence>
>                               <xs:attribute name="id" type="xs:token"/>
>                               <xs:attribute name="createdBy"
> type="xs:token"/>
>                               <xs:attribute name="creationDate"
> type="xs:date"/>
>                         </xs:complexType>
>                   </xs:element>
> [...]
>             </xs:schema>
>             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://myservice.bbb.aaa.com/"
> xmlns:ns1="http://www.aaa.com/AaaOtherService"
> attributeFormDefault="unqualified" elementFormDefault="unqualified"
> targetNamespace="http://myservice.bbb.aaa.com/">
>                   <xs:import
> namespace="http://www.aaa.com/AaaOtherService"/>
>                   <xs:element name="myList">
>                         <xs:complexType>
>                               <xs:sequence>
>                                     <xs:element maxOccurs="unbounded"
> name="items">
>                                           <xs:complexType>
>                                                 <xs:sequence>
>                                                       <xs:element
> ref="ns1:attributes"/>
>                                                       <xs:element
> minOccurs="0" ref="ns1:orderBy"/>
>                                                 </xs:sequence>
>                                                 <xs:attribute name="id"
> type="xs:token"/>
>                                                 <xs:attribute
> name="createdBy" type="xs:token"/>
>                                                 <xs:attribute
> name="creationDate" type="xs:date"/>
>                                           </xs:complexType>
>                                     </xs:element>
>                               </xs:sequence>
>                         </xs:complexType>
>                   </xs:element>
> [...]
>                   <xs:element name="getItemsResponse"
> type="getItemsResponse"/>
>                   <xs:complexType name="getItemsResponse">
>                         <xs:sequence>
>                               <xs:element minOccurs="0" ref="myList"/>
>                         </xs:sequence>
>                   </xs:complexType>
> [...]
>             </xs:schema>
>       </wsdl:types>
> [...]
> </wsdl:definitions>
>
>
>
> I think it's a bit weird that it defines myList as a sequence of the
> elements that form an Item, instead of a sequence of items.
> Anyway I'm not sure why it does not work if it is mostly all generated
> code.
> Any ideas?
>
> Help or pointers very much appreciated!
>
>
> Monica

Re: WSDLToJava Error : Thrown by JAXB : undefined element declaration 'ns1:orderBy'

Posted by Jim Ma <em...@iona.com>.
Hi ,

 From the error message , I think this is caused by the inner class 
OrderBy is not loaded into
JAXB context . Can you modify this class as a outer class and try it 
again ?
I will look it further to see if the JAXB can not load the inner static 
class .

Thanks

Jim


Monica Ferrero wrote:
> Hi!
>
> I'm getting this error:
>
> WSDLToJava Error : Thrown by JAXB : undefined element declaration
> 'ns1:orderBy'
>
> when trying to generate java stubs from the wsdl.
>
>
> This is my original service:
>
> @WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
> public interface MyService {
>
>     [...]
>
>     @WebResult(name="MyList")
>     @WebMethod
>     MyList getItems( @WebParam(name="listId") int listId);
>
>     [...]
> }
>
>
> the MyList class:
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "", propOrder = {"items"})
> @XmlRootElement(name = "myList")
> public class MyList {
>
>     @XmlElement(required = true)
>     private List<Item> items;
>
>     public List<Item> getItems() {
>         if (items == null) {
>             items = new ArrayList<Item>();
>         }
>         return items;
>     }
>
>     public void setItems(List<Item> items) {
>         this.items = items;
>     }
> }
>
>
> The Item is a JAXB generated file from a schema:
>
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "", propOrder = {
>     "attributesPD",
>     "orderBy"
> })
> @XmlRootElement(name = "item")
> public class Item {
>
>     @XmlElement(name = "attributes", required = true)
>     protected AttributesPD attributesPD;
>     protected Item.OrderBy orderBy;
>     @XmlAttribute
>     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
>     @XmlSchemaType(name = "token")
>     protected String id;
>     @XmlAttribute
>     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
>     @XmlSchemaType(name = "token")
>     protected String createdBy;
>     @XmlAttribute
>     @XmlSchemaType(name = "date")
>     protected XMLGregorianCalendar creationDate;
>
>     public AttributesPD getAttributesPD() {
>         return attributesPD;
>     }
>
>     public void setAttributesPD(AttributesPD value) {
>         this.attributesPD = value;
>     }
>
>     public Item.OrderBy getOrderBy() {
>         return orderBy;
>     }
>
>     public void setOrderBy(Item.OrderBy value) {
>         this.orderBy = value;
>     }
>
>     public String getId() {
>         return id;
>     }
>
>     public void setId(String value) {
>         this.id = value;
>     }
>
>     public String getCreatedBy() {
>         return createdBy;
>     }
>
>     public void setCreatedBy(String value) {
>         this.createdBy = value;
>     }
>
>     public XMLGregorianCalendar getCreationDate() {
>         return creationDate;
>     }
>
>     public void setCreationDate(XMLGregorianCalendar value) {
>         this.creationDate = value;
>     }
>
>
>     @XmlAccessorType(XmlAccessType.FIELD)
>     @XmlType(name = "", propOrder = {
>         "orderedAttributeRef"
>     })
>     public static class OrderBy {
>
>         @XmlElement(required = true)
>         protected List<OrderedAttributeRefType> orderedAttributeRef;
>
>         public List<OrderedAttributeRefType> getOrderedAttributeRef() {
>             if (orderedAttributeRef == null) {
>                 orderedAttributeRef = new
> ArrayList<OrderedAttributeRefType>();
>             }
>             return this.orderedAttributeRef;
>         }
>     }
> }
>
>
>
> The wsdl generated by cxf:
>
> <?xml version="1.0" encoding="utf-8"?>
> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://myservice.bbb.aaa.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MyServiceImplService"
> targetNamespace="http://myservice.bbb.aaa.com/">
>       <wsdl:types>
>             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:tns="http://www.aaa.com/AaaOtherService"
> attributeFormDefault="unqualified" elementFormDefault="qualified"
> targetNamespace="http://www.aaa.com/AaaOtherService">
> [...]
>                   <xs:element name="item">
>                         <xs:complexType>
>                               <xs:sequence>
>                                     <xs:element ref="tns:attributes"/>
>                                     <xs:element minOccurs="0"
> name="orderBy">
>                                           <xs:complexType>
>                                                 <xs:sequence>
>                                                       <xs:element
> maxOccurs="unbounded" name="orderedAttributeRef"
> type="tns:orderedAttributeRefType"/>
>                                                 </xs:sequence>
>                                           </xs:complexType>
>                                     </xs:element>
>                               </xs:sequence>
>                               <xs:attribute name="id" type="xs:token"/>
>                               <xs:attribute name="createdBy"
> type="xs:token"/>
>                               <xs:attribute name="creationDate"
> type="xs:date"/>
>                         </xs:complexType>
>                   </xs:element>
> [...]
>             </xs:schema>
>             <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://myservice.bbb.aaa.com/"
> xmlns:ns1="http://www.aaa.com/AaaOtherService"
> attributeFormDefault="unqualified" elementFormDefault="unqualified"
> targetNamespace="http://myservice.bbb.aaa.com/">
>                   <xs:import
> namespace="http://www.aaa.com/AaaOtherService"/>
>                   <xs:element name="myList">
>                         <xs:complexType>
>                               <xs:sequence>
>                                     <xs:element maxOccurs="unbounded"
> name="items">
>                                           <xs:complexType>
>                                                 <xs:sequence>
>                                                       <xs:element
> ref="ns1:attributes"/>
>                                                       <xs:element
> minOccurs="0" ref="ns1:orderBy"/>
>                                                 </xs:sequence>
>                                                 <xs:attribute name="id"
> type="xs:token"/>
>                                                 <xs:attribute
> name="createdBy" type="xs:token"/>
>                                                 <xs:attribute
> name="creationDate" type="xs:date"/>
>                                           </xs:complexType>
>                                     </xs:element>
>                               </xs:sequence>
>                         </xs:complexType>
>                   </xs:element>
> [...]
>                   <xs:element name="getItemsResponse"
> type="getItemsResponse"/>
>                   <xs:complexType name="getItemsResponse">
>                         <xs:sequence>
>                               <xs:element minOccurs="0" ref="myList"/>
>                         </xs:sequence>
>                   </xs:complexType>
> [...]
>             </xs:schema>
>       </wsdl:types>
> [...]
> </wsdl:definitions>
>
>
>
> I think it's a bit weird that it defines myList as a sequence of the
> elements that form an Item, instead of a sequence of items.
> Anyway I'm not sure why it does not work if it is mostly all generated
> code.
> Any ideas?
>
> Help or pointers very much appreciated!
>
>
> MonicaAccelrys Limited (http://www.accelrys.com) 
> Registered office: 334 Cambridge Science Park, Cambridge, CB4 0WN, UK 
> Registered in England: 2326316   
>