1 Reply Latest reply: Jan 16, 2012 3:33 AM by gimbal2 RSS

    EJB 3.0 Constraints Problem

    712157
      Hi everybody !
      Hope someone can help me !! Im really go crazy with this stuff :s...
      Im Using jdeveloper .... I have 2 Entity Bean called Jiverating and Jiveuser, I creadte them using "Create Entity Bean from Table".... also a Session Bean called ForumFacadeBean I created using a EJB diagram as EJB Sesion Bean ....

      I can execute query without any problem but when I want to sotre a new Jiverating the aplication thows an exception... I just call the following metold of ForumFacadeBean


      public Jiverating persistJiverating(Jiverating jiverating) {   
      em.persist(jiverating);
      return jiverating;
      }

      The exception I got is:


      <Jan 13, 2012 8:42:48 PM PET> <Warning> <EclipseLink> <BEA-2005000> <2012-01-13 20:42:48.125--UnitOfWork(317933487)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
      ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found

      Error Code: 2091
      Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
           bind => [2, 0, 2, 11]
      Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)>
      <Jan 13, 2012 8:42:48 PM PET> <Warning> <EclipseLink> <BEA-2005000> <2012-01-13 20:42:48.126--UnitOfWork(317933487)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
      ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found

      Error Code: 2091
      Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
           bind => [2, 0, 2, 11]
      Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)>
      <Jan 13, 2012 8:42:48 PM PET> <Error> <EJB> <BEA-010026> <Exception occurred during commit of transaction Name=[EJB pe.com.gart.ejb.entities.ForumFacadeBean.persistJiverating(pe.com.bcts.gart.ejb.entities.Jiverating)],Xid=BEA1-001B5FB5B4DB06A00B5F(317932956),Status=Rolled back. [Reason=Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
      ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found

      Error Code: 2091
      Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
           bind => [2, 0, 2, 11]
      Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=30,SCInfo[osinergminWebPortalDesa+WC_Spaces]=(state=rolledback),properties=({weblogic.transaction.name=[EJB pe.com.gart.ejb.entities.ForumFacadeBean.persistJiverating(pe.com.bcts.gart.ejb.entities.Jiverating)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=WC_Spaces+192.168.101.124:9000+osinergminWebPortalDesa+t3+, XAResources={WSATGatewayRM_WC_Spaces_osinergminWebPortalDesa, CustomPortalServicesEJB@Portal@Portal_osinergminWebPortalDesa, webapp@Portal@Portal_osinergminWebPortalDesa},NonXAResources={})],CoordinatorURL=WC_Spaces+192.168.101.124:9000+osinergminWebPortalDesa+t3+): weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion: sync=org.eclipse.persistence.transaction.JTASynchronizationListener@12f34805

      Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
      ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found
      Error Code: 2091
      Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
      *     bind => [2, 0, 2, 11]*Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)
           at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1881)
           at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:345)
           at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:240)
           at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemoteObject.java:627)
           at weblogic.ejb.container.internal.StatelessRemoteObject.postInvoke1(StatelessRemoteObject.java:49)
           at weblogic.ejb.container.internal.BaseRemoteObject.__WL_postInvokeTxRetry(BaseRemoteObject.java:444)
           at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:53)
           at pe.com.gart.ejb.entities.ForumFacade_xgr9io_ForumFacadeImpl.persistJiverating(Unknown Source)
           at pe.com.gart.ejb.entities.ForumFacade_xgr9io_ForumFacadeImpl_WLSkel.invoke(Unknown Source)
           at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
           at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:345)
           at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
           at pe.com.gart.ejb.entities.ForumFacade_xgr9io_ForumFacadeImpl_1035_WLStub.persistJiverating(Unknown Source)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
           at $Proxy247.persistJiverating(Unknown Source)
           at customdiscussions.backing.AddRating.<init>(AddRating.java:51)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
           at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
           at java.lang.Class.newInstance0(Class.java:355)
           at java.lang.Class.newInstance(Class.java:308)
           at oracle.adfinternal.controller.beans.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:187)
           at oracle.adfinternal.controller.beans.ManagedBeanFactory.instantiateBean(ManagedBeanFactory.java:874)
           at oracle.adfinternal.controller.state.ScopeMap.get(ScopeMap.java:83)
           at javax.el.MapELResolver.getValue(MapELResolver.java:164)
           at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
           at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
           at com.sun.el.parser.AstValue.getValue(Unknown Source)
           at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
           at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:250)
           at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:222)
           at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:513)
           at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:782)
           at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1354)
           at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:75)
           at oracle.adfinternal.view.faces.unified.taglib.UnifiedDocumentTag.doStartTag(UnifiedDocumentTag.java:50)
           at jsp_servlet.__addrating_jspx._jspx___tag1(__addrating_jspx.java:154)
           at jsp_servlet.__addrating_jspx._jspx___tag0(__addrating_jspx.java:113)
           at jsp_servlet.__addrating_jspx._jspService(__addrating_jspx.java:74)
           at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
           at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:417)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:326)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
           at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:523)
           at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)
           at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
           at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
           at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
           at oracle.adfinternal.view.faces.config.rich.RecordRequestAttributesDuringDispatch.dispatch(RecordRequestAttributesDuringDispatch.java:45)
           at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
           at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
           at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
           at org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl$OverrideDispatch.dispatch(FacesContextFactoryImpl.java:268)
           at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:471)
           at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:191)
           at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:800)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:294)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:214)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
           at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
           at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
           at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
           at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
           at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
           at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
           at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
           at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
           at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
           at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
           at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
           at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
           at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
      Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
      ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found


      I dont underestand this error beacuse when I execute INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (2, 0, 2, 11) directly on the database I got no error !

      please help me !!!!!
        • 1. Re: EJB 3.0 Constraints Problem
          gimbal2
          ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found
          Well it is a database constraint, so it is the database that is blocking the insertion of the record.
          I dont underestand this error beacuse when I execute INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (2, 0, 2, 11) directly on the database I got no error !
          And did you actually attempt to -commit- the transaction? If you did then I can only conclude one thing: you are using two different databases. One has a constraint, the other does not. Constraints do not magically appear out of thin air, especially ones that generate an ORA error.