Thanks Dennis! That fixed two of the problems I was having, and I just got my first test case to run. I am slowly starting to understand some of these subtleties.
I want to complement you on JiBX, and on having good documentation to help newbies like me get started. I discovered JiBX yesterday afternoon, and now have my first test case working. I've been floundering for the last week using Castor and JAXB. Castor had too many limitations, and hand coding with JAXB was too much work and complicated. So far JiBX looks to provide the ease of Castor with a lot more power and flexibility. Does JiBX stand for something? How do you pronounce it (Ji-BX, JiB-X, ???) Thanks again, Scott... -----Original Message----- From: Dennis Sosnoski [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 13, 2004 3:08 PM To: [EMAIL PROTECTED]; Stevenson, Scott W Subject: Re: [jibx-devs] Recursive collections with defined types Hi Scott, I'm redirecting this response to the users list, since it's the type of question that I like to have archived there. You certainly shouldn't be getting this failure in any case, but I see the likely cause of the problem. This goes back to the definition of the item-type attribute on the <collection>: "If this attribute is used it must be the fully-qualified class name for items contained in the collection, where the class has an mapping defined at an enclosing level." There's no mapping defined for java.lang.String - there's a default serialization/deserialization, but that's something that just works with text while a mapping needs to work with elements. Subtle distinction, I know, and it should be handled by giving you an explicit message that says "No mapping defined for java.lang.String" rather than causing a failure in code generation. To handle this properly you need to define how you want the collection of strings handled, something like: <collection field="editors"> <value name="editor"/> </collection> That tells JiBX to represent the individual string values from the collection as <editor>editor name text</editor>, which is what I suspect you want. - Dennis Stevenson, Scott W wrote: >Hello, > >I am new to jibx. So far it looks awesome, but I am getting an exception when >generating the bindings that I think may be an error. I have classes held in >collections recursively. As long as I done specify the item-type attribute it works >fine, but if I specify item-type for anything I get the following exception when >generating the bindings. Has anyone seen this before? > >Thanks, > >Scott... > > > <mapping name="ClassInfo" class="boeing.engineering.leangi3.metadata.ClassInfo"> > <value name="class-name" field="className"/> > <value name="display-name" field="displayName"/> > <value name="icon-file" field="iconFile"/> > <value name="default-editor" field="defaultEditor"/> > <value name="default-viewer" field="defaultViewer"/> > <value name="automatic-viewer" field="automaticViewer"/> > <value name="post-edit-callback" field="postEditCallback"/> > <collection field="editors" item-type="java.lang.String"/> // FAILS > <collection field="viewers" item-type="java.lang.String"/> > <collection field="propertyDescriptors" > item-type="boeing.engineering.leangi3.metadata.PropertyInfo"/> > <collection field="methodDescriptors" > item-type="boeing.engineering.leangi3.metadata.MethodInfo"/> > </mapping> > > <mapping name="ClassInfo" class="boeing.engineering.leangi3.metadata.ClassInfo"> > <value name="class-name" field="className"/> > <value name="display-name" field="displayName"/> > <value name="icon-file" field="iconFile"/> > <value name="default-editor" field="defaultEditor"/> > <value name="default-viewer" field="defaultViewer"/> > <value name="automatic-viewer" field="automaticViewer"/> > <value name="post-edit-callback" field="postEditCallback"/> > <collection field="editors"/> // WORKS > <collection field="viewers"/> > <collection field="propertyDescriptors"/> > <collection field="methodDescriptors"/> > </mapping> > > >Stack trace: > >U:\cvsProjects\ltk\build>java -jar u:\javastuff\jibx\lib\jibx-bind.jar binding.x >ml >Exception in thread "main" java.lang.IllegalStateException: Stack size mismatch >on branch > in method boeing.engineering.leangi3.metadata.JiBX_MungeAdapter.JiBX_binding_ma >rshal > generated by [EMAIL PROTECTED] > from stack: > 0: org.jibx.runtime.impl.MarshallingContext > 1: java.lang.String > to stack: > 0: org.jibx.runtime.impl.MarshallingContext > > at org.jibx.binding.classes.BranchWrapper.setTarget(BranchWrapper.java:1 >84) > at org.jibx.binding.classes.BranchWrapper.setTarget(BranchWrapper.java:2 >01) > at org.jibx.binding.def.NestedCollection.genContentMarshal(NestedCollect >ion.java:208) > at org.jibx.binding.def.ObjectBinding.genMarshalContentCall(ObjectBindin >g.java:668) > at org.jibx.binding.def.ObjectBinding.genContentMarshal(ObjectBinding.ja >va:728) > at org.jibx.binding.def.ComponentProperty.genContentMarshal(ComponentPro >perty.java:241) > at org.jibx.binding.def.ElementWrapper.genContentMarshal(ElementWrapper. >java:380) > at org.jibx.binding.def.NestedStructure.genContentMarshal(NestedStructur >e.java:190) > at org.jibx.binding.def.ObjectBinding.genMarshalContentCall(ObjectBindin >g.java:668) > at org.jibx.binding.def.ObjectBinding.genContentMarshal(ObjectBinding.ja >va:728) > at org.jibx.binding.def.ElementWrapper.genContentMarshal(ElementWrapper. >java:380) > at org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinition >.java:560) > at org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContext >.java:593) > at org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinition >.java:562) > at org.jibx.binding.Compile.compile(Compile.java:299) > at org.jibx.binding.Compile.main(Compile.java:367) > > >------------------------------------------------------- >This SF.Net email sponsored by Black Hat Briefings & Training. >Attend Black Hat Briefings & Training, Las Vegas July 24-29 - >digital self defense, top technical experts, no vendor pitches, >unmatched networking opportunities. Visit www.blackhat.com >_______________________________________________ >jibx-devs mailing list >[EMAIL PROTECTED] >https://lists.sourceforge.net/lists/listinfo/jibx-devs > > > > ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users
