[ 
http://jira.codehaus.org/browse/JIBX-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_103097
 ] 

Ingo Wilken commented on JIBX-169:
----------------------------------

I have the same problem, but I'm not restricted to marshalling.

Basically, I have a small 'control' file containing some metadata and a related 
(possibly very large)
'data' file, both using the same element name.  Most important, the control 
file contains the path
to the data file.

<binding value-style="attribute">
<mapping name="foo" class="FooControl">
        <value name="path" field="pathToData"/>
</mapping>

<mapping name="foo" class="FooData">
        <!-- lots of stuff here -->
</mapping>
</binding>


A server application feeds control files to my program, and using the contained 
path my program knows where to
find the real data.  So when I read/write an XML file, I know exactly what 
class to unmarshal to/marshal from, and
simply use two IBindingFactory instances to read and write both kind of files:
    IBindingFactory controlFactory = 
BindingDirectory.getFactory(FooControl.class);
    IBindingFactory dataFactory = BindingDirectory.getFactory(FooData.class);


This works great with JiBX 1.0.2.

1.1.3 complains:

Error: Duplicate mapping name not allowed for unmarshalling; on mapping element 
at (line 6, col 37, in binding.xml)
Error running binding compiler
org.jibx.runtime.JiBXException: Binding binding.xml is unusable because of 
validation errors
        at org.jibx.binding.Utility.loadBinding(Utility.java:346)
        at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
        at org.jibx.binding.Compile.compile(Compile.java:296)
        at org.jibx.binding.Compile.main(Compile.java:385)

1.1.5 fails with the NullPointerException from the original bug report.


> Binding compile of two classes with same element name fails with NPE in 
> NameAttributes.equals although output only
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: JIBX-169
>                 URL: http://jira.codehaus.org/browse/JIBX-169
>             Project: JiBX
>          Issue Type: Bug
>          Components: core
>    Affects Versions: JiBX 1.1.5
>         Environment: Windows XP, Java 1.5.0_10
>            Reporter: Andrew Harris
>         Attachments: outboundBindIssue.zip
>
>
> Just tried upgrading to JIBX 1.1.5 from 1.0.1 and hit this problem.  
> I have a binding that is direction="output" and I have three hibernate 
> classes that map to the same element name.
> When I try to bind compile, there is an exception thrown because the equals 
> method in NameAttributes, when the name is the same, resorts to the namespace 
> to distinguish the two objects, but the namespace has not been set on either 
> of them.
>      [java] Error running binding compiler
>      [java] java.lang.NullPointerException
>      [java]     at 
> org.jibx.binding.model.NameAttributes.equals(NameAttributes.java:184)
>      [java]     at java.util.HashMap.eq(HashMap.java:299)
>      [java]     at java.util.HashMap.containsKey(HashMap.java:381)
>      [java]     at 
> org.jibx.binding.model.DefinitionContext.addMappedName(DefinitionContext.java:551)
>      [java]     at 
> org.jibx.binding.model.RegistrationVisitor.visit(RegistrationVisitor.java:183)
>      [java]     at 
> org.jibx.binding.model.TreeContext.tourTree(TreeContext.java:171)
>      [java]     at 
> org.jibx.binding.model.TreeContext.tourTree(TreeContext.java:232)
>      [java]     at 
> org.jibx.binding.model.RegistrationVisitor.visitTree(RegistrationVisitor.java:96)
>      [java]     at 
> org.jibx.binding.model.BindingElement.runValidation(BindingElement.java:755)
>      [java]     at 
> org.jibx.binding.model.BindingElement.validateBinding(BindingElement.java:819)
>      [java]     at org.jibx.binding.Utility.validateBinding(Utility.java:228)
>      [java]     at org.jibx.binding.Utility.loadBinding(Utility.java:269)
>      [java]     at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
>      [java]     at org.jibx.binding.Compile.compile(Compile.java:296)
>      [java]     at org.jibx.binding.Compile.main(Compile.java:385)
> I understand that it is not possible to unmarshal an incoming element to one 
> of multiple classes, since there is not enough information to figure out 
> which class to instantiate.  But it would be useful to be able to marshal 
> multiple classes to the same element name.
> The attached code has a target outputIssue that causes the exception

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to