No DuplicateKeyException on create

When I call the create method on some home interface, with a key that already exists in the database, I don't get a DuplicateKeyException. Instead a rollback exception occurs when the transaction is committed. This behaviour makes it very difficult to catch the problem early and present the user with a nice message. Does anybody know what can be done about this?

Thanks for your answer. Your solution does mitigate the problem but it doesn't really solve it. I guess it's more general than what I described. I can accept that the PM often doesn't flush changes to the database until commit time, which happens when the business method returns to the container but before the container returns to the client. Any SQL- or JDO exception thrown during this flushing will be logged to the serve log, but the client is only informed that a rollback has occurred. There is no way for the client code to analyze the cause, since the actual exception isn't in the cause chain of the RemoteException thrown to the client.
Wouldn't it be nice if the SQL exception was included in the cause chain of the remote exception. A typical chain would then be:
RemoteException, caused by
RollbackException, caused by
JDODataStoreException, caused by
SQLException
Another nice feature would be if the business method had some way (probably not portable) to force the PM to flush its updates and catch any exceptions.
Any thoughts on this?
- Gunnar

Similar Messages

  • EJB CMP remove create cache issue? DuplicateKeyException

    EJB CMP remove create cache issue? DuplicateKeyException
    Hi I have an EJB 2.1 application using CMP. Most things work fine. But if I in a transaction tries to remove a bean and create a new one with the same primary key I get a DuplicateKeyException:
    2007-11-16 09:25:31,963 ERROR [RMICallHandler-6] AdminGroupData_ConcreteSubClass147 - Error adding AccessRules:
    javax.ejb.DuplicateKeyException: Exception [EJB - 10007]: Exception creating bean of type [AccessRulesData]. Bean already exists.
    at oracle.toplink.internal.ejb.cmp.EJBExceptionFactory.duplicateKeyException(EJBExceptionFactory.java:195)
    I suspect that the remove call only removes from the cache (until commit), but that the create call checks the database or something?
    My code is simple like the following:
    AdminPreferencesDataLocal apdata1 = adminpreferenceshome.findByPrimaryKey(certificatefingerprint);
    adminpreferenceshome.remove(certificatefingerprint);
    adminpreferenceshome.create(certificatefingerprint,newadminpreference);
    Is there some configuration I can set in toplink-ejb-jar.xml to fix this?
    I use OC4j 10.1.3.3
    Cheers,
    Tomas

    The bean.remove() was executed but the sql DELETE was executed to the database as the result, oc4j manages all sql statements and they are optimized to commit to the database in batch at once when the transaction commit. Oc4j ejb container is smart and preventing you from creating the same entity cached in the transaction because the sql delete was not really committed to the database when the create is called.
    My guess is that the reason it works with IBM WAS was because it issued sql for each remove/create call right away instead of doing them in batch as oc4j, or your WAS remove then create were called in separate transactions.

  • Com.sap.sql.DuplicateKeyException in file receiver channel

    Hi experts,
    I am currently testing the following scenario:
    xml file -> file sender ->file receiver -> csv file
    No mapping is used. Both channels are on the same PI 7.1 system.
    The transformation seems to work so far. The only problem I have is that my receiver channel does not post the message to the directory because of this error:
    Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.DuplicateMessageException: Message Id f167e134-145e-4b2c-2d47-e431b8b34fd8(INBOUND) already exists in duplicate check table: com.sap.sql.DuplicateKeyException: [200]: Duplicate key.
    Is it not possible to use file sender and file receiver in the same scenario? Thanks for any help.
    Best regards.
    Oliver.

    Hi André,
    I am using the test option so the message can be processed multiple times. Anyway, I also tried using deletion but I still get the same error. I also tried a completely new file but still no change. When I check the comm channel I see that there is always created a new message id and when I search the rwb it posts two entries. One from the sender step and one from the receiver step. Seems to be alright to me.
    Regards.
    Oliver.

  • GPEngineException Caused by a com.sap.sql.DuplicateKeyException

    Often, we are getting the following error when we do an instance of GP Process from WebDynpro code, however in a second attempt with the same data the GP Process is created successfully: <br>
    <br>
    //----- CODE -
    // <br>
    IGPUserContext userContext = null; <br>
    IWDClientUser wdUser = null; <br>
    IUser user = null; <br>
    IGPProcess process = null; <br>
    IGPRuntimeManager rtm = null; <br>
    IGPProcessRoleInstanceList roles = null; <br>
    IGPStructure params = null; <br>
    <br>
    try { <br>
       wdUser = WDClientUser.getCurrentUser(); <br>
       user = wdUser.getSAPUser(); <br>                         
       userContext = GPContextFactory.getContextManager().createUserContext(user); <br>
       process = GPProcessFactory.getDesigntimeManager().getActiveTemplate(GP_ID, userContext); <br>
       rtm = GPProcessFactory.getRuntimeManager(); <br>
       roles = rtm.createProcessRoleInstanceList(); <br>
       <br>                                        
       params = GPStructureFactory.getStructure(process.getInputParameters()); <br>
       params.setAttributeValue("ORDER_ID", wdContext.currentSalesOrderModelResponseResultElement().getOrderID()); <br>
       params.setAttributeValue("CLIENT_ID", wdContext.currentCustomerDataElement().getCustomerID()); <br>
       <br>                                        
       processName = "Request ofequipment " + wdContext.currentSalesOrderModelResponseResultElement().getOrderID(); <br>
       IGPProcessInstance prInstance = rtm.startProcess(process, processName, processName, user, roles, params, user); <br>
    } catch(Exception e) { <br>
       logger.traceThrowableT(Severity.ERROR, "Request Equipment Error: ", e); <br>
    } <br>
    //----- CODE -
    // <br>
    <br>
    //----- EXCEPTION -
    //<br>
    com.sap.caf.eu.gp.exception.api.GPEngineException: DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, SQLERRMC=1;SAPQNEDB.CAF_GP_PFWRUSRPT, DRIVER=3.53.95
    at com.sap.caf.eu.gp.exception.impl.ExceptionUtil.convertTo(ExceptionUtil.java:36)
    at com.sap.caf.eu.gp.process.rt.impl.GPRuntimeManager.startProcess(GPRuntimeManager.java:150)
    at com.gmodelo.meta.vac018.wd.b.equipmentrequestcomp.EquipmentRequestComp.createEquipmentRequest(EquipmentRequestComp.java:1123)
    at com.gmodelo.meta.vac018.wd.b.equipmentrequestcomp.wdp.InternalEquipmentRequestComp.createEquipmentRequest(InternalEquipmentRequestComp.java:1184)
    at com.gmodelo.meta.vac018.wd.b.equipmentrequestcomp.EquipmentAssignationView.onActionExecuteRequest(EquipmentAssignationView.java:346)
    at com.gmodelo.meta.vac018.wd.b.equipmentrequestcomp.wdp.InternalEquipmentAssignationView.wdInvokeEventHandler(InternalEquipmentAssignationView.java:587)
    at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:131)
    at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:72)
    at com.sap.tc.webdynpro.clientserver.phases.ProcessingEventPhase.doHandleActionEvent(ProcessingEventPhase.java:156)
    at com.sap.tc.webdynpro.clientserver.phases.ProcessingEventPhase.execute(ProcessingEventPhase.java:91)
    at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequestPartly(WindowPhaseModel.java:161)
    at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doProcessRequest(WindowPhaseModel.java:109)
    at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:96)
    at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:469)
    at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:52)
    at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.doExecute(ClientApplication.java:1431)
    at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.doProcessing(ClientApplication.java:1251)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.delegateToApplicationDoProcessing(AbstractExecutionContextDispatcher.java:158)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.DispatchHandlerForAppProcessing.doService(DispatchHandlerForAppProcessing.java:35)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.AbstractDispatchHandler.service(AbstractDispatchHandler.java:116)
    at com.sap.engine.services.servlets_jsp.server.deploy.impl.module.IRequestDispatcherImpl.dispatch(IRequestDispatcherImpl.java:93)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.ExecutionContextDispatcher.dispatchToApplicationDoProcessing(ExecutionContextDispatcher.java:114)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.dispatch(AbstractExecutionContextDispatcher.java:81)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.dispatch(ApplicationSession.java:507)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.dispatch(ApplicationSession.java:527)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doApplicationProcessingPortal(ApplicationSession.java:472)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:251)
    at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:699)
    at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:231)
    at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:231)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.delegateToRequestManager(AbstractExecutionContextDispatcher.java:205)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.DispatchHandlerForRequestManager.doService(DispatchHandlerForRequestManager.java:38)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.AbstractDispatchHandler.service(AbstractDispatchHandler.java:116)
    at com.sap.engine.services.servlets_jsp.server.deploy.impl.module.IRequestDispatcherImpl.dispatch(IRequestDispatcherImpl.java:93)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.ExecutionContextDispatcher.dispatchToRequestManager(ExecutionContextDispatcher.java:140)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.dispatch(AbstractExecutionContextDispatcher.java:93)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.dispatch(AbstractExecutionContextDispatcher.java:105)
    at com.sap.tc.webdynpro.clientserver.session.core.ApplicationHandle.dispatch(ApplicationHandle.java:320)
    at com.sap.tc.webdynpro.clientserver.session.core.ApplicationHandle.doProcessing(ApplicationHandle.java:73)
    at com.sap.tc.webdynpro.portal.pb.impl.LocalApplicationProxy.sendDataAndProcessActionInternal(LocalApplicationProxy.java:1043)
    at com.sap.tc.webdynpro.portal.pb.impl.LocalApplicationProxy.sendDataAndProcessAction(LocalApplicationProxy.java:287)
    at com.sap.portal.pb.PageBuilder.updateApplications(PageBuilder.java:1569)
    at com.sap.portal.pb.PageBuilder.SendDataAndProcessAction(PageBuilder.java:357)
    at com.sap.portal.pb.PageBuilder$PhaseListenerImpl.doPhase(PageBuilder.java:2110)
    at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processPhaseListener(WindowPhaseModel.java:219)
    at com.sap.tc.webdynpro.clientserver.phases.PortalDispatchPhase.execute(PortalDispatchPhase.java:52)
    at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequestPartly(WindowPhaseModel.java:161)
    at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doProcessRequest(WindowPhaseModel.java:109)
    at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:96)
    at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:469)
    at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:52)
    at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.doExecute(ClientApplication.java:1431)
    at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.doProcessing(ClientApplication.java:1251)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.delegateToApplicationDoProcessing(AbstractExecutionContextDispatcher.java:158)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.DispatchHandlerForAppProcessing.doService(DispatchHandlerForAppProcessing.java:35)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.AbstractDispatchHandler.service(AbstractDispatchHandler.java:116)
    at com.sap.engine.services.servlets_jsp.server.deploy.impl.module.IRequestDispatcherImpl.dispatch(IRequestDispatcherImpl.java:93)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.ExecutionContextDispatcher.dispatchToApplicationDoProcessing(ExecutionContextDispatcher.java:114)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.dispatch(AbstractExecutionContextDispatcher.java:81)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.dispatch(ApplicationSession.java:507)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.dispatch(ApplicationSession.java:527)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doApplicationProcessingStandalone(ApplicationSession.java:458)
    at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:249)
    at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:699)
    at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:231)
    at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:231)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.delegateToRequestManager(AbstractExecutionContextDispatcher.java:205)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.DispatchHandlerForRequestManager.doService(DispatchHandlerForRequestManager.java:38)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.AbstractDispatchHandler.service(AbstractDispatchHandler.java:116)
    at com.sap.engine.services.servlets_jsp.server.deploy.impl.module.IRequestDispatcherImpl.dispatch(IRequestDispatcherImpl.java:93)
    at com.sap.tc.webdynpro.serverimpl.wdc.sessionctx.ExecutionContextDispatcher.dispatchToRequestManager(ExecutionContextDispatcher.java:140)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.dispatch(AbstractExecutionContextDispatcher.java:93)
    at com.sap.tc.webdynpro.serverimpl.core.sessionctx.AbstractExecutionContextDispatcher.dispatch(AbstractExecutionContextDispatcher.java:105)
    at com.sap.tc.webdynpro.serverimpl.core.AbstractDispatcherServlet.doContent(AbstractDispatcherServlet.java:87)
    at com.sap.tc.webdynpro.serverimpl.core.AbstractDispatcherServlet.doPost(AbstractDispatcherServlet.java:61)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at com.sap.engine.services.servlets_jsp.server.Invokable.invoke(Invokable.java:66)
    at com.sap.engine.services.servlets_jsp.server.Invokable.invoke(Invokable.java:32)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:431)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:289)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:376)
    at com.sap.engine.services.servlets_jsp.filters.ServletSelector.process(ServletSelector.java:85)
    at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:71)
    at com.sap.engine.services.servlets_jsp.filters.ApplicationSelector.process(ApplicationSelector.java:160)
    at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:71)
    at com.sap.engine.services.httpserver.filters.WebContainerInvoker.process(WebContainerInvoker.java:67)
    at com.sap.engine.services.httpserver.chain.HostFilter.process(HostFilter.java:9)
    at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:71)
    at com.sap.engine.services.httpserver.filters.ResponseLogWriter.process(ResponseLogWriter.java:60)
    at com.sap.engine.services.httpserver.chain.HostFilter.process(HostFilter.java:9)
    at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:71)
    at com.sap.engine.services.httpserver.filters.DefineHostFilter.process(DefineHostFilter.java:27)
    at com.sap.engine.services.httpserver.chain.ServerFilter.process(ServerFilter.java:12)
    at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:71)
    at com.sap.engine.services.httpserver.filters.MonitoringFilter.process(MonitoringFilter.java:29)
    at com.sap.engine.services.httpserver.chain.ServerFilter.process(ServerFilter.java:12)
    at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:71)
    at com.sap.engine.services.httpserver.server.Processor.chainedRequest(Processor.java:295)
    at com.sap.engine.services.httpserver.server.Processor$FCAProcessorThread.run(Processor.java:222)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:152)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:247)
    Caused by: com.sap.sql.DuplicateKeyException: DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, SQLERRMC=1;SAPQNEDB.CAF_GP_PFWRUSRPT, DRIVER=3.53.95
    at com.sap.sql.jdbc.common.CommonPreparedStatement.executeUpdate(CommonPreparedStatement.java:355)
    at com.sap.sql.jdbc.common.CommonPreparedStatement.execute(CommonPreparedStatement.java:917)
    at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.execute(PreparedStatementWrapper.java:269)
    at com.sap.caf.eu.gp.model.pfw.core.impl.UserProvidedDataManager.setTexts(UserProvidedDataManager.java:326)
    at com.sap.caf.eu.gp.model.pfw.core.impl.UserProvidedDataManager.updateTexts(UserProvidedDataManager.java:357)
    at com.sap.caf.eu.gp.model.pfw.core.impl.ProcessRuntime.startProcess(ProcessRuntime.java:1141)
    at com.sap.caf.eu.gp.process.rt.impl.GPRuntimeManager.startProcess(GPRuntimeManager.java:148)<br>
    //----- EXCEPTION -
    //<br>
    <br>
    Regards<br>
    FSC<br>
    Edited by: Fernando Salgado on Mar 9, 2011 12:02 AM

    Hey Anil,
    maybe this thread will help:
    https://forums.sdn.sap.com/click.jspa?searchID=734730&messageID=2934036
    Regards
    Dominic

  • How to Create and Remove CMP Entity with Toplink in same transaction??

    Hi, i have a problem to create and delete cmp intances with toplink.
    I create a entity bean and remove the same entity bean in the same transaction.
    ie. my method have this code:
    bean a = homeBean.create(pk);
    a.remove();
    bean a = homeBean.create(pk);
    this code throws a javax.ejb.DuplicateKeyException
    Toplink not remove CMP, execute the two calls of create first.
    What configure toplink to support this case ??
    Is this possible ??
    I Can't controling the transaction manualy i'm using CMP entity beans with CMT.
    tanks.
    Message was edited by:
    Carlos Lacerda

    BM,
    If you want to import the utils package into your code, then the location of the utils package has to be in your CLASSPATH. JDeveloper uses libraries to define a project's CLASSPATH.
    I'm not sure exactly what's going on here, but you might want to read the information about packages and class libraries in the online documentation. It's under:
    User Guides
    -> Working with JDeveloper
    -> Packages and Class Libraries
    Blaise

  • Inconsistent DuplicateKeyException

    Hi,
    I'm getting those Exceptions, (deeply nested)
    com.sap.dbtech.jdbc.exceptions.BatchUpdateExceptionSapDB: [250] (at 2): Duplicate secondary key:EIC_TYPES_I(input position 3)
    com.sap.sql.DuplicateKeyException
    instead of
    javax.ejb.DuplicateKeyException
    is this compliant?
    anyway it's ugly ...

    Hi Konrad,
    to my knowledge, javax.ejb.DuplicateKeyException is an EJB 2.1 exception indicating the atempt to create an entity bean, which already exists.
    The com.sap.sql.DuplicateKeyException in an SQLException, which indicates a unique constraint violation on the database.
    I hope this helps.
    -Adrian

  • Catching javax.ejb.DuplicateKeyException

    Here is the situation.
    A weblogic workshop control calls a message bean.
    The message bean calls a session bean.
    The session beans does some junk and creates an entity bean.
    During the create there is a possibilty of a javax.ejb.DuplicateKeyException being
    thrown.
    I am trying to catch this exception but for some reason the weblogic server is
    catching and
    and trying to restart the transaction by calling the message bean again.
    By doing this it is an enless cycle of errors that will not stop untill you shut
    down the weblogic server.
    How can I catch this error to prevent this loop from happening?

    Thanks for the response and the direction.
    Its Bug No.6713854
    Could you please shed some light on toplink flavors and support/fixes.
    That is:
    1. Is toplink that comes with OAS different than the open source toplink?
    2. If so, how are bugs tracked. where should I go and look for the bugs for the open source version?
    3. Could we use the open source version for OC4J?
    Thanks :)

  • Javax.ejb.DuplicateKeyException: Exception [EJB - 10007]

    Hi,
    I am deploying an EJB application in OAS10.1.3.1. (it comes with toplink)
    The application executes bean.remove() and removes the bean and then it creates
    the same bean again using bean.create() in the same transaction.
    When bean.create() executes the following exception is encountered.
    Is there any setting in toplink that will help me avoid this situation.
    javax.ejb.DuplicateKeyException: Exception [EJB - 10007]: Exception creating bean of type [XXXX]. Bean already exists.
    at oracle.toplink.internal.ejb.cmp.EJBExceptionFactory.duplicateKeyException(EJBExceptionFactory.java:195)
         at oracle.toplink.internal.ejb.cmp.oc4j.Oc4jPersistenceManager.createBean(Oc4jPersistenceManager.java:163)
         at com.evermind.server.ejb.interceptor.system.TopLinkCreateInterceptor.invoke(TopLinkCreateInterceptor.java:51)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.SecurityRoleInterceptor.invoke(SecurityRoleInterceptor.java:47)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
         at com.evermind.server.ejb.AbstractEJBHome.OC4J_invokeMethod(AbstractEJBHome.java:723)

    Thanks for the response and the direction.
    Its Bug No.6713854
    Could you please shed some light on toplink flavors and support/fixes.
    That is:
    1. Is toplink that comes with OAS different than the open source toplink?
    2. If so, how are bugs tracked. where should I go and look for the bugs for the open source version?
    3. Could we use the open source version for OC4J?
    Thanks :)

  • DuplicateKeyException is not thrown

    I have WL7, SP1.
    Trying to create a duplicate entry into the db using an entity bean.Instead of
    throwing a DuplicateKeyException, it always throw EJBException.
    Is it a bug?

    I doubt that is the case.
    If the JVM does not find a class (it has nothing to do with jars) it throws the exception.
    So if isn't throwing it then it is finding it somewhere.
    There are possible reasons for this. For example if the class tree is in the class path (along with the jar.)

  • DuplicateKeyException not thrown by WL7.0

    Hello,
    When I call a Create on an entity CMP from a Session bean(using the local interface),
    where the ejbCreate insertion violate the unicity primary key constraint, The
    WL container raise a LocalTransactionRollBackException (with a cause attribute
    embedding a DuplicateKeyException).
    This is a very tedious behaviour as the session can't catch the DuplicateKeyException.
    Do you think this is a correct behaviour ? Do you find the same kind of behaviour
    ? Is there some clean known workaround (different from testing the primary key
    existance before creating the bean)
    It's seems to me that this is a very limit interpretation of the spec (which is
    not very precise on the subject and let to much freedom on the subject, I admit)
    Here is what says the ejb 2.0 spec :
    ====================================
    10.5.8.2 DuplicateKeyException
    The DuplicateKeyException is a subclass of CreateException. It may be thrown by
    the
    Container to indicate to the client or local client that the entity object cannot
    be created because an
    entity object with the same key already exists. The unique key causing the violation
    may be the primary
    key, or another key defined in the underlying database.
    Normally, the Container should not mark the transaction for rollback before throwing
    the exception.
    When the client or local client receives a DuplicateKeyException, the client knows
    that the
    entity was not created, and that the transaction has not typically been marked
    for rollback.
    I hate the 2 words in the previous spec section : "may be" and "Normaly", which
    allows to have too much different behaviour from one Container to another. But
    if DuplicateKeyException cannot be directly catch, what would be its interest

    I think this is a bug. I've encountered similar problem using WL7 + Sybase
    12 Server. I was getting some kind of EJB exception, which was wrapping SQL
    exception. Considering that CreateException is the application exception, WL
    behaviour differs from what is required in 18.3.1. WL behaves as if
    CreateException was a system exception.
    Actually, it is not the exception type I am bothered with. What really
    upsets me is that contaner rolls back the transaction and there is no way to
    continue it. This sucks. Maybe I should file a bug 6 months ago?
    Michael J.
    "nicolas frank" <[email protected]> wrote in message
    news:[email protected]...
    >
    Hello,
    When I call a Create on an entity CMP from a Session bean(using the localinterface),
    where the ejbCreate insertion violate the unicity primary key constraint,The
    WL container raise a LocalTransactionRollBackException (with a causeattribute
    embedding a DuplicateKeyException).
    This is a very tedious behaviour as the session can't catch theDuplicateKeyException.
    >
    >
    Do you think this is a correct behaviour ? Do you find the same kind ofbehaviour
    ? Is there some clean known workaround (different from testing the primarykey
    existance before creating the bean)
    It's seems to me that this is a very limit interpretation of the spec(which is
    not very precise on the subject and let to much freedom on the subject, Iadmit)
    Here is what says the ejb 2.0 spec :
    ====================================
    10.5.8.2 DuplicateKeyException
    The DuplicateKeyException is a subclass of CreateException. It may bethrown by
    the
    Container to indicate to the client or local client that the entity objectcannot
    be created because an
    entity object with the same key already exists. The unique key causing theviolation
    may be the primary
    key, or another key defined in the underlying database.
    Normally, the Container should not mark the transaction for rollbackbefore throwing
    the exception.
    When the client or local client receives a DuplicateKeyException, theclient knows
    that the
    entity was not created, and that the transaction has not typically beenmarked
    for rollback.
    I hate the 2 words in the previous spec section : "may be" and "Normaly",which
    allows to have too much different behaviour from one Container to another.But
    if DuplicateKeyException cannot be directly catch, what would be itsinterest

  • Unable to save workflow types and create workflow stage  in CUP

    Hi Guru's,
    We are currently installling GRC AC 5.3 and are stuck in configuration.
    we are unable to create workflow stage in CUP. Whenever we try to open the tab for stage it gives below mentioned error.
    Webpage error details
    Message: Expected ';'
    Line: 757
    Char: 15
    Code: 0
    URI: http://172.25.7.32:50000/AE/scrLeftNav.linkConfigWorkFlowStages.do
    Also while tryinng to save workflow types under "miscellaneous" we encounter error - Error saving workflow types
    On further checking system log we found the below details --
    Caused by: com.sap.sql.DuplicateKeyException: ORA-00001: unique constraint (SAPSR3DB.VI_AE_CTMDT_LOC1) violated
         at com.sap.sql.jdbc.common.CommonPreparedStatement.executeUpdate(CommonPreparedStatement.java:259)
         at com.sap.sql.sqlj.runtime.profile.ref.RTStatementJDBCPrepared.executeUpdate(RTStatementJDBCPrepared.java:267)
         at sqlj.runtime.ExecutionContext$StatementFrame.executeUpdate(ExecutionContext.java:1124)
         at sqlj.runtime.ExecutionContext.executeUpdate(ExecutionContext.java:718)
         at com.virsa.ae.dao.sqlj.CustomAppDetDAO.insertCustomAppDetDetails(CustomAppDetDAO.sqlj:1022)
    Please advice how it can be remediated.
    Thanks
    Akshay Daniel

    Hi Akshay,
    It seems you have uploaded some wrong file .
    I would suggest you to delete those entries from table.
    please check for the  duplicate entry in u r workflow type under miscellaneous tab in CUP.
    for example if you find duplicate entry for work flow type  RE that is ERM ,   And the Work flow type ERM gives you error while saving request type .then please look for the table VIRSA_AE_WFTYPE   in file AE_init_append_data_RE.xml   and follow the below  mentioned  steps:
    1. log in  to SQL with SYSDBA access delete the duplicate entry.
    2.use  below command to find the
    SQL> select * from SAPSR3DB.VIRSA_AE_WFTYPE where NAME='ERM'
    3. delete this Row form the table.
    4. restart AS java
    After deleting this  duplicate entry your issue should get resolved.
    please let em know if your issue is resolved
    Edited by: prashntk on Jul 21, 2011 10:48 AM

  • Cannot create CMP bean, Error: "Werent current caller"

    Hi,
    I generated a CMP entity ejbean with JDeveloper and deployed it. I can use that bean with a client and retrieve a specific instance using the home interface's findByPrimaryKey() method.
    But I can not create a new bean using the home interface's create( long newPrimKey) method. The following error occures only if the specified newPrimKey is not occupied yet. If I use an occupied key, I get an expectable "javax.ejb.DuplicateKeyException"...
    java.lang.InternalError: Werent current caller, server stacktrace (to disable this message, use -Dejb.assert=false at startup): java.lang.Throwable: Werent current caller
         at Person_EntityBeanWrapper11.setEntityBean(Person_EntityBeanWrapper11.java:5404)
         at com.evermind.server.ejb.EntityEJBHome.passivateAndRelease(EntityEJBHome.java:344)
         at com.evermind.server.ejb.EntityEJBObject.releaseContext(EntityEJBObject.java:378)
         at PersonHome_EntityHomeWrapper13.create(PersonHome_EntityHomeWrapper13.java:542)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:80)
         at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         de.fiscus.sfs.cmp.Person __Proxy0.create(long)
         void SamplePersonClient1.main(java.lang.String[])
    Any idea?? I'm really stuck with this!
    Thank you.
    CU, Chris

    Chris,
    The problem is that both clients and EJBs are in the same server and you are using RMIInitialContextFactory. You have to use default context and package this client in the same EAR. Please look at http://otn.oracle.com/sample_code/tech/java/oc4j/htdocs/oc4jsamplecode/oc4j-demo-ejb.html#CMP for samples. Also some EJB/client sample programs are packaged with Oc4J disand you can find at $IAS_HOME/j2ee/home/demo/cmp distribution ctory.
    However the client program should work fine if your client and EJBs are running on different Oc4J containers.
    regards
    Debu
    Hi Debu,
    the client is a java application. Here is the code:
    [...in main method...]
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "admin");
    env.put(Context.PROVIDER_URL, "ormi://CHRISTIANE/statful");
    Context ctx = new InitialContext(env);
    PersonHome personHome = (PersonHome)ctx.lookup("Person");
    Person person;
    person = personHome.create( 14261026 );
    CU, Chris

  • CUP 5.3 - Error creating request

    Dear expert,
    We have installed GRC Access control 5.3 (support package 8.0) and are facing a problem when trying to create a request in CUP:
    When creating a new request, we always get the error message "Error creating request" after trying to submit.  There seems to be no apparent problem with the workflow and we have filled out all mandatory fields.
    Thanks for your help in advance!
    Regards,
    Felix Poeschl

    Hello Alpesh, hello Shweta,
    We're pretty sure that the initiator is set correctly.  (The only condition for it to be actived is that a certain employee type is selected, which we select accordingly during request creation.)
    Below are the sections of the log durch creation of the request, where an error message appears.
    Thanks for your help!
    Regards,
    Felix
    1)
    2009-07-13 09:32:31,015 [SAPEngine_Application_Thread[impl:3]_8] ERROR com.virsa.ae.dao.sqlj.RequestDataHeaderDAO : insertUsers(IAETransaction txn,String reqNo,List listRequestDataUserDTOs) :   : SqlException occured, reqNo= 44 exception=[SAP_NWmss][SQLServer JDBC Driver][SQLServer]The INSERT statement conflicted with the FOREIGN KEY constraint "VF_AE_RQD_USERS_1". The conflict occurred in database "ERP", table "SAPERPDB.VIRSA_AE_REQD_HDR", column 'REQNO'.
    com.sap.sql.DuplicateKeyException: [SAP_NWmss][SQLServer JDBC Driver][SQLServer]The INSERT statement conflicted with the FOREIGN KEY constraint "VF_AE_RQD_USERS_1". The conflict occurred in database "ERP", table "SAPERPDB.VIRSA_AE_REQD_HDR", column 'REQNO'.
         at com.sap.sql.jdbc.common.CommonPreparedStatement.executeUpdate(CommonPreparedStatement.java:259)
         at com.sap.sql.sqlj.runtime.profile.ref.RTStatementJDBCPrepared.executeUpdate(RTStatementJDBCPrepared.java:267)
         at sqlj.runtime.ExecutionContext$StatementFrame.executeUpdate(ExecutionContext.java:1124)
         at sqlj.runtime.ExecutionContext.executeUpdate(ExecutionContext.java:718)
         at com.virsa.ae.dao.sqlj.RequestDataHeaderDAO.insertUsers(RequestDataHeaderDAO.sqlj:578)
         at com.virsa.ae.accessrequests.bo.RequestBO.saveUsers(RequestBO.java:1505)
         at com.virsa.ae.accessrequests.bo.RequestBO.saveNewRequest(RequestBO.java:359)
         at com.virsa.ae.accessrequests.actions.CreateRequestAction.createRequest(CreateRequestAction.java:268)
         at com.virsa.ae.accessrequests.actions.CreateRequestAction.execute(CreateRequestAction.java:89)
         at com.virsa.ae.commons.utils.framework.NavigationEngine.execute(NavigationEngine.java:295)
         at com.virsa.ae.commons.utils.framework.servlet.AEFrameworkServlet.service(AEFrameworkServlet.java:431)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    2)
    2009-07-13 09:32:31,015 [SAPEngine_Application_Thread[impl:3]_8] ERROR Exception in saving the request
    com.virsa.ae.dao.DAOException: [SAP_NWmss][SQLServer JDBC Driver][SQLServer]The INSERT statement conflicted with the FOREIGN KEY constraint "VF_AE_RQD_USERS_1". The conflict occurred in database "ERP", table "SAPERPDB.VIRSA_AE_REQD_HDR", column 'REQNO'.
         at com.virsa.ae.dao.sqlj.RequestDataHeaderDAO.insertUsers(RequestDataHeaderDAO.sqlj:605)
         at com.virsa.ae.accessrequests.bo.RequestBO.saveUsers(RequestBO.java:1505)
         at com.virsa.ae.accessrequests.bo.RequestBO.saveNewRequest(RequestBO.java:359)
         at com.virsa.ae.accessrequests.actions.CreateRequestAction.createRequest(CreateRequestAction.java:268)
         at com.virsa.ae.accessrequests.actions.CreateRequestAction.execute(CreateRequestAction.java:89)
         at com.virsa.ae.commons.utils.framework.NavigationEngine.execute(NavigationEngine.java:295)
         at com.virsa.ae.commons.utils.framework.servlet.AEFrameworkServlet.service(AEFrameworkServlet.java:431)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.sql.DuplicateKeyException: [SAP_NWmss][SQLServer JDBC Driver][SQLServer]The INSERT statement conflicted with the FOREIGN KEY constraint "VF_AE_RQD_USERS_1". The conflict occurred in database "ERP", table "SAPERPDB.VIRSA_AE_REQD_HDR", column 'REQNO'.
         at com.sap.sql.jdbc.common.CommonPreparedStatement.executeUpdate(CommonPreparedStatement.java:259)
         at com.sap.sql.sqlj.runtime.profile.ref.RTStatementJDBCPrepared.executeUpdate(RTStatementJDBCPrepared.java:267)
         at sqlj.runtime.ExecutionContext$StatementFrame.executeUpdate(ExecutionContext.java:1124)
         at sqlj.runtime.ExecutionContext.executeUpdate(ExecutionContext.java:718)
         at com.virsa.ae.dao.sqlj.RequestDataHeaderDAO.insertUsers(RequestDataHeaderDAO.sqlj:578)
         ... 21 more
    3)
    2009-07-13 09:32:31,015 [SAPEngine_Application_Thread[impl:3]_8] ERROR BO Exception in Save request
    com.virsa.ae.core.BOException: [SAP_NWmss][SQLServer JDBC Driver][SQLServer]The INSERT statement conflicted with the FOREIGN KEY constraint "VF_AE_RQD_USERS_1". The conflict occurred in database "ERP", table "SAPERPDB.VIRSA_AE_REQD_HDR", column 'REQNO'.
         at com.virsa.ae.accessrequests.bo.RequestBO.saveNewRequest(RequestBO.java:443)
         at com.virsa.ae.accessrequests.actions.CreateRequestAction.createRequest(CreateRequestAction.java:268)
         at com.virsa.ae.accessrequests.actions.CreateRequestAction.execute(CreateRequestAction.java:89)
         at com.virsa.ae.commons.utils.framework.NavigationEngine.execute(NavigationEngine.java:295)
         at com.virsa.ae.commons.utils.framework.servlet.AEFrameworkServlet.service(AEFrameworkServlet.java:431)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.virsa.ae.dao.DAOException: [SAP_NWmss][SQLServer JDBC Driver][SQLServer]The INSERT statement conflicted with the FOREIGN KEY constraint "VF_AE_RQD_USERS_1". The conflict occurred in database "ERP", table "SAPERPDB.VIRSA_AE_REQD_HDR", column 'REQNO'.
         at com.virsa.ae.dao.sqlj.RequestDataHeaderDAO.insertUsers(RequestDataHeaderDAO.sqlj:605)
         at com.virsa.ae.accessrequests.bo.RequestBO.saveUsers(RequestBO.java:1505)
         at com.virsa.ae.accessrequests.bo.RequestBO.saveNewRequest(RequestBO.java:359)
         ... 19 more
    Caused by: com.sap.sql.DuplicateKeyException: [SAP_NWmss][SQLServer JDBC Driver][SQLServer]The INSERT statement conflicted with the FOREIGN KEY constraint "VF_AE_RQD_USERS_1". The conflict occurred in database "ERP", table "SAPERPDB.VIRSA_AE_REQD_HDR", column 'REQNO'.
         at com.sap.sql.jdbc.common.CommonPreparedStatement.executeUpdate(CommonPreparedStatement.java:259)
         at com.sap.sql.sqlj.runtime.profile.ref.RTStatementJDBCPrepared.executeUpdate(RTStatementJDBCPrepared.java:267)
         at sqlj.runtime.ExecutionContext$StatementFrame.executeUpdate(ExecutionContext.java:1124)
         at sqlj.runtime.ExecutionContext.executeUpdate(ExecutionContext.java:718)
         at com.virsa.ae.dao.sqlj.RequestDataHeaderDAO.insertUsers(RequestDataHeaderDAO.sqlj:578)
         ... 21 more

  • Strange duplicate key error on doing remove/create

    Hi,
    I am trying to delete a bunch of entities and then re-use the primary keys to
    insert a bunch of new ones, all within the same transaction. I am using WL6.1
    (EJB2.0), sp1 on NT.
    I use the home.ejbRemove (pk) method to remove the beans, and then the appropriate
    create method to create the new instances. 98% of the time this seems to work;
    I see the delete statements issued to the database and the assocaited create statements.
    Every now and then I get the following error:
    javax.ejb.DuplicateKeyException: Bean with primary key: 'AssociateActivity Primary
    Keycom.Timesheets.domainBean.AssociateActivityPK@962f6d6f
    AssocaiteId : 130.00
    AssociateActivityId : 204841.00' already exists.
    Yet I still see the delete statement for the PK in question issued to the db,
    and everything looks the same as it does when the TX succeeds - but in this case
    its as if somehow the entity isnt getting deleted from the WL cache in a timely
    fashion. I see that the 'delay_updates_until_end_of_tx' could be set to false,
    but isnt this a database-related parameter? I have set this up and am re-testing,
    but it is hard to produce this error, so I am not comfortable testing a while
    and saying its gone. Does anyone know why I might be seeing this error, and shed
    some insight as to whether this parameter will fix it for me?
    Thanks in advance !
    Caroline.

    Hi Rob,
    thanks for your reply. The beans are CMP. I agree, updating makes more sense -
    this is (now) legacy code written by another engineer, and they didnt want to
    deal with updates. It doesnt sound as thought this problem should be happening,
    though, and that is concerning. I will keep an eye on if - if I see this intermittent
    problem again, maybe I wll bite the bullet and change the algorithms to do just
    that. Of course, we are in test mode and getting software out is our primary goal
    right now. If you have any other suggestions, I would appreciate them.
    Thanks,
    Caroline.
    Rob Woollen <[email protected]> wrote:
    WLS doesn't currently delay deletes so it should have removed the entry
    from the cache
    before you called create.
    Are these BMP or CMP beans?
    Our of curiousity, why not just update the beans instead of deleting
    and re-creating?
    -- Rob
    Caroline Day wrote:
    Hi,
    I am trying to delete a bunch of entities and then re-use the primarykeys to
    insert a bunch of new ones, all within the same transaction. I am usingWL6.1
    (EJB2.0), sp1 on NT.
    I use the home.ejbRemove (pk) method to remove the beans, and thenthe appropriate
    create method to create the new instances. 98% of the time this seemsto work;
    I see the delete statements issued to the database and the assocaitedcreate statements.
    Every now and then I get the following error:
    javax.ejb.DuplicateKeyException: Bean with primary key: 'AssociateActivityPrimary
    Keycom.Timesheets.domainBean.AssociateActivityPK@962f6d6f
    AssocaiteId : 130.00
    AssociateActivityId : 204841.00' already exists.
    Yet I still see the delete statement for the PK in question issuedto the db,
    and everything looks the same as it does when the TX succeeds - butin this case
    its as if somehow the entity isnt getting deleted from the WL cachein a timely
    fashion. I see that the 'delay_updates_until_end_of_tx' could be setto false,
    but isnt this a database-related parameter? I have set this up andam re-testing,
    but it is hard to produce this error, so I am not comfortable testinga while
    and saying its gone. Does anyone know why I might be seeing this error,and shed
    some insight as to whether this parameter will fix it for me?
    Thanks in advance !
    Caroline.

  • Create with duplicate key throws BaseEJBException instead of DuplicateKeyEx

    WAS640 SP9: implemented an entity EJB, with a primary key field that is a String. The database table has the mapped column as a key. create(keyfield) works fine (I can get the data out with either sqlcli or through the EJB). If I try to add a 2nd bean with the same primary key, I don't get the javax.ejb.DuplicateKeyException that I would expect, I get get a com.sap.engine.services.ejb.exceptions.BaseEJBException (trace at end of message)
    Any idea what I am doing incorrectly?
    com.sap.engine.services.ejb.exceptions.BaseEJBException: Transaction system failure in method com.whirlpool.stock.ejb.StockLocalHomeImpl0.create(java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean).
         at com.whirlpool.stock.ejb.StockLocalHomeImpl0.create(StockLocalHomeImpl0.java:479)
         at com.whirlpool.stock.ejb.StockProcessorBean.createStock(StockProcessorBean.java:86)
         at com.whirlpool.stock.ejb.StockProcessorObjectImpl0.createStock(StockProcessorObjectImpl0.java:119)
         at com.whirlpool.stock.ejb.StockProcessor_Stub.createStock(StockProcessor_Stub.java:64)
         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:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy67.createStock(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:324)
         at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:146)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:68)
         at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
         at SoapServlet.doPost(SoapServlet.java:51)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.engine.services.ts.exceptions.BaseRollbackException: Exception in beforeCompletition of ( SAP J2EE Engine JTA Transaction : [075ffffffd56e000e] ).
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:217)
         at com.whirlpool.stock.ejb.StockLocalHomeImpl0.create(StockLocalHomeImpl0.java:452)
         ... 34 more
    Caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException while the data is being flushed. The persistent object is com.whirlpool.stock.ejb.StockBean0Persistent.
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:101)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.beforeCompletion(TransactionContext.java:506)
         at com.sap.engine.services.ejb.entity.SynchronizationList.beforeCompletion(SynchronizationList.java:136)
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:205)
         ... 35 more
    Caused by: com.sap.sql.DuplicateKeyException: [200]: Duplicate key
         at com.sap.sql.jdbc.common.CommonPreparedStatement.executeUpdate(CommonPreparedStatement.java:326)
         at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:240)
         at com.whirlpool.stock.ejb.StockBean0Persistent.ejb_iInsert(StockBean0Persistent.java:443)
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:92)
         ... 40 more
    com.sap.engine.services.ts.exceptions.BaseRollbackException: Exception in beforeCompletition of ( SAP J2EE Engine JTA Transaction : [075ffffffd56e000e] ).
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:217)
         at com.whirlpool.stock.ejb.StockLocalHomeImpl0.create(StockLocalHomeImpl0.java:452)
         at com.whirlpool.stock.ejb.StockProcessorBean.createStock(StockProcessorBean.java:86)
         at com.whirlpool.stock.ejb.StockProcessorObjectImpl0.createStock(StockProcessorObjectImpl0.java:119)
         at com.whirlpool.stock.ejb.StockProcessor_Stub.createStock(StockProcessor_Stub.java:64)
         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:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy67.createStock(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:324)
         at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:146)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:68)
         at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
         at SoapServlet.doPost(SoapServlet.java:51)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException while the data is being flushed. The persistent object is com.whirlpool.stock.ejb.StockBean0Persistent.
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:101)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.beforeCompletion(TransactionContext.java:506)
         at com.sap.engine.services.ejb.entity.SynchronizationList.beforeCompletion(SynchronizationList.java:136)
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:205)
         ... 35 more
    Caused by: com.sap.sql.DuplicateKeyException: [200]: Duplicate key
         at com.sap.sql.jdbc.common.CommonPreparedStatement.executeUpdate(CommonPreparedStatement.java:326)
         at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:240)
         at com.whirlpool.stock.ejb.StockBean0Persistent.ejb_iInsert(StockBean0Persistent.java:443)
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:92)
         ... 40 more

    Hi Douglas,
    The answer is that the EJB container does not have to throw DuplicateKeyException in case of an attempt for creating an already existing entity object. The EJB 2.0 specification, chapter 10.5.3 says "The container may, but is not required to, throw the DuplicateKeyException on the Bean Provider’s attempt to create an entity object with a duplicate primary key[15]." And the explanation follows in the footnote "[15] Containers using optimistic caching strategies, for example, may rollback the transaction at a later point."
    In fact this is what happens in your case – the EJB container postpones the insert database operation for the end of the transaction, thus optimizing the number of database access calls. Then, the primary key constraint violation is detected by the database, which leads to transaction rollback, but nevertheless an exception different from DuplicateKeyException is thrown.
    The EJB container can detect primary key constraint violation in case two entities with the same primary keys are created in one transaction and then to throw the DuplicateKeyException (you can check this).
    The conclusion is that EJB applications cannot rely on the DuplicateKeyException to distinguish the case when  primary key constraint is violated. The EJB container can improve the primary key constraint violation handling  by introducing an additional option for immediately storing a newly created entity object, thus checking whether an entity with the same primary key already exists and throwing DuplicateKeyException. This option will be introduced with the next versions of the EJB container, but nevertheless it again does not cover all possible scenarios. So my advice is simply to not rely on the DuplicateKeyException to distinguish primary key constraint violation from other transaction failures.
    Best regards,
    Viliana

