Hi guys,

I wanted to answer my own question here in case anyone else makes the same
mistake.

I was basically mixing up tutorials and at the time I didn't understand the
real difference between JAXB and JiBX, and I was mistakenly trying to
unmarshal data using JAXB with JiBX generated classes, which, well, isn't
gonna work.

So, should anyone else see this error in the future, don't make the same
mistake.

The working JiBX unmarshalling code looks more like:

// Create the JiBX unmarshalling object
IBindingFactory jc =
BindingDirectory.getFactory(org.oma.protocols.mlp.svc_init.SvcInit.class);
IUnmarshallingContext unmarshaller = jc.createUnmarshallingContext();

// Unmarshal directly from the POST input stream
org.oma.protocols.mlp.svc_init.SvcInit svcInit =
(org.oma.protocols.mlp.svc_init.SvcInit)unmarshaller.unmarshalDocument(requestStream,
"UTF-8");

Cheers,
Andrew

On Fri, Mar 20, 2015 at 4:14 PM, Andrew Eross <er...@locatrix.com> wrote:

> Hi guys,
>
> I've been fighting with this error, and I've researched it on Google, but
> I can't really find a solution, and it's driving me a bit nuts.
>
> My XSD is attached.
>
> The CodeGen process using this XSD works just fine and generates the java
> classes, binding.xml, etc, no worries. I'm doing this via maven with the
> package "org.oma.protocols.mlp" assigned to it.
>
> Then I'm trying to perform an unmarshal on some raw XML data like this
> sample:
>
> <?xml version="1.0" encoding="UTF-8"?>
>  <!DOCTYPE svc_init SYSTEM "MLP_SVC_INIT_310.DTD">
>  <svc_init>
>    <hdr>
>      <client>
>        <id>USERNAME</id>
>        <pwd>PASSWORD</pwd>
>        <serviceid>SERVICEID</serviceid>
>      </client>
>      <initiator><msid type="MSISDN">MSISDN OF REQUESTING
> USER</msid></initiator>
>    </hdr>
>    <slir>
>      <msids>
>        <msid type="MSISDN">MSISDN OF TARGET</msid>
>      </msids>
>      <eqop>
>         <resp_timer>15</resp_timer>
>      </eqop>
>    </slir>
>  </svc_init>
>
> My unmarshal code looks like:
>
> JAXBContext jaxbContext =
> JAXBContext.newInstance(org.oma.protocols.mlp.SvcInit.class);
> Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
>
> StringReader reader = new StringReader(postString);
> org.oma.protocols.mlp.SvcInit svcinit = (org.oma.protocols.mlp.SvcInit)
> unmarshaller.unmarshal(reader);
>
> This then produces a whole bunch of run-time errors like these:
>
> 12:49:12,160 ERROR [STDERR] (pool-25-thread-1)
> com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 9 counts of
> IllegalAnnotationExceptions
> Two classes have the same XML type name "type". Use @XmlType.name and
> @XmlType.namespace to assign different names to them.
>         this problem is related to the following location:
>                 at org.oma.protocols.mlp.RespReq$Type
>                 at public org.oma.protocols.mlp.RespReq$Type
> org.oma.protocols.mlp.RespReq.getType()
>                 at org.oma.protocols.mlp.RespReq
>                 at public org.oma.protocols.mlp.RespReq
> org.oma.protocols.mlp.Eqop.getRespReq()
>                 at org.oma.protocols.mlp.Eqop
>                 at public org.oma.protocols.mlp.Eqop
> org.oma.protocols.mlp.EmeLir.getEqop()
>                 at org.oma.protocols.mlp.EmeLir
>                 at public org.oma.protocols.mlp.EmeLir
> org.oma.protocols.mlp.SvcInit.getEmeLir()
>                 at org.oma.protocols.mlp.SvcInit
>         this problem is related to the following location:
>                 at org.oma.protocols.mlp.LocType$Type
>                 at public org.oma.protocols.mlp.LocType$Type
> org.oma.protocols.mlp.LocType.getType()
>                 at org.oma.protocols.mlp.LocType
>                 at public org.oma.protocols.mlp.LocType
> org.oma.protocols.mlp.EmeLir.getLocType()
>                 at org.oma.protocols.mlp.EmeLir
>                 at public org.oma.protocols.mlp.EmeLir
> org.oma.protocols.mlp.SvcInit.getEmeLir()
>                 at org.oma.protocols.mlp.SvcInit
>
> There's a pile more of similar errors as well.
>
> Is there a real "solution" for this? What am I doing wrong? Am I supposed
> to manually go through the generated classes every time and add these
> @XmlType tags? I'm not totally clear on what type of tag of that sort I
> could add that wouldn't break my system?
>
> Any help is much appreciated!
>
> Thank you,
> Andrew
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to