Re: [jibx-users] collection Set JDK 1.4.2

2006-08-21 Thread Dennis Sosnoski
Hi Morgan,

Glad you got through this okay. Instead of using the factory method, you 
can probably use the new (as of 1.1) create-type attribute on the 
collection (see 
http://jibx.sourceforge.net/details/binding-attributes.html#object).

  - Dennis

Dennis M. Sosnoski
SOA, Web Services, and XML
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-296-6194 - Wellington, NZ +64-4-298-6117



Morgan Rachell wrote:
 I got it to work. I needed to give the collection a factory method for 
 HashSets.
 I removed the item-type and type attributes of collection and added the
 factory. I also added a structure that specifies the types. One of the samples
 that JiBX ships with (example 8 or 9) did it this way.

 My old mapping was:

  
  binding forwards=false value-style=attribute
mapping class=FlockTest name=flock-test
  []
   collection field=flockTestDetails 
   item-type=FlockTestDetail 
   type=java.util.HashSet
   usage=optional/
  /mapping

 And my new mapping is: 

 binding forwards=false value-style=attribute
   mapping class=FlockTest name=flock-test
   []
   collection field=flockTestDetails 
   factory=FlockTestDetail.HashSetFactory 
   structure 
   type=FlockTestDetail 
   usage=optional/
   /collection
   /mapping
 /binding

 I have to say that I am very happy with the ease with which I was able to
 generate a binding file from my hibernate domain objects using 
 jibx-genbinding.
 It was also just a cut-and-paste of sample code to get my marshalling code to
 work (with some small tweaks in the binding file). I also have maven2 calling
 the binding compiler. Very nice. Great documentation too! 

 Morgan




 -
 Using Tomcat but need to do more? Need to support web services, security?
 Get stuff done quickly with pre-integrated technology to make your job easier
 Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
 http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
 ___
 jibx-users mailing list
 jibx-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jibx-users

   

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users


Re: [jibx-users] collection Set JDK 1.4.2

2006-08-18 Thread Morgan Rachell

Dennis Sosnoski dms at sosnoski.com writes:

 
 Hi Sandeep,
 
 Is the exception occurring during marshalling or unmarshalling? Also, I 
 don't understand how you can get a ClassCastException with no further 
 stack trace information - can you show exactly what you're getting? Thanks,
 
   - Dennis
 
 Sandeep Khanna wrote:
 
 Hi All,
 
 Jibx binding compiler compiles fine with the following binding  class
 declaration:
 
 mapping name=AsClient class=com.adminserver.dcl.ClientDcl
 ordered=false
 collection field=roles type=java.util.HashSet
 item-type=com.adminserver.dcl.RoleDcl name=PolicyRoles
 usage=optional/
 /mapping
 
 mapping name=AsRole class=com.adminserver.dcl.RoleDcl
 ordered=false
 value get-method=getRoleGuid set-method=setRoleGuid
 name=RoleGUID style=element
 usage=optional/
 /mapping
 
 
 public class ClientDcl {
 ...
 private java.util.Set roles;
 ...
 }
 
 I am getting a java.lang.ClassCastException without any more stack trace
 information from Jibx.
 
 Would I need to use the 'factory' attribute instead of the 'type'
 attribute? Something on the lines of
 org.jibx.runtime.Utility.arrayListFactory?
 
 Any idea what's going on here?
 
 --Sandeep Khanna
 
 
 
 ---
 This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
 for problems?  Stop!  Download the new AJAX search engine that makes
 searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
 http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
 ___
 jibx-users mailing list
 jibx-users at lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jibx-users
 
   
 
 
 ---
 This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
 for problems?  Stop!  Download the new AJAX search engine that makes
 searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
 http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
 


Hi Dennis,

I know this topic has been idle for a while, but I am seeing the same thing when
I marshal a hibernate object. My FlockTest object marshalled just fine the first
time, without any collection bindings. Then I added the collection and got a
ClassCastException with no detailMessage, stackTrace, or any other information.
My binding has this:

binding forwards=false value-style=attribute
  mapping class=FlockTest name=flock-test
value style=element 
 name=flock-test-id 
 field=flockTestId 
 usage=optional/
[]
collection field=flockTestDetails 
item-type=FlockTestDetail 
type=java.util.HashSet
usage=optional/
/mapping
  mapping class=FlockTestDetail name=flock-test-detail
[...]
/mapping
/binding

My FlockTest class looks like this:

public class FlockTest implements java.io.Serializable {
 [...]
 private Set flockTestDetails = new HashSet(0);

public Set getFlockTestDetails() {
return this.flockTestDetails;
}

public void setFlockTestDetails(Set flockTestDetails) {
this.flockTestDetails = flockTestDetails;
}
}

The marshalling code looks like this:

public void saveFlockTest(FlockTest ft) throws DataAccessException
{
try{
IBindingFactory bfact = 
BindingDirectory.getFactory(FlockTest.class);
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
mctx.marshalDocument(ft, UTF-8, null, baos);
log.debug(baos.toString());
}catch(JiBXException je){
;
}catch(Exception e){
log.debug(e.getStackTrace());
}
}

I even rebuilt the latest code (1.0 RC1?) with debug symbols and stepped through
the marshalling code. It all works until it gets to the JiBX-generated FlockTest
marshal code, which I cannot step through. In the marshal() call, it steps into
MarshallingContext.getMarshaller(). That seems to return a marshaller correctly
because the debugger opens the FlockTest source file and indicates that it's
calling FlockTest.marshal(IMarshallingContext), as expected. I step/execute
three times (helpful?) in the marshal call and then get a CCE. 

I'm just getting into JiBX and very happy that my first test succeeded, but that
was a simple test. My objects may have many levels of children and
grandchildren, all implemented as java.util.Set. 

Any pointers would be helpful. Thanks!



-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo