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=7637&alloc_id=16865&op=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=7637&alloc_id=16865&op=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
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to