The error message says that you have an element
<OTA_HotelResNotifRQ>
in your XML data file where only <OTA_HotelResNotifRS> or
<TPA_Extensions<
http://www.opentravel.org/OTA/2003/05%7DTPA_Extensions>>
is
permitted. Compare the XML data with your XML schema.
-W
On 1 October 2010 23:37, ddoTwo <ddodini_at_gmail.com> wrote:
>
> Hi Wolfgang,
>
> You are right. I had typos from changing my package names in my post, from
> changing my package names. I have amended them in my code fragments below.
> The first thing I checked was that my package names and paths were correct.
> They are all matching.
>
> For what it is worth, I used XML-Spy to generate the xml from my schema.
> Then I attempted to unmarshal from xml to Java using JAXB. The context
> loaded, but I got errors using the unmarshall.
>
> I'll provide them in case it helps.
>
> Unmarshal exception:
>
> [java] javax.xml.bind.UnmarshalException: unexpected element
> (uri:"http://www.opentravel.o
> rg/OTA/2003/05", local:"OTA_HotelResNotifRQ"). Expected elements are
> <{http://www.opentravel.or
> g/OTA/2003/05}OTA_HotelResNotifRS>,<{
> http://www.opentravel.org/OTA/2003/05}TPA_Extensions<http://www.opentravel.org/OTA/2003/05%7DTPA_Extensions>
> >
> [java] at
>
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(Un
> marshallingContext.java:642)
>
> The .xsd declaration for my object OTA_HotelResNotifRQ is:
>
> "<?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns="http://www.opentravel.org/OTA/2003/05"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.opentravel.org/OTA/2003/05"
> elementFormDefault="qualified" version="5.000" id="OTA2009A">"
>
> Is this all related to schema references?
>
>
> Wolfgang Laun-2 wrote:
> >
> > The information you provide is insufficient for diagnosis. The error
> > message
> > refers to a class "my.genpkg.class", which is impossible; you have
> > JAXBContext.newInstance("my.pkg.name");
> > where the package name in JAXBContext.newInstance does not refer to the
> > package of that class.
> >
> > -W
> >
> >
> > On 1 October 2010 18:26, ddoTwo <ddodini_at_gmail.com> wrote:
> >
> >>
> >> Hi,
> >>
> >> I am do a poc with JAXB. I have successfully compiled my java objects
> >> from
> >> my xsd. There are 365 Java objects that have been generated.
> >>
> >> The next step is to populate my Java object in memory and then marshal
> it
> >> to
> >> xml. (From there I can test unmarshalling). When I do this I get the
> >> following exception:
> >>
> >> "javax.xml.bind. JAXBException <my.gen-src.pkg.name> nor any of its
> super
> >> class
> >> is known to this context"
> >>
> >> I am using Java6 and pointing to the
> >> com.sun.xml.bind.v2.runtime.JAXBContextImpl. The ObjectFactory for my
> >> generated root context was created along with the classes representing
> >> the
> >> types in the xsd(s).
> >>
> >> I am pointing to the package where the ObjectFactory and my generated
> >> classes. I am not sure what is going on. I am using ant. I include the
> >> code
> >> below where I generated my classes, (in Ant), and my marshalling code.
> >>
> >> Any tips would be greatly appreciated.
> >>
> >> The generation ant code:
> >> <target name="bindOtaSchema">
> >> <exec executable="${myEnv.JAVA_HOME}/bin/xjc.exe">
> >> <arg value="-d"/>
> >> <arg value="${src.dir}"/>
> >> <arg value="-p"/>
> >> <arg value="${my.gen-src.pkg.name}"/>
> >> <arg value="${my.schema.dir}/mySchema.xsd"/>
> >> </exec>
> >> </target>
> >>
> >> The code to do the marshalling:
> >>
> >> private void marshallXml(MyRootObj rootObj) {
> >> try {
> >> JAXBContext jc =
> >> JAXBContext.newInstance("my.gen-src.pkg.name");
> >> Marshaller m = jc.createMarshaller();
> >> m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
> >> Boolean.TRUE);
> >> m.marshal(rootObj, System.out);
> >> } catch (JAXBException jaxbe) {
> >> jaxbe.printStackTrace();
> >> }
> >> }
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/JAXB-marshal-error%3A-%3Cmy.genpkg.class%3E-nor-any-of-its-super-class-is-known-to-this-context-tp29859106p29859106.html
> >> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> >> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/JAXB-marshal-error%3A-%3Cmy.genpkg.class%3E-nor-any-of-its-super-class-is-known-to-this-context-tp29859106p29860782.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>