users@jaxb.java.net

Re: [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: Mon, 21 Aug 2006 12:16:51 +0300

On 8/16/06, Kostis Anagnostopoulos <ankostis_at_gmail.com> wrote:
> 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>

I then tried to set 'parse' and 'print' methods and no exception this
time, but the XJC screamed something like this (not the eaxct error,
don't just search it up in the codebase):
    [ERROR] the <xjc:idSymbolSpace> was not used!

I think the <xjc:idSymbolSpace> should support types other than
String. (Dbs use numeric ids, so it is a common requirement).

Regards
  Kostis


>
>
> 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
>