users@jaxb.java.net

JAXB marshal error: <my.genpkg.class> nor any of its super class is known to this context

From: ddoTwo <ddodini_at_gmail.com>
Date: Fri, 1 Oct 2010 09:26:07 -0700 (PDT)

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.genpkg.class> 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.pkg.name}"/>
      <arg value="${htng.schema.dir}/mySchema.xsd"/>
    </exec>
  </target>

The code to do the marshalling:

    private void marshallXml(MyRootObj rootObj) {
        try {
            JAXBContext jc = JAXBContext.newInstance("my.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.