users@jaxb.java.net

[JAXB-1.x] Error while setting <jaxb:javaType> to 'java.lang.Long' for element of type='xsd:ID'

From: Kostis Anagnostopoulos <ankostis_at_gmail.com>
Date: Wed, 16 Aug 2006 13:27:04 +0300

Hi,

I'm having a problem using JAXB-1.x, version 1.0.6's <jaxb:javaType>
customization:

I have a complex type, for instance, like this:

  <xsd:complexType name="dog">
    <xsd:sequence>
      <xsd:element name="dogId" type="xsd:ID" />
      ....
    </xsd:sequence>
  </xsd:complexType>

I need the dogId to be Long, so i tried to define both inside
<jaxb:globalBindings> and directly, like that (only the global shown):

    <jaxb:globalBindings>
      <jaxb:javaType name="java.lang.Long" xmlType="xsd:IDREF" />
      <jaxb:javaType name="java.lang.Long" xmlType="xsd:ID" />
    </jaxb:globalBindings>


But then, then XJC throws:

com.sun.xml.bind.JAXBAssertionError
        at com.sun.tools.xjc.grammar.xducer.CastTranducer.<init>(CastTranducer.java:52)
        at com.sun.tools.xjc.reader.xmlschema.bindinfo.MagicTransducer.create(MagicTransducer.java:77)
        at com.sun.tools.xjc.grammar.xducer.DelayedTransducer.update(DelayedTransducer.java:60)
        at com.sun.tools.xjc.grammar.xducer.DelayedTransducer.getReturnType(DelayedTransducer.java:64)
        at com.sun.tools.xjc.grammar.xducer.TransducerDecorator.getReturnType(TransducerDecorator.java:50)
        at com.sun.tools.xjc.grammar.PrimitiveItem.getType(PrimitiveItem.java:49)
        at com.sun.tools.xjc.grammar.FieldItem.getType(FieldItem.java:230)
        at com.sun.tools.xjc.reader.annotator.RelationNormalizer.normalize(RelationNormalizer.java:173)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:154)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:99)
        at com.sun.tools.xjc.GrammarLoader.annotateXMLSchema(GrammarLoader.java:423)
        at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:142)
        at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:91)
        at org.jvnet.jaxb1.maven2.AbstractXJC1Mojo.runXJC(AbstractXJC1Mojo.java:427)
        at org.jvnet.jaxb1.maven2.AbstractXJC1Mojo.executeImp(AbstractXJC1Mojo.java:118)
        at org.jvnet.hyperjaxb2.maven2.HJ2Mojo.execute(HJ2Mojo.java:430)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

* How can i workaround it?

* Should id file an issue with it ?

FYI, i'm using Hyperjaxb2, and i need to map the schema to a
pre-existent database. So, if i cannot change the type, i won't be
able to use ID/IDREFi to avoid cyclic relationships.


Any Help Appreciated,
  Kostis