-
1. Re: How to convert CMR Proxy to EJBLocalObject?
raja05 Nov 9, 2003 6:34 PM (in response to ergomy)Can you post some code or the exception ? This should be pretty standard behaviour so it shud work ;-)
-Raj -
2. Re: How to convert CMR Proxy to EJBLocalObject?
ergomy Nov 10, 2003 1:44 PM (in response to ergomy)Thanks for your reply.. Yes, i expected that it would be straightforward and haven't had a problem implementing CMR with 1 to Many relationships. So I'm baffled and certain i've missed something simple.
But your help will be greatly appreciated.
Here is the code and exception...
EJB-JAR.XML
<ejb-relation>
<ejb-relation-name>usergroup-user</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>usergroups-have-users</ejb-relationship-role-name>
Many
<relationship-role-source>
<ejb-name>TheUserGroup</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>members</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>users-have-usergroups</ejb-relationship-role-name>
Many
<relationship-role-source>
<ejb-name>TheUser</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>userGroups</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
jbosscmp-jdbc.xml
<ejb-relation>
<ejb-relation-name>usergroup-user</ejb-relation-name>
<relation-table-mapping>
<table-name>user_usergroups</table-name>
</relation-table-mapping>
<ejb-relationship-role>
<ejb-relationship-role-name>usergroups-have-users</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>groupId</field-name>
<column-name>usergroup_id</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>users-have-usergroups</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>userId</field-name>
<column-name>user_id</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation>
Snippet of Java inside "TheUserGroup" entity bean that is called after the bean has been loaded by finder
Iterator users = getUsers().iterator();
while( users.hasNext() ){
UserEntityLocal userLocal = (UserEntityLocal)users.next();
Globals.getTrace().traceInfo( "user - name " + userLocal.getName());
}
Exception that occurs when attempting to access userLocal..
java.sql.SQLException: Unable to load to deserialize result: java.io.InvalidClassException: com.transensory.ergomy.model.MemberImpl; local class incompatible: stream classdesc serialVersionUID = 8309846566778834449, local class serialVersionUID = -2781449848339997329
at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.convertToObject(JDBCUtil.java:747)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.getResult(JDBCUtil.java:372)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults(JDBCAbstractCMPFieldBridge.java:369)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadInstanceResults(JDBCAbstractCMPFieldBridge.java:322)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:190)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:83)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:632)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:614)
at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:386)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:353)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:232)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:82)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
....
Thanks again! -
3. Re: How to convert CMR Proxy to EJBLocalObject?
ergomy Nov 10, 2003 2:02 PM (in response to ergomy)
OOPS.. i realized that I typed in the wrong accessor call in the java snippet i posted. The "cmr-field-name" defined in the ejb-jar.xml is "members" as given in my post. My previous post had a typo in the java snippet section.. i don't call getUsers() but do call the correct accessor.. getMembers().
Thanks,
Ed -
4. Re: How to convert CMR Proxy to EJBLocalObject?
ergomy Nov 10, 2003 3:04 PM (in response to ergomy)
SOLUTION:
Wouldn't you know it, that shortly after posting the code I figured out the problem. The problem turned out to be unrelated to CMR altogether. It was a Class type mismatch of a blob in the User table and a field in the User Entity bean.
Sorry if I caused you to scratch your heads.. but hopefully it might help someone else who might be mislead by the same symptoms.
-Ed