I am trying to get started with EJB on JBoss, particularly creating container-managed EJBs.  I am using JBoss 3.2.2 and MySQL on the backend.  I have two simple beans, Employee and Address.  I would like to establish a CMR between the two so that an Employee bean can call the function setAddress(Address a) and have an address associated with it.  This should be a uni-directional one-to-one relationship.  I've tried several different ways to create this bean (manual class creation, XDoclet, etc.) but keep getting exceptions.  Here are the two beans I've created with the relevant XDoclet tags:
 
 

/**

* @ejb.bean name="Employee"

* jndi-name="EmployeeBean"

* type="CMP"

* primkey-field="employeeID"

* schema="MyEmployee"

* cmp-version="2.x"

*

* @ejb.persistence

* table-name="employee"

*

* @ejb.finder

* query="SELECT OBJECT(a) FROM MyEmployee as a"

* signature="java.util.Collection findAll()"

*

**/

public abstract class EmployeeBean implements EntityBean {

 <more stuff here>

/**

* @ejb.interface-method

*

* @ejb.relation

* name = "employee-address"

* role-name = "employeeHasAddress"

* cascade-delete = "yes"

* target-ejb = "Address"

* target-role-name = "AddressBelongsToEmployee"

*

* @jboss.relation

* fk-constraint = "true"

* related-pk-field = "addressID"

* fk-column = "addressID"

*

* @author SDNakhla

*

*/

public abstract Address getAddress();

/**

* @ejb.interface-method

*/

public abstract void setAddress(Address address);

}

However, when I call the setAddress() function, I get a long list of exceptions.  The address information is created properly in the database, as is the employee information.  However, in the employee table the address_id field (a foreign key, corresponding to the primary key of the address) is null.  Below is the stack trace I'm receiving.  Can anyone tell me what it is I'm doing wrong and why this exception is occurring?  I've been working on this for two weeks and have made no progress.  Thanks in advance!!

Steve Nakhla

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:

java.rmi.ServerException: EJBException:; nested exception is:

javax.ejb.EJBException: null; CausedByException is:

null

at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)

at sun.rmi.transport.Transport$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Unknown Source)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)

at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)

at sun.rmi.server.UnicastRef.invoke(Unknown Source)

at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)

at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)

at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)

at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)

at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)

at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:97)

at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)

at $Proxy3.setAddress(Unknown Source)

at ejb.addressbook.AddressBookClient.testBean(AddressBookClient.java:76)

at ejb.addressbook.AddressBookClient.main(AddressBookClient.java:90)

Caused by: java.rmi.ServerException: EJBException:; nested exception is:

javax.ejb.EJBException: null; CausedByException is:

null

at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:347)

at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)

at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)

at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:490)

at org.jboss.ejb.Container.invoke(Container.java:700)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)

at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)

at sun.rmi.transport.Transport$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Unknown Source)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: javax.ejb.EJBException: null; CausedByException is:

null

at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:745)

at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setValue(JDBCCMRFieldBridge.java:590)

at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:121)

at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)

at ejb.addressbook.EmployeeCMP$Proxy.setAddress(<generated>)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1095)

at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:71)

at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:277)

at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)

at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:114)

at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)

at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)

at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)

at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)

at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)

at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)

at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)

at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)

... 21 more

 


Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

Reply via email to