Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random failure on globalBindings customization #687

Closed
Tomas-Kraus opened this issue Sep 12, 2009 · 18 comments
Closed

random failure on globalBindings customization #687

Tomas-Kraus opened this issue Sep 12, 2009 · 18 comments

Comments

@Tomas-Kraus
Copy link
Member

When a (anonymous) schema document is (syntactically) included in more than one
other schema document, global bindings specified in a seperate binding document
can cause a failure:

only one globalBindings customization is allowed in a whole compilation
(related to above) but one is already given at this location

Moving the same set of schema files to another location can change the
behaviour.

Environment

Operating System: All
Platform: All

Affected Versions

[2.2]

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Reported by tdesmedt

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Issue-Links:
is cloned by
JAXB-1124

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Was assigned to snajper

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
tdesmedt said:
Created an attachment (id=328)
eclipse project with example schema files and test class

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: test-xjc-687.zip
Attached By: tdesmedt

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
tdesmedt said:
I attached a test case that illustrates the problem and checks my analysis. This
is was a very nasty bug to handle, because only some of our developers, sometime
had the problem.

the method

com.sun.tools.xjc.reader.internalizer.DOMForest.getOneDocument()

is used by

com.sun.tools.xjc.reader.internalizer.Internalizer [line: 311]

to (randomly) choose a schema document that gets to carry the xjc globalBinding
settings.
Because the documents are internally stored under a HashMap by systemid, the
choice
of the documents depends on the full path of the actual resource.

If the chosen document is not actually defining a namespace, but happens to be
(syntactically)
included in more than one other schema document, the including documents will
inherit the globalBinding settings.
The code in

com.sun.tools.xjc.reader.xmlschema.BGMBuilder.promoteGlobalBIndings [line:
200]

will report failure because it finds more than one schemas with globalBinding
annotations.

Suggestions for remediation:

  • do not assign global bindings from a binding document to a schema document,
    but leave it in the binding document. The internalizer could assign the
    global bindings an
    empty schema document (with a specific reserved target namespace).
  • alternative: check duplicate globalBindings for compatiblity.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
snajper said:
Thanks for submission, however global scope is at the top of the scope
hierarchy. It covers all the schema elements in the source schema and
(recursively) any schemas that are included or imported by the source schema.
Probably best would be to add a property so that you may choose to ignore global
bindings from underlying schemas.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
tdesmedt said:
Reset issue type to defect. I'm aware of the semantics of global scope. The
input documents (see example) declare the global scope binding only once (in the
.xjb file – it makes no difference wether this globalBindings is tied to a
schemalocation or not)

The bug is that xjc assigns these global scope binding to a random schema
document. If this document is included in other schema definition files, you get
fatal errors.

I deem this to be an important defect because:

  • the use case of including an anonymous schema that declares some
    syntactically reusable definitions seems common to me.
  • it is difficult to reproduce, because of the random choice

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
snajper said:
Oh, I see, I get it. Thanks a lot for an excellent testcase and evaluation. Need to think of what is the best
way to fix this.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
snajper said:
Fixed in trunk and all branches:
https://jaxb2-sources.dev.java.net/source/browse/jaxb2-sources/jaxb-
ri/xjc/src/com/sun/tools/xjc/reader/xmlschema/BGMBuilder.java?r1=1.24&r2=1.25
https://jaxb2-sources.dev.java.net/source/browse/jaxb2-sources/jaxb-
ri/xjc/src/com/sun/tools/xjc/reader/xmlschema/bindinfo/BIGlobalBinding.java?r1=1.31&r2=1.32

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Marked as fixed on Monday, September 28th 2009, 9:31:51 pm

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
niels.bertram said:
I am still having the exact issue at random in 2.2.10 branch. One project builds perfectly fine, but if I copy it to a different folder location it sometimes spews the following error over and over again until it dies. No further clue as to what may have caused the problem but only referring to the exact same location. Perhaps a regression or simply problem not fixed?

[ERROR] Error while parsing schema(s).Location [ file:/C:/dev/workspaces/model/someproject/src/main/resources/global.jaxb.xml{7,83}].
com.sun.istack.SAXParseException2; systemId: file:/C:/dev/workspaces/model/someproject/src/main/resources/global.jaxb.xml; lineNumber: 7; columnNumber: 83; only one globalBindings customization is allowed in a whole compilation
        at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:86)
        at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:84)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.promoteGlobalBindings(BGMBuilder.java:215)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:171)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:117)
        at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:425)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:54)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:44)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:29)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:364)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:161)

[ERROR] Error while parsing schema(s).Location [ file:/C:/dev/workspaces/model/someproject/src/main/resources/global.jaxb.xml{7,83}].
com.sun.istack.SAXParseException2; systemId: file:/C:/dev/workspaces/model/someproject/src/main/resources/global.jaxb.xml; lineNumber: 7; columnNumber: 83; (related to above) but one is already given at this location
        at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:86)
        at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error(ErrorReporter.java:84)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.promoteGlobalBindings(BGMBuilder.java:217)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.<init>(BGMBuilder.java:171)
        at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:117)
        at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:425)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:54)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:44)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:29)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:364)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:161)

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
rodrigo.ijk said:
The problem still occurs here using 2.2.7.
This is the content of my bindings:

<jxb:globalBindings>
	<xjc:simple/>
	<jxb:serializable uid="1"/>
</jxb:globalBindings>

By removing the serializable part I could run the build successfully:

<jxb:globalBindings>
	<xjc:simple/>
</jxb:globalBindings>

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
suboptimal said:
In method

BIGGlobalBindung.isEqual(BIGGlobalBindung b)

the check for equality fails on the serializable property.
It is done as

this.serializable == b.serializable

but it should rather check the uid property of the BISerializable object

this.serializable.uid.equals(b.serializeable.uid) // null checks are omitted here for simplicity

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
struberg said:
We suffered from the same bug in 2.2.11.
Is there any chance this not only gets fixed for 2.1.x but also for 2.2.x?

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
bdrx312 said:
We just experienced this bug in xjc version 2.2.8.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAXB-687

@Tomas-Kraus
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants