wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Problem adding to Collection in CMR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problem adding to Collection in CMR" Watch "Problem adding to Collection in CMR" New topic
Author

Problem adding to Collection in CMR

Dale Gundersen
Greenhorn

Joined: Jun 23, 2004
Posts: 2
I have a one-to-many CMR between a Conversation entity bean (one) and a Message entity bean (many). I have a stateless session bean that is called from the client (session facade pattern) to handle the business logic involving the Conversation and Message beans. The getters and setters for the entity beans are working just fine but I'm having problems adding a new Message to the Collection in the Conversation.

I'm fairly new at EJB development and I've searched exhaustively for information on bean relationships and it seems like the code is pretty straightforward. My session bean makes a call to:

convoEntity.addMessageToCollection(messageEntity);

which calls the following method in the ConversationEntityBean class:

public void addMessageToCollection(MessageEntity msg) {
getMessageentity().add(msg);
}

The problem is that the add(msg) call throws the following exceptions:

[6/23/04 17:01:34:094 PDT] 5360f2e ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "addMessageToCollection" on bean "BeanId(DCSEARProject#DCSEJBProject.jar#ConversationEntity, dcs.ejb.ConversationEntityKey@fffffff7)". Exception data: java.lang.IllegalArgumentException: The argument passed into a CMR set function is invalid.
at com.ibm.ws.ejbpersistence.associations.LinkImpl.basicValidateArgument(Unknown Source)
at com.ibm.ws.ejbpersistence.associations.LinkImpl.validateArgument(Unknown Source)
at com.ibm.ws.ejbpersistence.associations.ManyValuedLinkImpl.validateArgument(Unknown Source)
at com.ibm.ws.ejbpersistence.associations.LinkSet.add(Unknown Source)
at dcs.ejb.ConversationEntityBean.addMessageToCollection(ConversationEntityBean.java:24)
at dcs.ejb.EJSRemoteCMPConversationEntity_c2e6f5c5.addMessageToCollection(EJSRemoteCMPConversationEntity_c2e6f5c5.java:346)
at dcs.ejb._ConversationEntity_Stub.addMessageToCollection(_ConversationEntity_Stub.java:1140)
at dcs.ejb.ConversationManagerBean.newMessage(ConversationManagerBean.java:222)
at dcs.ejb.EJSRemoteStatelessConversationManager_3972ab92.newMessage(EJSRemoteStatelessConversationManager_3972ab92.java:643)
at dcs.ejb._ConversationManager_Stub.newMessage(_ConversationManager_Stub.java:1927)
at dcs.ejb.MessageDispatcherBean.newMessage(MessageDispatcherBean.java:27)
at org.apache.jsp._sender._jspService(_sender.java:107)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:662)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R [6/23/04 17:01:34:359 PDT] 5360f2e SystemOut O RemoteException while attempting to create new message
javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 0x0 No; nested exception is:
org.omg.CORBA.TRANSACTION_ROLLEDBACK: javax.transaction.TransactionRolledbackException: ; nested exception is:
java.lang.IllegalArgumentException: The argument passed into a CMR set function is invalid. vmcid: 0x0 minor code: 0 completed: No
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.CORBA.iiop.UtilDelegateImpl.mapSystemException(UtilDelegateImpl.java:208)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.CORBA.iiop.UtilDelegateImpl.wrapException(UtilDelegateImpl.java:684)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at javax.rmi.CORBA.Util.wrapException(Util.java:295)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at dcs.ejb._ConversationEntity_Stub.addMessageToCollection(_ConversationEntity_Stub.java:1144)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at dcs.ejb.ConversationManagerBean.newMessage(ConversationManagerBean.java:222)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at dcs.ejb.EJSRemoteStatelessConversationManager_3972ab92.newMessage(EJSRemoteStatelessConversationManager_3972ab92.java:643)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at dcs.ejb._ConversationManager_Stub.newMessage(_ConversationManager_Stub.java:1927)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at dcs.ejb.MessageDispatcherBean.newMessage(MessageDispatcherBean.java:27)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at org.apache.jsp._sender._jspService(_sender.java:107)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:662)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:760)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
[6/23/04 17:01:34:359 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R Caused by: org.omg.CORBA.TRANSACTION_ROLLEDBACK: javax.transaction.TransactionRolledbackException: ; nested exception is:
java.lang.IllegalArgumentException: The argument passed into a CMR set function is invalid. vmcid: 0x0 minor code: 0 completed: No
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:79)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java(Compiled Code))
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled Code))
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.rmi.util.ProxyUtil.copyObject(ProxyUtil.java:320)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at com.ibm.CORBA.iiop.UtilDelegateImpl.copyObject(UtilDelegateImpl.java:789)
[6/23/04 17:01:34:375 PDT] 5360f2e SystemErr R at javax.rmi.CORBA.Util.copyObject(Util.java:332)
[6/23/04 17:01:34:391 PDT] 5360f2e SystemErr R at dcs.ejb._ConversationEntity_Stub.addMessageToCollection(_ConversationEntity_Stub.java:1143)
[6/23/04 17:01:34:391 PDT] 5360f2e SystemErr R ... 30 more



Does anyone know what I might be doing wrong???

Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You probably set up your CMR to a different bean accidentally. CMR collection implementations supplied by the container make sure that objects added to it are of the correct bean type. If they aren't, the add method will freak out (as you're seeing).


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Dale Gundersen
Greenhorn

Joined: Jun 23, 2004
Posts: 2
Actually I finally figured out what I was doing wrong yesterday. I was using the remote interface when I should have been using the local interface.
 
GeeCON Prague 2014
 
subject: Problem adding to Collection in CMR