Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Johan Naudts

Greenhorn
+ Follow
since Jan 15, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Johan Naudts

It probably is a good idea to point out some bugs and pitfalls to avoid within WSAD and WebSphere 5...
17 years ago
Ok,
I give up... I tried about verything but still can't get a simple create method to work when a relationship is involved!
This is what my EventBean looks like:
package entity;
import javax.naming.InitialContext;
/**
* Bean implementation class for Enterprise Bean: Event
*/
public abstract class EventBean implements javax.ejb.EntityBean {
private javax.ejb.EntityContext myEntityCtx;
/**
* setEntityContext
*/
public void setEntityContext(javax.ejb.EntityContext ctx) {
myEntityCtx = ctx;
}
/**
* getEntityContext
*/
public javax.ejb.EntityContext getEntityContext() {
return myEntityCtx;
}
/**
* unsetEntityContext
*/
public void unsetEntityContext() {
myEntityCtx = null;
}

public java.lang.String ejbCreate(common.bean.EventBean event, UserLocal localUser)
throws javax.ejb.CreateException {
System.out.println("New event is being created in the database");
setId(event.getId());
setSubject(event.getSubject());
setUser(localUser);
System.out.println("SUBJECT :: " + event.getStartTime());
if (event.getLocation() != null)
setLocation(event.getLocation());
System.out.println("LOCATION :: " + event.getLocation());
setDate(event.getDate());
System.out.println("DATE :: " + event.getDate());
setStartTime(event.getStartTime());
System.out.println("START_TIME :: " + event.getStartTime());
setEndTime(event.getEndTime());
System.out.println("END_TIME :: " + event.getEndTime());
if (event.getBody() != null)
setBody(event.getBody());
System.out.println("BODY :: " + event.getBody());
if (event.getComment() != null)
setComment(event.getComment());
System.out.println("COMMENT :: " + event.getComment());
return null;
}

public void ejbPostCreate(common.bean.EventBean event, UserLocal localUser)
throws javax.ejb.CreateException {
}

/**
* ejbActivate
*/
public void ejbActivate() {
}
/**
* ejbLoad
*/
public void ejbLoad() {
}
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() throws javax.ejb.RemoveException {
}
/**
* ejbStore
*/
public void ejbStore() {
}
/**
* Get accessor for persistent attribute: id
*/
public abstract java.lang.String getId();
/**
* Set accessor for persistent attribute: id
*/
public abstract void setId(java.lang.String newId);
/**
* Get accessor for persistent attribute: subject
*/
public abstract java.lang.String getSubject();
/**
* Set accessor for persistent attribute: subject
*/
public abstract void setSubject(java.lang.String newSubject);
/**
* Get accessor for persistent attribute: location
*/
public abstract java.lang.String getLocation();
/**
* Set accessor for persistent attribute: location
*/
public abstract void setLocation(java.lang.String newLocation);
/**
* Get accessor for persistent attribute: date
*/
public abstract java.lang.String getDate();
/**
* Set accessor for persistent attribute: date
*/
public abstract void setDate(java.lang.String newDate);
/**
* Get accessor for persistent attribute: startTime
*/
public abstract java.lang.String getStartTime();
/**
* Set accessor for persistent attribute: startTime
*/
public abstract void setStartTime(java.lang.String newStartTime);
/**
* Get accessor for persistent attribute: endTime
*/
public abstract java.lang.String getEndTime();
/**
* Set accessor for persistent attribute: endTime
*/
public abstract void setEndTime(java.lang.String newEndTime);
/**
* Get accessor for persistent attribute: body
*/
public abstract java.lang.String getBody();
/**
* Set accessor for persistent attribute: body
*/
public abstract void setBody(java.lang.String newBody);
/**
* Get accessor for persistent attribute: comment
*/
public abstract java.lang.String getComment();
/**
* Set accessor for persistent attribute: comment
*/
public abstract void setComment(java.lang.String newComment);
/**
* ejbCreate
*/
public java.lang.String ejbCreate(java.lang.String id)
throws javax.ejb.CreateException {
setId(id);
return null;
}
/**
* ejbPostCreate
*/
public void ejbPostCreate(java.lang.String id)
throws javax.ejb.CreateException {
}
/**
* This method was generated for supporting the relationship role named user.
* It will be deleted/edited when the relationship is deleted/edited.
*/
public abstract entity.UserLocal getUser();
/**
* This method was generated for supporting the relationship role named user.
* It will be deleted/edited when the relationship is deleted/edited.
*/
public abstract void setUser(entity.UserLocal anUser);
}
And this is what my client code looks like:
public void createEvent(common.bean.EventBean event) {
try {
if (_ic == null)
_ic = new InitialContext();
if (_userLocalHome == null)
_userLocalHome = (UserLocalHome)_ic.lookup("java:comp/env/ejb/LocalUser");
if (_eventLocalHome == null)
_eventLocalHome = (EventLocalHome)_ic.lookup("java:comp/env/ejb/LocalEvent");
_userLocal = _userLocalHome.findByPrimaryKey(event.getUserId());
EventLocal eventLocal = _eventLocalHome.create(event, _userLocal);
Collection events = _userLocal.getEvents();
events.add(eventLocal);
} catch (Exception e) {
e.printStackTrace();
}
}
I am sure that a localUser was found, but still, when I run the create method I get the following exception:
[16/01/03 23:21:13:216 CET] 74fabef1 SystemOut O New event is being created in the database
[16/01/03 23:21:13:226 CET] 74fabef1 ExceptionUtil E CNTR0019E: Non-application exception occurred while processing method "create". Exception data: com.ibm.ejs.container.CreateFailureException: java.lang.IllegalStateException; nested exception is:
java.lang.IllegalStateException
java.lang.IllegalStateException
at com.ibm.ejs.container.EntityBeanO.getEJBLocalObject(EntityBeanO.java:1481)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanInstanceExtensionImpl.getEJBObject(ConcreteBeanInstanceExtensionImpl.java:345)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.connectTo(OneValuedLinkImpl.java:63)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.setValue(OneValuedLinkImpl.java:202)
at com.ibm.ws.ejbpersistence.associations.ForwardOneLinkImpl.setValue(ForwardOneLinkImpl.java:89)
at entity.ConcreteEvent_ff29c918.setUser(ConcreteEvent_ff29c918.java:434)
at entity.EventBean.ejbCreate(EventBean.java:34)
at entity.ConcreteEvent_ff29c918.ejbCreate(ConcreteEvent_ff29c918.java:408)
at entity.EJSCMPEventHomeBean_ff29c918.create_Local(EJSCMPEventHomeBean_ff29c918.java:100)
at entity.EJSLocalCMPEventHome_ff29c918.create(EJSLocalCMPEventHome_ff29c918.java:138)
at session.CalendarFacadeBean.createEvent(CalendarFacadeBean.java:132)
at session.EJSLocalStatelessCalendarFacade_f06dce2d.createEvent(EJSLocalStatelessCalendarFacade_f06dce2d.java:121)
at controller.CreateEventServlet.doGet(CreateEventServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
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:258)
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:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:187)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
----- Begin backtrace for detail
java.lang.IllegalStateException
at com.ibm.ejs.container.EntityBeanO.getEJBLocalObject(EntityBeanO.java:1481)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanInstanceExtensionImpl.getEJBObject(ConcreteBeanInstanceExtensionImpl.java:345)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.connectTo(OneValuedLinkImpl.java:63)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.setValue(OneValuedLinkImpl.java:202)
at com.ibm.ws.ejbpersistence.associations.ForwardOneLinkImpl.setValue(ForwardOneLinkImpl.java:89)
at entity.ConcreteEvent_ff29c918.setUser(ConcreteEvent_ff29c918.java:434)
at entity.EventBean.ejbCreate(EventBean.java:34)
at entity.ConcreteEvent_ff29c918.ejbCreate(ConcreteEvent_ff29c918.java:408)
at entity.EJSCMPEventHomeBean_ff29c918.create_Local(EJSCMPEventHomeBean_ff29c918.java:100)
at entity.EJSLocalCMPEventHome_ff29c918.create(EJSLocalCMPEventHome_ff29c918.java:138)
at session.CalendarFacadeBean.createEvent(CalendarFacadeBean.java:132)
at session.EJSLocalStatelessCalendarFacade_f06dce2d.createEvent(EJSLocalStatelessCalendarFacade_f06dce2d.java:121)
at controller.CreateEventServlet.doGet(CreateEventServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
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:258)
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:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:187)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
[16/01/03 23:21:13:437 CET] 74fabef1 SystemErr R javax.ejb.TransactionRolledbackLocalException: javax.transaction.TransactionRolledbackException: com.ibm.websphere.csi.CSITransactionRolledbackException: null; nested exception is:
java.lang.IllegalStateException
java.lang.IllegalStateException
at com.ibm.ejs.container.EntityBeanO.getEJBLocalObject(EntityBeanO.java:1481)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanInstanceExtensionImpl.getEJBObject(ConcreteBeanInstanceExtensionImpl.java:345)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.connectTo(OneValuedLinkImpl.java:63)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.setValue(OneValuedLinkImpl.java:202)
at com.ibm.ws.ejbpersistence.associations.ForwardOneLinkImpl.setValue(ForwardOneLinkImpl.java:89)
at entity.ConcreteEvent_ff29c918.setUser(ConcreteEvent_ff29c918.java:434)
at entity.EventBean.ejbCreate(EventBean.java:34)
at entity.ConcreteEvent_ff29c918.ejbCreate(ConcreteEvent_ff29c918.java:408)
at entity.EJSCMPEventHomeBean_ff29c918.create_Local(EJSCMPEventHomeBean_ff29c918.java:100)
at entity.EJSLocalCMPEventHome_ff29c918.create(EJSLocalCMPEventHome_ff29c918.java:138)
at session.CalendarFacadeBean.createEvent(CalendarFacadeBean.java:132)
at session.EJSLocalStatelessCalendarFacade_f06dce2d.createEvent(EJSLocalStatelessCalendarFacade_f06dce2d.java:121)
at controller.CreateEventServlet.doGet(CreateEventServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
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:258)
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:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:187)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
at com.ibm.ejs.container.util.ExceptionUtil.mapCSIException(ExceptionUtil.java:51)
at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapException(LocalExceptionMappingStrategy.java:85)
at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapCSITransactionRolledBackException(LocalExceptionMappingStrategy.java:195)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:2858)
at entity.EJSLocalCMPEventHome_ff29c918.create(EJSLocalCMPEventHome_ff29c918.java:148)
at session.CalendarFacadeBean.createEvent(CalendarFacadeBean.java:132)
at session.EJSLocalStatelessCalendarFacade_f06dce2d.createEvent(EJSLocalStatelessCalendarFacade_f06dce2d.java:121)
at controller.CreateEventServlet.doGet(CreateEventServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
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:258)
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:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:187)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
; nested exception is: java.lang.IllegalStateException
[16/01/03 23:21:13:447 CET] 74fabef1 SystemErr R java.lang.IllegalStateException
[16/01/03 23:21:13:447 CET] 74fabef1 SystemErr R at com.ibm.ejs.container.EntityBeanO.getEJBLocalObject(EntityBeanO.java:1481)
[16/01/03 23:21:13:457 CET] 74fabef1 SystemErr R at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanInstanceExtensionImpl.getEJBObject(ConcreteBeanInstanceExtensionImpl.java:345)
[16/01/03 23:21:13:457 CET] 74fabef1 SystemErr R at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.connectTo(OneValuedLinkImpl.java:63)
[16/01/03 23:21:13:457 CET] 74fabef1 SystemErr R at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.setValue(OneValuedLinkImpl.java:202)
[16/01/03 23:21:13:457 CET] 74fabef1 SystemErr R at com.ibm.ws.ejbpersistence.associations.ForwardOneLinkImpl.setValue(ForwardOneLinkImpl.java:89)
[16/01/03 23:21:13:457 CET] 74fabef1 SystemErr R at entity.ConcreteEvent_ff29c918.setUser(ConcreteEvent_ff29c918.java:434)
[16/01/03 23:21:13:467 CET] 74fabef1 SystemErr R at entity.EventBean.ejbCreate(EventBean.java:34)
[16/01/03 23:21:13:467 CET] 74fabef1 SystemErr R at entity.ConcreteEvent_ff29c918.ejbCreate(ConcreteEvent_ff29c918.java:408)
[16/01/03 23:21:13:467 CET] 74fabef1 SystemErr R at entity.EJSCMPEventHomeBean_ff29c918.create_Local(EJSCMPEventHomeBean_ff29c918.java:100)
[16/01/03 23:21:13:467 CET] 74fabef1 SystemErr R at entity.EJSLocalCMPEventHome_ff29c918.create(EJSLocalCMPEventHome_ff29c918.java:138)
[16/01/03 23:21:13:477 CET] 74fabef1 SystemErr R at session.CalendarFacadeBean.createEvent(CalendarFacadeBean.java:132)
[16/01/03 23:21:13:477 CET] 74fabef1 SystemErr R at session.EJSLocalStatelessCalendarFacade_f06dce2d.createEvent(EJSLocalStatelessCalendarFacade_f06dce2d.java:121)
[16/01/03 23:21:13:477 CET] 74fabef1 SystemErr R at controller.CreateEventServlet.doGet(CreateEventServlet.java:64)
[16/01/03 23:21:13:477 CET] 74fabef1 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
[16/01/03 23:21:13:477 CET] 74fabef1 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[16/01/03 23:21:13:487 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[16/01/03 23:21:13:487 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[16/01/03 23:21:13:487 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[16/01/03 23:21:13:487 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[16/01/03 23:21:13:497 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
[16/01/03 23:21:13:497 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[16/01/03 23:21:13:497 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[16/01/03 23:21:13:497 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
[16/01/03 23:21:13:497 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
[16/01/03 23:21:13:507 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
[16/01/03 23:21:13:507 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
[16/01/03 23:21:13:507 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
[16/01/03 23:21:13:517 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[16/01/03 23:21:13:517 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
[16/01/03 23:21:13:517 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:187)
[16/01/03 23:21:13:517 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
[16/01/03 23:21:13:527 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[16/01/03 23:21:13:537 CET] 74fabef1 SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
[16/01/03 23:21:13:537 CET] 74fabef1 SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
[16/01/03 23:21:13:537 CET] 74fabef1 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
[16/01/03 23:21:13:537 CET] 74fabef1 SystemErr R javax.ejb.TransactionRolledbackLocalException: javax.transaction.TransactionRolledbackException: com.ibm.websphere.csi.CSITransactionRolledbackException: null; nested exception is:
java.lang.IllegalStateException
java.lang.IllegalStateException
at com.ibm.ejs.container.EntityBeanO.getEJBLocalObject(EntityBeanO.java:1481)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanInstanceExtensionImpl.getEJBObject(ConcreteBeanInstanceExtensionImpl.java:345)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.connectTo(OneValuedLinkImpl.java:63)
at com.ibm.ws.ejbpersistence.associations.OneValuedLinkImpl.setValue(OneValuedLinkImpl.java:202)
at com.ibm.ws.ejbpersistence.associations.ForwardOneLinkImpl.setValue(ForwardOneLinkImpl.java:89)
at entity.ConcreteEvent_ff29c918.setUser(ConcreteEvent_ff29c918.java:434)
at entity.EventBean.ejbCreate(EventBean.java:34)
at entity.ConcreteEvent_ff29c918.ejbCreate(ConcreteEvent_ff29c918.java:408)
at entity.EJSCMPEventHomeBean_ff29c918.create_Local(EJSCMPEventHomeBean_ff29c918.java:100)
at entity.EJSLocalCMPEventHome_ff29c918.create(EJSLocalCMPEventHome_ff29c918.java:138)
at session.CalendarFacadeBean.createEvent(CalendarFacadeBean.java:132)
at session.EJSLocalStatelessCalendarFacade_f06dce2d.createEvent(EJSLocalStatelessCalendarFacade_f06dce2d.java:121)
at controller.CreateEventServlet.doGet(CreateEventServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
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:258)
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:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:187)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
at com.ibm.ejs.container.util.ExceptionUtil.mapCSIException(ExceptionUtil.java:51)
at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapException(LocalExceptionMappingStrategy.java:85)
at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapCSITransactionRolledBackException(LocalExceptionMappingStrategy.java:195)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:2858)
at entity.EJSLocalCMPEventHome_ff29c918.create(EJSLocalCMPEventHome_ff29c918.java:148)
at session.CalendarFacadeBean.createEvent(CalendarFacadeBean.java:132)
at session.EJSLocalStatelessCalendarFacade_f06dce2d.createEvent(EJSLocalStatelessCalendarFacade_f06dce2d.java:121)
at controller.CreateEventServlet.doGet(CreateEventServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
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:258)
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:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:187)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
; nested exception is: java.lang.IllegalStateException
[16/01/03 23:21:13:547 CET] 74fabef1 SystemErr R at controller.CreateEventServlet.doGet(CreateEventServlet.java:75)
[16/01/03 23:21:13:557 CET] 74fabef1 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:787)
[16/01/03 23:21:13:557 CET] 74fabef1 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:854)
[16/01/03 23:21:13:557 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:145)
[16/01/03 23:21:13:557 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:215)
[16/01/03 23:21:13:567 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:314)
[16/01/03 23:21:13:567 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:117)
[16/01/03 23:21:13:567 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:306)
[16/01/03 23:21:13:567 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:43)
[16/01/03 23:21:13:567 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:41)
[16/01/03 23:21:13:567 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:941)
[16/01/03 23:21:13:567 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:662)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:214)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:135)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:227)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:72)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:118)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:190)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:406)
[16/01/03 23:21:13:577 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:57)
[16/01/03 23:21:13:587 CET] 74fabef1 SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:461)
[16/01/03 23:21:13:587 CET] 74fabef1 SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:414)
[16/01/03 23:21:13:587 CET] 74fabef1 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
[16/01/03 23:21:13:597 CET] 74fabef1 SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:414)
[16/01/03 23:21:13:597 CET] 74fabef1 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
[16/01/03 23:21:13:597 CET] 74fabef1 SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:57)
[16/01/03 23:21:13:597 CET] 74fabef1 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
I don't understand anymore... Is this some kind of a bug within WebSphere, or am I doing something deadly wrong? Still don't understand why a simple setUserId inside the EventBean isn't possible... It is in other environments such as Pramati e.g.....
Can somebody please help???
Thanks in advance
17 years ago
Ok,
so if I get it right, my new ejbCreate method should look something like this:
public String ejbCreate(common.bean.EventBean, UserLocal localUser) throws CreateException {
setId("1");
setUser(localUser);
setSubject("Blabla");
setLocation("Home");
...
}
But I will only have the setUser method available if I add a cmr-field user, AND when I make the Event bean navigable. So, if this is correct, you should always make both CMP's in a relationship navigable, because otherwise, there is no way you can create a new row in the database? Is this correct?
By the way: can only test this this evening (in the afternoon for you guys :-). Will tell you the outcome later...
17 years ago
Ok, I did what you told me for part (1) that is, because part (2) and (3) where already implemented this way.
Now, I still don't see a create method in the EventLocalHome. I now have 2 create methods (like before): standard create (generated automagically by WSAD :-), taking the primary key field (id) as argument, and the user-defined create method, taking an EventBean (no EJB, standard Java bean!) as argument. Now, I don't see how the Event CMP, could take a UserLocal as argument in a create method?? Maybe I'm missing something...
This is the code for the UserLocalHome:
package entity;
import javax.ejb.CreateException;
/**
* Local Home interface for Enterprise Bean: Event
*/
public interface EventLocalHome extends javax.ejb.EJBLocalHome {
/**
* Creates an instance from a key for Entity Bean: Event
*/
public entity.EventLocal create(java.lang.String id)
throws javax.ejb.CreateException;

public entity.EventLocal create(common.bean.EventBean event)
throws javax.ejb.CreateException;
/**
* Finds an instance using a key for Entity Bean: Event
*/
public entity.EventLocal findByPrimaryKey(java.lang.String primaryKey)
throws javax.ejb.FinderException;
}
Help?
17 years ago
Uh oh,
guess something went werong in the formatting of the XML file. Here's another attempt:
< !--<br /> <?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">;
<ejb-jar id="ejb-jar_ID">
<display-name>PersonalPlannerEJB</display-name>
<enterprise-beans>
<session id="CalendarFacade">
<ejb-name>CalendarFacade</ejb-name>
<home>session.CalendarFacadeHome</home>
<remote>session.CalendarFacade</remote>
<local-home>session.CalendarFacadeLocalHome</local-home>
<local>session.CalendarFacadeLocal</local>
<ejb-class>session.CalendarFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref id="EJBLocalRef_1040332897235">
<description></description>
<ejb-ref-name>ejb/LocalEvent</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.EventLocalHome</local-home>
<local>entity.EventLocal</local>
<ejb-link>Event</ejb-link>
</ejb-local-ref>
<ejb-local-ref id="EJBLocalRef_1040335538924">
<description></description>
<ejb-ref-name>ejb/LocalUser</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-link>User</ejb-link>
</ejb-local-ref>
</session>
<session id="LoginFacade">
<ejb-name>LoginFacade</ejb-name>
<home>session.LoginFacadeHome</home>
<remote>session.LoginFacade</remote>
<local-home>session.LoginFacadeLocalHome</local-home>
<local>session.LoginFacadeLocal</local>
<ejb-class>session.LoginFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref id="EJBLocalRef_1039983293063">
<description></description>
<ejb-ref-name>ejb/LocalUser</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-link>User</ejb-link>
</ejb-local-ref>
</session>
<entity id="User">
<ejb-name>User</ejb-name>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-class>entity.UserBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>User</abstract-schema-name>
<cmp-field id="CMPAttribute_1039982972362">
<field-name>userId</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982975817">
<field-name>password</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982978932">
<field-name>lastName</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982982357">
<field-name>firstName</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982985481">
<field-name>gender</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982988435">
<field-name>birthDate</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982991480">
<field-name>street</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982994504">
<field-name>houseNrNum</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982997468">
<field-name>houseNrAlpha</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983000372">
<field-name>postalCodeNum</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983003237">
<field-name>postalCodeAlpha</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983005880">
<field-name>city</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983008664">
<field-name>country</field-name>
</cmp-field>
<primkey-field>userId</primkey-field>
<ejb-local-ref id="EJBLocalRef_1042578719424">
<ejb-ref-name>ejb/Event</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.EventLocalHome</local-home>
<local>entity.EventLocal</local>
<ejb-link>Event</ejb-link>
</ejb-local-ref>
</entity>
<entity id="Event">
<ejb-name>Event</ejb-name>
<local-home>entity.EventLocalHome</local-home>
<local>entity.EventLocal</local>
<ejb-class>entity.EventBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Event</abstract-schema-name>
<cmp-field id="CMPAttribute_1042578642103">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578607042">
<field-name>userId</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642104">
<field-name>subject</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642113">
<field-name>location</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642183">
<field-name>date</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578610567">
<field-name>startTime</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578614042">
<field-name>endTime</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642184">
<field-name>body</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642193">
<field-name>comment</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<ejb-local-ref id="EJBLocalRef_1042578719434">
<ejb-ref-name>ejb/User</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-link>User</ejb-link>
</ejb-local-ref>
<query>
<description></description>
<query-method>
<method-name>findEvents</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>select object(o) from Event o where o.userId = ?1 and o.date = ?2</ejb-ql>
</query>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<description></description>
<ejb-relation-name>User-Events</ejb-relation-name>
<ejb-relationship-role id="EJBRelationshipRole_1042578730169">
<ejb-relationship-role-name>user</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>Event</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
<ejb-relationship-role id="EJBRelationshipRole_1042578733845">
<ejb-relationship-role-name>event</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>User</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>events</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>CalendarFacade</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>LoginFacade</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>User</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>Event</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
-->
17 years ago
First of all: thanks for the fast responses!
Ok, this is what I did: I created 2 beans within WSAD, by means of the EJB wizard. This wizard lets you specify fields and appropriate getters and setters. In the case of the Event CMP, I simply added getters and setters for the userId field, which is perfectly possible without getting error messages. After the creation of the 2 beans, I added a relationship within the EJB deployment descriptor. I decided not to make the Event CMP bean navigable, so I don't have any CMR field (e.g. user) within this bean (which is again possible). So, I supposed I could simply set the user id within the ejbCreate method.. Apparently this is not the case, and I don't know why... Anyway: this is the code of both beans and the deployment descriptor for WebSphere. Maybe you can see my mistakes better this way.. Thanks in advance for a (last?) answer...
package entity;
import java.awt.image.LookupOp;
import javax.naming.InitialContext;
/**
* Bean implementation class for Enterprise Bean: Event
*/
public abstract class EventBean implements javax.ejb.EntityBean {
private javax.ejb.EntityContext myEntityCtx;
/**
* setEntityContext
*/
public void setEntityContext(javax.ejb.EntityContext ctx) {
myEntityCtx = ctx;
}
/**
* getEntityContext
*/
public javax.ejb.EntityContext getEntityContext() {
return myEntityCtx;
}
/**
* unsetEntityContext
*/
public void unsetEntityContext() {
myEntityCtx = null;
}
/**
* ejbCreate
*/
public java.lang.String ejbCreate(java.lang.String id)
throws javax.ejb.CreateException {
setId(id);
return null;
}
/**
* ejbPostCreate
*/
public void ejbPostCreate(java.lang.String id)
throws javax.ejb.CreateException {
}
public java.lang.String ejbCreate(common.bean.EventBean event)
throws javax.ejb.CreateException {
System.out.println("New event is being created in the database");
this.setId(event.getId());
System.out.println("ID :: " + event.getId());
//this.setUserId(event.getUserId());
System.out.println("USER_ID :: " + event.getUserId());
this.setSubject(event.getSubject());
System.out.println("SUBJECT :: " + event.getStartTime());
if (event.getLocation() != null)
this.setLocation(event.getLocation());
System.out.println("LOCATION :: " + event.getLocation());
this.setDate(event.getDate());
System.out.println("DATE :: " + event.getDate());
this.setStartTime(event.getStartTime());
System.out.println("START_TIME :: " + event.getStartTime());
this.setEndTime(event.getEndTime());
System.out.println("END_TIME :: " + event.getEndTime());
if (event.getBody() != null)
this.setBody(event.getBody());
System.out.println("BODY :: " + event.getBody());
if (event.getComment() != null)
this.setComment(event.getComment());
System.out.println("COMMENT :: " + event.getComment());
return null;
}

public void ejbPostCreate(common.bean.EventBean event)
throws javax.ejb.CreateException {
}

/**
* ejbActivate
*/
public void ejbActivate() {
}
/**
* ejbLoad
*/
public void ejbLoad() {
}
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() throws javax.ejb.RemoveException {
}
/**
* ejbStore
*/
public void ejbStore() {
}
/**
* Get accessor for persistent attribute: id
*/
public abstract java.lang.String getId();
/**
* Set accessor for persistent attribute: id
*/
public abstract void setId(java.lang.String newId);
/**
* Get accessor for persistent attribute: userId
*/
public abstract java.lang.String getUserId();
/**
* Set accessor for persistent attribute: userId
*/
public abstract void setUserId(java.lang.String newUserId);
/**
* Get accessor for persistent attribute: subject
*/
public abstract java.lang.String getSubject();
/**
* Set accessor for persistent attribute: subject
*/
public abstract void setSubject(java.lang.String newSubject);
/**
* Get accessor for persistent attribute: location
*/
public abstract java.lang.String getLocation();
/**
* Set accessor for persistent attribute: location
*/
public abstract void setLocation(java.lang.String newLocation);
/**
* Get accessor for persistent attribute: date
*/
public abstract java.lang.String getDate();
/**
* Set accessor for persistent attribute: date
*/
public abstract void setDate(java.lang.String newDate);
/**
* Get accessor for persistent attribute: startTime
*/
public abstract java.lang.String getStartTime();
/**
* Set accessor for persistent attribute: startTime
*/
public abstract void setStartTime(java.lang.String newStartTime);
/**
* Get accessor for persistent attribute: endTime
*/
public abstract java.lang.String getEndTime();
/**
* Set accessor for persistent attribute: endTime
*/
public abstract void setEndTime(java.lang.String newEndTime);
/**
* Get accessor for persistent attribute: body
*/
public abstract java.lang.String getBody();
/**
* Set accessor for persistent attribute: body
*/
public abstract void setBody(java.lang.String newBody);
/**
* Get accessor for persistent attribute: comment
*/
public abstract java.lang.String getComment();
/**
* Set accessor for persistent attribute: comment
*/
public abstract void setComment(java.lang.String newComment);
}
package entity;
/**
* Bean implementation class for Enterprise Bean: User
*/
public abstract class UserBean implements javax.ejb.EntityBean {
private javax.ejb.EntityContext myEntityCtx;
/**
* setEntityContext
*/
public void setEntityContext(javax.ejb.EntityContext ctx) {
myEntityCtx = ctx;
}
/**
* getEntityContext
*/
public javax.ejb.EntityContext getEntityContext() {
return myEntityCtx;
}
/**
* unsetEntityContext
*/
public void unsetEntityContext() {
myEntityCtx = null;
}
/**
* ejbCreate
*/
public java.lang.String ejbCreate(java.lang.String userId)
throws javax.ejb.CreateException {
setUserId(userId);
return null;
}
/**
* ejbPostCreate
*/
public void ejbPostCreate(java.lang.String userId)
throws javax.ejb.CreateException {
}
/**
* ejbActivate
*/
public void ejbActivate() {
}
/**
* ejbLoad
*/
public void ejbLoad() {
}
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() throws javax.ejb.RemoveException {
}
/**
* ejbStore
*/
public void ejbStore() {
}
/**
* Get accessor for persistent attribute: userId
*/
public abstract java.lang.String getUserId();
/**
* Set accessor for persistent attribute: userId
*/
public abstract void setUserId(java.lang.String newUserId);
/**
* Get accessor for persistent attribute: password
*/
public abstract java.lang.String getPassword();
/**
* Set accessor for persistent attribute: password
*/
public abstract void setPassword(java.lang.String newPassword);
/**
* Get accessor for persistent attribute: lastName
*/
public abstract java.lang.String getLastName();
/**
* Set accessor for persistent attribute: lastName
*/
public abstract void setLastName(java.lang.String newLastName);
/**
* Get accessor for persistent attribute: firstName
*/
public abstract java.lang.String getFirstName();
/**
* Set accessor for persistent attribute: firstName
*/
public abstract void setFirstName(java.lang.String newFirstName);
/**
* Get accessor for persistent attribute: gender
*/
public abstract java.lang.String getGender();
/**
* Set accessor for persistent attribute: gender
*/
public abstract void setGender(java.lang.String newGender);
/**
* Get accessor for persistent attribute: birthDate
*/
public abstract java.lang.String getBirthDate();
/**
* Set accessor for persistent attribute: birthDate
*/
public abstract void setBirthDate(java.lang.String newBirthDate);
/**
* Get accessor for persistent attribute: street
*/
public abstract java.lang.String getStreet();
/**
* Set accessor for persistent attribute: street
*/
public abstract void setStreet(java.lang.String newStreet);
/**
* Get accessor for persistent attribute: houseNrNum
*/
public abstract java.lang.Integer getHouseNrNum();
/**
* Set accessor for persistent attribute: houseNrNum
*/
public abstract void setHouseNrNum(java.lang.Integer newHouseNrNum);
/**
* Get accessor for persistent attribute: houseNrAlpha
*/
public abstract java.lang.String getHouseNrAlpha();
/**
* Set accessor for persistent attribute: houseNrAlpha
*/
public abstract void setHouseNrAlpha(java.lang.String newHouseNrAlpha);
/**
* Get accessor for persistent attribute: postalCodeNum
*/
public abstract java.lang.Integer getPostalCodeNum();
/**
* Set accessor for persistent attribute: postalCodeNum
*/
public abstract void setPostalCodeNum(java.lang.Integer newPostalCodeNum);
/**
* Get accessor for persistent attribute: postalCodeAlpha
*/
public abstract java.lang.String getPostalCodeAlpha();
/**
* Set accessor for persistent attribute: postalCodeAlpha
*/
public abstract void setPostalCodeAlpha(
java.lang.String newPostalCodeAlpha);
/**
* Get accessor for persistent attribute: city
*/
public abstract java.lang.String getCity();
/**
* Set accessor for persistent attribute: city
*/
public abstract void setCity(java.lang.String newCity);
/**
* Get accessor for persistent attribute: country
*/
public abstract java.lang.String getCountry();
/**
* Set accessor for persistent attribute: country
*/
public abstract void setCountry(java.lang.String newCountry);
/**
* This method was generated for supporting the relationship role named event.
* It will be deleted/edited when the relationship is deleted/edited.
*/
public abstract java.util.Collection getEvents();
/**
* This method was generated for supporting the relationship role named event.
* It will be deleted/edited when the relationship is deleted/edited.
*/
public abstract void setEvents(java.util.Collection anEvent);
}
<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">;
<ejb-jar id="ejb-jar_ID">
<display-name>PersonalPlannerEJB</display-name>
<enterprise-beans>
<session id="CalendarFacade">
<ejb-name>CalendarFacade</ejb-name>
<home>session.CalendarFacadeHome</home>
<remote>session.CalendarFacade</remote>
<local-home>session.CalendarFacadeLocalHome</local-home>
<local>session.CalendarFacadeLocal</local>
<ejb-class>session.CalendarFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref id="EJBLocalRef_1040332897235">
<description></description>
<ejb-ref-name>ejb/LocalEvent</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.EventLocalHome</local-home>
<local>entity.EventLocal</local>
<ejb-link>Event</ejb-link>
</ejb-local-ref>
<ejb-local-ref id="EJBLocalRef_1040335538924">
<description></description>
<ejb-ref-name>ejb/LocalUser</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-link>User</ejb-link>
</ejb-local-ref>
</session>
<session id="LoginFacade">
<ejb-name>LoginFacade</ejb-name>
<home>session.LoginFacadeHome</home>
<remote>session.LoginFacade</remote>
<local-home>session.LoginFacadeLocalHome</local-home>
<local>session.LoginFacadeLocal</local>
<ejb-class>session.LoginFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref id="EJBLocalRef_1039983293063">
<description></description>
<ejb-ref-name>ejb/LocalUser</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-link>User</ejb-link>
</ejb-local-ref>
</session>
<entity id="User">
<ejb-name>User</ejb-name>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-class>entity.UserBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>User</abstract-schema-name>
<cmp-field id="CMPAttribute_1039982972362">
<field-name>userId</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982975817">
<field-name>password</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982978932">
<field-name>lastName</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982982357">
<field-name>firstName</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982985481">
<field-name>gender</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982988435">
<field-name>birthDate</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982991480">
<field-name>street</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982994504">
<field-name>houseNrNum</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039982997468">
<field-name>houseNrAlpha</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983000372">
<field-name>postalCodeNum</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983003237">
<field-name>postalCodeAlpha</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983005880">
<field-name>city</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1039983008664">
<field-name>country</field-name>
</cmp-field>
<primkey-field>userId</primkey-field>
<ejb-local-ref id="EJBLocalRef_1042578719424">
<ejb-ref-name>ejb/Event</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.EventLocalHome</local-home>
<local>entity.EventLocal</local>
<ejb-link>Event</ejb-link>
</ejb-local-ref>
</entity>
<entity id="Event">
<ejb-name>Event</ejb-name>
<local-home>entity.EventLocalHome</local-home>
<local>entity.EventLocal</local>
<ejb-class>entity.EventBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Event</abstract-schema-name>
<cmp-field id="CMPAttribute_1042578642103">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578607042">
<field-name>userId</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642104">
<field-name>subject</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642113">
<field-name>location</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642183">
<field-name>date</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578610567">
<field-name>startTime</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578614042">
<field-name>endTime</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642184">
<field-name>body</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1042578642193">
<field-name>comment</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<ejb-local-ref id="EJBLocalRef_1042578719434">
<ejb-ref-name>ejb/User</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>entity.UserLocalHome</local-home>
<local>entity.UserLocal</local>
<ejb-link>User</ejb-link>
</ejb-local-ref>
<query>
<description></description>
<query-method>
<method-name>findEvents</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>select object(o) from Event o where o.userId = ?1 and o.date = ?2</ejb-ql>
</query>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<description></description>
<ejb-relation-name>User-Events</ejb-relation-name>
<ejb-relationship-role id="EJBRelationshipRole_1042578730169">
<ejb-relationship-role-name>user</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>Event</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
<ejb-relationship-role id="EJBRelationshipRole_1042578733845">
<ejb-relationship-role-name>event</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>User</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>events</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>CalendarFacade</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>LoginFacade</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>User</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>Event</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
17 years ago
Well,
there indeed is a CMR relationship (1:M) between User and Event. The ejbCreate method is a simple set of standard setters looking like this:
...
this.setId("1");
this.setUserId("Johan Naudts");
this.setSubject("First event");
...
All setters (for all CMP fields) have been hard-coded and are consequently NOT NULL
In the DB2 database there is a cascading delete constraint on the foreign key (USER_ID)...
Is this enough, or do you want the complete Event and User bean code?
17 years ago
Dear,
I am currently developing an EJB 2.0 application within WebSphere Studio Applicaton Developer V5. For the moment, this application consists of 2 CMP beans, Event and User, mapped respectively to the DB2 7.2 tables EVENT and USER.
This is what the tables look like:
USER:
USER_ID VARCHAR NOT NULL
FIRST_NAME VARCHAR NOT NULL
LAST_NAME VARCHAR NOT NULL
...
EVENT
ID VARCHAR NOT NULL
USER_ID VARCHAR NOT NULL --> Foreign key to USER.USER_ID
SUBJECT VARCHAR NOT NULL
...
When I do any kind of lookup (finder methods), this works perfectly. When I try to persist a new Event to the database by means of a custom ejbCreate method on the Event bean (I'm using the built-in WebSphere V5 test environment), I always get a DB2 error (inside of a CreateException), stating that I cannot insert a NULL value into a non-NULL column. I have checked this, and I am 100% sure that all fields are provided and NOT NULL when calling the ejbCreate method. Is this a bug in WebSphere, or am I doing something wrong...???
If you need more info, please let me know..
Any help is greatly appreciated!
17 years ago