Maybe you are looking for

  • How to display the outline of a DelegateShape?

    I want to draw the outline of a DelegateShape. In the script below two stages are created, A and B. Each displays the same defined Circle. In A it appears as a black filled circle. In B it shows (correctly) as a red outlined circle. How do I get an o

  • Expanding iTunes fields to handle more info about each CD (Mac & PC)

    The LP and CD covers often hold a lot of important info about the album, music and artist, producer, history. With the use of physical album covers on the decline as we use iTunes/mp3s more and more, a lot of liner notes and credits are no longer wit

  • Gui program doesn't look good with startx

    I did not install a DE in arch linux, just to keep it lightweight. However, my GUI application doesn't look good running with start x. is there any package I can install to make it look better, like fonts, visuals, or the only way is to install eithe

  • Is it possible to have cs5 Bridge open cs4 ai files actually in cs4 rather than opening them in cs5

    I recently upgraded from mac cs4 to cs5.5. Due to a bug? with cs5 ai illustrator 'Pixel Preview' won't show 1 bit tiff files as it did in cs4 (the workaround is time consuming/wasting). This is a problem for me as most of my files contain them, GGrrr

  • CRM-XI-File Scenario

    Hi all, I am working on CRM-XI Scenario. I have no idea about this CRM. but i have to pick data from CRM to XI. >>so i request, ...........please give me some guidance....& Blogs.... for this. >>>I want to use here RFC/Idos........... please help....