Optimistic Lock Exception handler

Hi,
In my session bean, i am trying to handle the optimistic error but always get the standard error page.
My sample code is:
Public MyObject updateMyObject (MyObject myObject) {
try {
em.merge(myObject);
catch (OptimisticLockException e) {
return myObject;
kindly advise how can i handle the exception programmatically en refresh the entity.
Regards

Hi,
are you using JPA or TopLink ? Check if there is another exception thrown that produces the error. You can try and catch (Exception ex), which will catch them all. if this works the obviously you don't catch the right exception
I found a post saying that: "If you trying commit directly after persist w/o doing an explicit
flush then OptimisticLocking Exception maybe nested inside
RollBackException. What is the top most error on stack? You can catch
javax.persistence.PersistenceException and try to do this kind of
error translation
public static void getThrowable(javax.persistence.PersistenceException
perex, int code) {
boolean updateError = false ;
boolean deleteError = false ;
KentException kentex = null ;
Throwable th = null ;
if( perex instanceof org.apache.openjpa.persistence.RollbackException) {
th = perex.getCause();
if(th instanceof OptimisticLockException) {
updateError = true ;
if(perex instanceof OptimisticLockException ){
updateError = true ;
th = perex ;
if(perex instanceof org.apache.openjpa.persistence.EntityNotFoundException) {
deleteError = true ;
th = perex ;
http://n2.nabble.com/OptimisticLockException-confusion.-td210621.html
Frank

Similar Messages

  • Em.merge does not throw Optimistic Lock Exception

    Hello,
    we are using Optimistic Lock Exception in a stateful bean managed transaction.
    I am wondering that there is no Optimistic Lock Exception is thrown after em.merge
    The Optimistic Lock Exception is primary thrown on em.flush - is this right?
    A similar problem is described on
    http://www.nabble.com/Optimistic-Lock-Exception-expected-td22742662.html#a22742662
    See serveroutput: The EclipseLink-5006-Exception is thrown after an em.flush
    14:03:11,657 INFO [STDOUT] updateItem
    14:03:11,657 INFO [STDOUT] [EL Finest]: 2009-04-09 14:03:11.657--UnitOfWork(14218007)--Thread(WorkerThread#0[192.168.1.217:4518])--Merge clone with references com.tup.model.Person@131a24c
    14:03:11,657 INFO [STDOUT] merged
    14:03:11,657 INFO [STDOUT] [EL Finest]: 2009-04-09 14:03:11.657--UnitOfWork(14218007)--Thread(WorkerThread#0[192.168.1.217:4518])--Execute query UpdateObjectQuery(com.tup.model.Person@196649c)
    14:03:11,657 INFO [STDOUT] [EL Fine]: 2009-04-09 14:03:11.657--ClientSession(21268424)--Connection(25845065)--Thread(WorkerThread#0[192.168.1.217:4518])--UPDATE mku_person_ver SET first_name = ? WHERE ((ID = ?) AND (((last_name = ?) AND (first_name = ?)) AND (version = ?)))
    bind => [Bernd 982, 5, Kuls, Bernd 98, 2009-04-09 13:12:15.0]
    14:03:11,672 INFO [STDOUT] [EL Warning]: 2009-04-09 14:03:11.672--UnitOfWork(14218007)--Thread(WorkerThread#0[192.168.1.217:4518])--Exception [EclipseLink-5006] (Eclipse Persistence Services - 1.1.0.r3634): org.eclipse.persistence.exceptions.OptimisticLockException
    Exception Description: The object [com.tup.model.Person@196649c] cannot be updated because it has changed or been deleted since it was last read.
    Class> com.tup.model.Person Primary Key> [5]
    14:03:11,688 INFO [STDOUT] [EL Warning]: 2009-04-09 14:03:11.688--UnitOfWork(14218007)--Thread(WorkerThread#0[192.168.1.217:4518])--javax.persistence.OptimisticLockException: Exception [EclipseLink-5006] (Eclipse Persistence Services - 1.1.0.r3634): org.eclipse.persistence.exceptions.OptimisticLockException
    Exception Description: The object [com.tup.model.Person@196649c] cannot be updated because it has changed or been deleted since it was last read.
    Class> com.tup.model.Person Primary Key> [5]
    14:03:11,688 INFO [STDOUT] OptimisticLockException throws MyApplicationException
    14:03:11,688 INFO [STDOUT] MyApplicationException
    14:03:11,735 INFO [STDOUT] [EL Finer]: 2009-04-09 14:03:11.735--UnitOfWork(14218007)--Thread(WorkerThread#0[192.168.1.217:4518])--TX afterCompletion callback, status=ROLLEDBACK
    14:03:11,750 INFO [STDOUT] [EL Finer]: 2009-04-09 14:03:11.75--UnitOfWork(14218007)--Thread(WorkerThread#0[192.168.1.217:4518])--release unit of work
    14:03:11,750 INFO [STDOUT] [EL Finer]: 2009-04-09 14:03:11.75--ClientSession(21268424)--Thread(WorkerThread#0[192.168.1.217:4518])--client released
    14:03:11,750 ERROR [BMTInterceptor] BMT stateful bean 'ModelFacade' did not complete user transaction properly status=STATUS_MARKED_ROLLBACK
    And by this Exception the transaction's status is set to status=STATUS_MARKED_ROLLBACK.
    The transaction can no longer be used.
    I want to use this transaction further and wrap the OptimisticLockException into an MyApplicationException
    (see serveroutput).
    But no change!
    Any Ideas ?
    Regards,
    Martin Kubitza
    T&P Bochum/Germany

    Hi,
    are you using JPA or TopLink ? Check if there is another exception thrown that produces the error. You can try and catch (Exception ex), which will catch them all. if this works the obviously you don't catch the right exception
    I found a post saying that: "If you trying commit directly after persist w/o doing an explicit
    flush then OptimisticLocking Exception maybe nested inside
    RollBackException. What is the top most error on stack? You can catch
    javax.persistence.PersistenceException and try to do this kind of
    error translation
    public static void getThrowable(javax.persistence.PersistenceException
    perex, int code) {
    boolean updateError = false ;
    boolean deleteError = false ;
    KentException kentex = null ;
    Throwable th = null ;
    if( perex instanceof org.apache.openjpa.persistence.RollbackException) {
    th = perex.getCause();
    if(th instanceof OptimisticLockException) {
    updateError = true ;
    if(perex instanceof OptimisticLockException ){
    updateError = true ;
    th = perex ;
    if(perex instanceof org.apache.openjpa.persistence.EntityNotFoundException) {
    deleteError = true ;
    th = perex ;
    http://n2.nabble.com/OptimisticLockException-confusion.-td210621.html
    Frank

  • Optimistic Lock Exceptions

    Another question:
    I'm getting some optimistic lock exceptions for object which I believe
    should only be modified in a single transaction. How can I see the context
    in which each modification took place?
    What is the definition of a 'modification', i.e. what operations on an
    object take an optimistic lock?
    Thanks,
    Tom

    Tom-
    In article <blj328$1i4$[email protected]>, Tom Davies wrote:
    >
    Another question:
    I'm getting some optimistic lock exceptions for object which I believe
    should only be modified in a single transaction. How can I see the context
    in which each modification took place?Try catching the lock exception and getting the FailedObject to see which
    object failed.
    You could also track which objects are being saved by
    implementing javax.jdo.InstanceCallbacks and doing some logging in
    jdoPreStore(). You could also try watching the SQL log to see if any
    suspicious updates are taking place.
    What is the definition of a 'modification', i.e. what operations on an
    object take an optimistic lock?Any field change or the addition/deletion to any related fields.
    Thanks,
    Tom--
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Cache Synchronization Exception Handling

    I am setting up cache synchronization on WebLogic using JMS. I am looking into writing an exception handler to handle cache synchronization exceptions. The following statement in the documentation caught my attention:
    “As mentioned above, the TopLink cache does not begin the merge or update process until the database transaction has already been committed. This is quite beneficial in that it avoids letting uncommitted data into the shared cache, but should be recognized where transactional synchronization is considered. In cases where a merge may have failed there is no way to roll back the changes made to the database (although it is questionable whether this would be a good idea in any case). As a consequence, failures during remote merging can leave the cache in an inconsistent state. This makes it important to handle any errors that occur by performing cache normalization actions, such as resetting the cache, or even the server.”
    Suppose we have two app server instances, A and B. Instance A commits a change and sends the update notification to instance B. The merge fails on instance B with an optimistic lock exception.
    - I assume that a CacheSynchronizationException will be thrown. Will it be thrown on instance A, B, or both?
    - At this point which cache is inconsistent; A, B, or both?
    - The documentation suggests resetting the cache, but this seems a rather severe way of dealing with the problem. Is it feasible / effective to just refresh the objects in the change set of the CacheSynchronizationException?
    This is a simple exception handler. On receiving a CacheSynchronizationException it resets the cache and re-throws the exception.
    class ToplinkExceptionHandler implements ExceptionHandler{
         public Object handleException(RuntimeException exception) throws DatabaseException{
              if(exception instanceof CacheSynchronizationException){){
                   myServerSession.initializeAllIdentityMaps();
                   throw exception;
              }else{
                   throw exception;
    - Is this approach effective?
    - Once the cache is reset should the exception be re-thrown or should I consider it handled and swallow it? If I do swallow it what should the method return?
    Any advice would be appreciated.

    I had to fix a few errors (in our code) before getting it working. Since I have multiple sessions, I had to specify different multicast ports (actually I used a different multicast address itself) for each of the sessions. I was not setting the announcement delay on one of the sesssions and that was why it was announcing immediately upon coming up. Also I had to explicitly set asynchronous to false because it is true by default.
    BTW, we are not using CMP (entity beans) rather Java Objects. Our deployment has two Apache/Tomcat machines and two WebLogic machines. The WebLogic servers are in a round-robin cluster. The cache synchronization seems to be working fine for this configuration.
    Thanks.
    Anand R

  • Pessimistic lock exception in a clustered environment

    Hello,
    i am using distributed Cache(DataCache) in a Cluster environment
    (Weblogic 7.0 cluster).
    I got one AdminServer and two ManagedServer running on the same machine.
    The problem occurs when i am using optimistic locking. It seems to be that
    the cache is not beeing synchronized, when i am successivly persisting
    objects and therfore get optimistic lock exceptions.
    When i am using pessimistic locking there is no problem.
    Waht could be the reason for this, maybe the case the all instances
    running on the same machine?
    My properties for the cache are the following:
    com.solarmetric.kodo.DataCacheClass=de.d2vodafone.webe.common.security.
    authorization.jdo.Cache (Cache is a subclass of UDPCache)
    com.solarmetric.kodo.DataCacheProperties=UseMulticast=true
    MulticastGroup=224.0.0.123 (is unique in my environment)
    In the log of my server i got the following messages:
    ignoring update from localhost
    ####<12.02.2003 13:25:11 CET> <Error> <EJB> <pc120514> <ManagedServer2>
    <ExecuteThread: '4' for queue: '__weblogic_admin_rmi_queue'> <kernel
    identity> <> <010026> <Exception during commit of transaction
    4:b57355e6636065c2: javax.jdo.JDOUserException: Errors were detected when
    flushing to the data store. If using optimistic transactions, this could
    indicate that lock violations were detected. The "getNestedExceptions"
    method of this Exception will return the specific errors.
    NestedThrowables:
    javax.jdo.JDOUserException:
    An instance was concurrently modified in another transaction (optimistic
    lock #: 3).
    FailedObject:de.webe.common.security.authorization.DomainImpl-5
         at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:551)
         at
    com.solarmetric.kodo.ee.EEPersistenceManager.beforeCompletion(EEPersistenceManager.java:192)
         at
    weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:540)
         at
    weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:92)
         at
    weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1044)
         at
    weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1581)
         at
    weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:237)
         at
    weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at
    weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:278)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl.createUser(AuthorizationServiceBean_8zrrq4_EOImpl.java:170)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
         at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    NestedThrowablesStackTrace:
    javax.jdo.JDOUserException: An instance was concurrently modified in
    another transaction (optimistic lock #: 3).
    FailedObject:de.d2vodafone.webe.common.security.authorization.DomainImpl-5
         at
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping$1.afterUpdate(ClassMapping.java:611)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatementNonBatch(SQLExecutionManagerImpl.java:563)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatement(SQLExecutionManagerImpl.java:512)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeInternal(SQLExecutionManagerImpl.java:406)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.flush(SQLExecutionManagerImpl.java:273)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:421)
         at
    com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:296)
         at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:549)
         at
    com.solarmetric.kodo.ee.EEPersistenceManager.beforeCompletion(EEPersistenceManager.java:192)
         at
    weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:540)
         at
    weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:92)
         at
    weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1044)
         at
    weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1581)
         at
    weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:237)
         at
    weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at
    weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:278)
         at
    de.d2vodafone.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl.createUser(AuthorizationServiceBean_8zrrq4_EOImpl.java:170)
         at
    de.d2vodafone.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
         at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    --------------- nested within: ------------------
    weblogic.transaction.RollbackException: Unexpected exception in
    beforeCompletion: sync=com.solarmetric.kodo.ee.EEPersistenceManager@472ddf
    Errors were detected when flushing to the data store. If using optimistic
    transactions, this could indicate that lock violations were detected. The
    "getNestedExceptions" method of this Exception will return the specific
    errors. - with nested exception:
    [javax.jdo.JDOUserException: Errors were detected when flushing to the
    data store.  If using optimistic transactions, this could indicate that
    lock violations were detected.  The "getNestedExceptions" method of this
    Exception will return the specific errors.
    NestedThrowables:
    javax.jdo.JDOUserException: An instance was concurrently modified in
    another transaction (optimistic lock #: 3).
    FailedObject:de.d2vodafone.webe.common.security.authorization.DomainImpl-5]
         at
    weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1561)
         at
    weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:284)
         at
    weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at
    weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:278)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl.createUser(AuthorizationServiceBean_8zrrq4_EOImpl.java:170)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
         at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    Thanks for your help
    Best Regards
    Orhan Keskin

    Orhan-
    Is this consistently reproducable, or a rare or one-time occurance? If
    the former, it may be a configuration issue, and we will investigatge
    along that path.
    If it is a rare or one-time occurance, keep in mind that data cache
    synchronization does not guarantee that you will be able to avoid
    optimistic locking exceptions. Whenever using optimistic locking, you
    always need to assume that someday, someone is going to violate that
    lock, unless you place some sort of synchronization atop all the
    database access (e.g., an EJB). It makes any application much more error
    prone (especially since an OL exception is a RuntimeException, and
    frequently people forget that it always needs to be checked for).
    Anyway, if you provide us with some more details, we will be able to
    investigate further.
    In article <[email protected]>, Orhan Keskin wrote:
    Hello,
    i am using distributed Cache(DataCache) in a Cluster environment
    (Weblogic 7.0 cluster).
    I got one AdminServer and two ManagedServer running on the same machine.
    The problem occurs when i am using optimistic locking. It seems to be that
    the cache is not beeing synchronized, when i am successivly persisting
    objects and therfore get optimistic lock exceptions.
    When i am using pessimistic locking there is no problem.
    Waht could be the reason for this, maybe the case the all instances
    running on the same machine?
    My properties for the cache are the following:
    com.solarmetric.kodo.DataCacheClass=de.d2vodafone.webe.common.security.
    authorization.jdo.Cache (Cache is a subclass of UDPCache)
    com.solarmetric.kodo.DataCacheProperties=UseMulticast=true
    MulticastGroup=224.0.0.123 (is unique in my environment)
    In the log of my server i got the following messages:
    ignoring update from localhost
    ####<12.02.2003 13:25:11 CET> <Error> <EJB> <pc120514> <ManagedServer2>
    <ExecuteThread: '4' for queue: '__weblogic_admin_rmi_queue'> <kernel
    identity> <> <010026> <Exception during commit of transaction
    4:b57355e6636065c2: javax.jdo.JDOUserException: Errors were detected when
    flushing to the data store. If using optimistic transactions, this could
    indicate that lock violations were detected. The "getNestedExceptions"
    method of this Exception will return the specific errors.
    NestedThrowables:
    javax.jdo.JDOUserException:
    An instance was concurrently modified in another transaction (optimistic
    lock #: 3).
    FailedObject:de.webe.common.security.authorization.DomainImpl-5
         at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:551)
         at
    com.solarmetric.kodo.ee.EEPersistenceManager.beforeCompletion(EEPersistenceManager.java:192)
         at
    weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:540)
         at
    weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:92)
         at
    weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1044)
         at
    weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1581)
         at
    weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:237)
         at
    weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at
    weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:278)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl.createUser(AuthorizationServiceBean_8zrrq4_EOImpl.java:170)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
         at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    NestedThrowablesStackTrace:
    javax.jdo.JDOUserException: An instance was concurrently modified in
    another transaction (optimistic lock #: 3).
    FailedObject:de.d2vodafone.webe.common.security.authorization.DomainImpl-5
         at
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping$1.afterUpdate(ClassMapping.java:611)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatementNonBatch(SQLExecutionManagerImpl.java:563)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatement(SQLExecutionManagerImpl.java:512)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeInternal(SQLExecutionManagerImpl.java:406)
         at
    com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.flush(SQLExecutionManagerImpl.java:273)
         at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:421)
         at
    com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:296)
         at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:549)
         at
    com.solarmetric.kodo.ee.EEPersistenceManager.beforeCompletion(EEPersistenceManager.java:192)
         at
    weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:540)
         at
    weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:92)
         at
    weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1044)
         at
    weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1581)
         at
    weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:237)
         at
    weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at
    weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:278)
         at
    de.d2vodafone.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl.createUser(AuthorizationServiceBean_8zrrq4_EOImpl.java:170)
         at
    de.d2vodafone.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
         at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    --------------- nested within: ------------------
    weblogic.transaction.RollbackException: Unexpected exception in
    beforeCompletion: sync=com.solarmetric.kodo.ee.EEPersistenceManager@472ddf
    Errors were detected when flushing to the data store. If using optimistic
    transactions, this could indicate that lock violations were detected. The
    "getNestedExceptions" method of this Exception will return the specific
    errors. - with nested exception:
    [javax.jdo.JDOUserException: Errors were detected when flushing to the
    data store.  If using optimistic transactions, this could indicate that
    lock violations were detected.  The "getNestedExceptions" method of this
    Exception will return the specific errors.
    NestedThrowables:
    javax.jdo.JDOUserException: An instance was concurrently modified in
    another transaction (optimistic lock #: 3).
    FailedObject:de.d2vodafone.webe.common.security.authorization.DomainImpl-5]
         at
    weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1561)
         at
    weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:284)
         at
    weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at
    weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:278)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl.createUser(AuthorizationServiceBean_8zrrq4_EOImpl.java:170)
         at
    de.webe.common.security.authorization.jdo.AuthorizationServiceBean_8zrrq4_EOImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
         at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    Thanks for your help
    Best Regards
    Orhan Keskin
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Optimistic Locking - Specifying an alternative User message

    Scenario...
    User A selects a record
    User B selects the same record
    User A makes a change and commits/applies it
    User B makes a change to the same record and ties to commit
    Result...User B gets the following message...
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "56693D48DF0C4F9D2A06AE5976FA6E8F", item checksum = "FC863259F75396F19D003B6B5E687758"., update "MAPOWN"."MAP_ALERT_LEVELS" set "MEASURE_ID" = :b1, "MEASURE_DESC" = :b2, "WARN_DFT" = :b3, "DANGER_DFT" = :b4, "WARN_TMP" = :b5, "DANGER_TMP" = :b6, "RECOMMENDATION" = :b7
    PROBLEM
    How do I capture this message and present a more user-friendly one??
    regards
    Paul P

    Paul - I don't know of a way around this other than to code your own optimistic locking logic and raise/handle an exception before the automatic row processing process catches it.
    Scott

  • Optimistic Lock with Parent and Child relationships

    Hi,
    I just have a question regarding optimistic locking. We have a scenario
    where a parent object has many child objects. Both the parent and the
    child objects have a jdolockx column in the database/jdo file.
    It appears that whenever you add a new child to the parent the parent's
    optimistic lock counter is also updated.
    eg
    parent.getChildren().add(child);
    child.setParent(parent);
    Why does this occur? There is no change made to the database table for
    the parent, except for the jdolockx column. Is there something that I can
    do to stop the lock count from incrementing when I child is added?
    We have a scenario where we have many threads of execution wishing to add
    children to a single parent. The parent itself isnt modified but this
    operation fails due to the parent lock counter being incremented.
    Any help would be appreciated
    Thanks
    Luke

    There is state image indicator in Kodo 3 which has more locking options
    beyond a simple number:
    http://solarmetric.com/Software/Documentation/3.0.1/docs/ref_guide_mapping_versionind.html#state-image
    In addition, you can plug your own version indicator.
    Our default optimistic locking avoids the problem of users having no
    idea what is -actually- in the collection/set at any given time.
    Inconsistencies can occur at the datastore level (user 1 adds
    object a to collection, user 2 removes a, user 1 adds object b... which
    should actually be in the DB? {a,b} or or {a}? This is one of the
    many ways in which not tracking changes to a collection/set can be
    hazardous).
    On locking exceptions, errors could be handled in some appropriate
    function (i.e. refresh, re-apply changes if applicable/safe,
    and commit).
    Luke wrote:
    Hi,
    I just have a question regarding optimistic locking. We have a scenario
    where a parent object has many child objects. Both the parent and the
    child objects have a jdolockx column in the database/jdo file.
    It appears that whenever you add a new child to the parent the parent's
    optimistic lock counter is also updated.
    eg
    parent.getChildren().add(child);
    child.setParent(parent);
    Why does this occur? There is no change made to the database table for
    the parent, except for the jdolockx column. Is there something that I can
    do to stop the lock count from incrementing when I child is added?
    We have a scenario where we have many threads of execution wishing to add
    children to a single parent. The parent itself isnt modified but this
    operation fails due to the parent lock counter being incremented.
    Any help would be appreciated
    Thanks
    Luke
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • Toplink Optimistic Locking not working with Session Bean facade.

    I am working on Oracle JDeveloper v 10.1.2 and connecting to an Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit
    The application is based on J2EE architecture and the technology stack uses Struts for presentation/controller framework, Stateless Session EJBs as session facade for custom business services, Simple java classes for the business services, Toplink implementation of DAO layer, Domain objects are mapped to database tables using Toplink Workbench that ships with JDeveloper. The transaction is managed by the session bean and hence the toplink session is configured to use external transaction controller and a named datasource as follows.
    <session xsi:type="server-session">
    <name>DBSession</name>
    <server-platform xsi:type="oc4j-1012-platform"/>
    <event-listener-classes/>
    <logging xsi:type="toplink-log">
    <log-level>fine</log-level>
    <file-name>D:/ToplinkLog.log</file-name>
    </logging>
    <primary-project xsi:type="xml">META-INF/toplink-descriptor.xml</primary-project>
    <login xsi:type="database-login">
    <platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</platform-class>
    <external-connection-pooling>true</external-connection-pooling>
    <external-transaction-controller>true</external-transaction-controller>
    <sequencing>
    <default-sequence xsi:type="native-sequence">
    <name>Native</name>
    <preallocation-size>1</preallocation-size>
    </default-sequence>
    </sequencing>
    <datasource>jdbc/ORADS</datasource>
    </login>
    </session>
    We intend to use Optimistic Locking based on Timestamp-version locking through an audit field "last_modification_date" of type java.sql.Timestamp. The corresponding database field is also of type Timestamp(6). We are not storing the version in cache.
    The problem we are facing is as follows.. we have an edit screen from where user can edit values for a domain object which are then persisted using Toplink...we expect Toplink to check the database record version (modification_date timestamp) before it applies the update. In DAO implementation, we register the object in a unitOfWork, then set the modified values, however we leave the modification_date (version field) unedited. Now when the application is running, on edit, an exception is thrown by the Session bean before ending the transaction.
    com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: Error in transaction: java.lang.NullPointerException
         at TrackingMediator_StatelessSessionBeanWrapper2.editOverheadExpenditure(TrackingMediator_StatelessSessionBeanWrapper2.java:1597)
         at com.enbridge.dsm.web.action.TrackingPortfolioAction.editOverheadExpenditure(TrackingPortfolioAction.java:264)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java)
         at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:278)
         at com.enbridge.dsm.web.shared.BaseAction.execute(BaseAction.java:90)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
         at com.enbridge.dsm.web.shared.DSMPojoRequestProcessor.process(DSMPojoRequestProcessor.java:182)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1425)
         at com.sourcebeat.strutslive.common.SLActionServlet.process(SLActionServlet.java:44)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.enbridge.dsm.web.shared.security.SecurityFilter.doFilter(SecurityFilter.java:142)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:645)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
         Nested exception is:
    java.lang.NullPointerException
         at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:1190)
         at com.evermind.sql.FilterConnection.commit(FilterConnection.java:209)
         at com.evermind.sql.DriverManagerXAConnection.commit(DriverManagerXAConnection.java:203)
         at com.evermind.server.TransactionEnlistment.commit(TransactionEnlistment.java:251)
         at com.evermind.server.ApplicationServerTransaction.singlePhaseCommit(ApplicationServerTransaction.java:745)
         at com.evermind.server.ApplicationServerTransaction.commit(ApplicationServerTransaction.java:690)
         at com.evermind.server.ApplicationServerTransaction.end(ApplicationServerTransaction.java:1035)
         at TrackingMediator_StatelessSessionBeanWrapper2.editOverheadExpenditure(TrackingMediator_StatelessSessionBeanWrapper2.java:1593)
         at com.enbridge.dsm.web.action.TrackingPortfolioAction.editOverheadExpenditure(TrackingPortfolioAction.java:264)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java)
         at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:278)
         at com.enbridge.dsm.web.shared.BaseAction.execute(BaseAction.java:90)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
         at com.enbridge.dsm.web.shared.DSMPojoRequestProcessor.process(DSMPojoRequestProcessor.java:182)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1425)
         at com.sourcebeat.strutslive.common.SLActionServlet.process(SLActionServlet.java:44)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
         at com.enbridge.dsm.web.shared.security.SecurityFilter.doFilter(SecurityFilter.java:142)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:645)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    Note that the exception is thrown at the time when the session bean is about to commit the transaction. i.e. the DAO code did not throw any exception and was able to check the optimistic locking and submit the update transaction.
    I am not able to understand why is the the EJB throwing this weird error with Optimistic locking implementation. The application is working fine when the optimistic locking is disabled.
    I am facing another problem due to this problem... since the session bean throws this exception after exiting the bean implemented method, when trying to commit the transaction, I am not able to mark the session context to setRollbackOnly. Hence if I continue on to another transaction by navigating to another screen in the application, mysteriously the previous transaction gets committed!!... again... weird...

    I am using JDBC driver version 10.1.2.
    I saw this additional error message in JDeveloper console, which for some reason was not logged to my log4j log file... if it helps...
    06/09/22 18:32:10 Thr[thread 6]-TransactionEnlistment.TransactionEnlistment.Caught forgetandRollback XAException e null
    Here are the logs from my Toplink log file....
    [TopLink Info]: 2006.09.22 06:31:46.546--ServerSession(989)--Thread(Thread[HttpRequestHandler-86,5,main])--TopLink, version: Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)
    [TopLink Info]: 2006.09.22 06:31:46.578--ServerSession(989)--Thread(Thread[HttpRequestHandler-86,5,main])--Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)
    [TopLink Config]: 2006.09.22 06:31:46.593--ServerSession(989)--Connection(991)--Thread(Thread[HttpRequestHandler-86,5,main])--connecting(DatabaseLogin(
         platform=>Oracle10Platform
         user name=> ""
         connector=>JNDIConnector datasource name=>jdbc/ORADS
    [TopLink Config]: 2006.09.22 06:31:47.484--ServerSession(989)--Connection(1432)--Thread(Thread[HttpRequestHandler-86,5,main])--Connected: jdbc:oracle:thin:@10.210.16.37:1521:orabld
         User: APP_USR
         Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
         Driver: Oracle JDBC driver Version: 10.1.0.3.0
    [TopLink Config]: 2006.09.22 06:31:47.500--ServerSession(989)--Connection(1433)--Thread(Thread[HttpRequestHandler-86,5,main])--connecting(DatabaseLogin(
         platform=>Oracle10Platform
         user name=> ""
         connector=>JNDIConnector datasource name=>jdbc/ORADS
    [TopLink Config]: 2006.09.22 06:31:47.500--ServerSession(989)--Connection(1434)--Thread(Thread[HttpRequestHandler-86,5,main])--Connected: jdbc:oracle:thin:@10.210.16.37:1521:orabld
         User: APP_USR
         Database: Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
         Driver: Oracle JDBC driver Version: 10.1.0.3.0
    [TopLink Info]: 2006.09.22 06:31:47.671--ServerSession(989)--Thread(Thread[HttpRequestHandler-86,5,main])--DBSession login successful
    [TopLink Fine]: 2006.09.22 06:31:47.703--ServerSession(989)--Connection(1554)--Thread(Thread[HttpRequestHandler-86,5,main])--select * from user_role ur, app_resource ar, role_resource rr where rr.APP_RESOURCE_ID = ar.APP_RESOURCE_ID and rr.USER_ROLE_ID = ur.USER_ROLE_ID
    [TopLink Fine]: 2006.09.22 06:31:49.937--ServerSession(989)--Connection(10245)--Thread(Thread[HttpRequestHandler-86,5,main])--SELECT * FROM PROGRAM_SUB_CAT
    [TopLink Fine]: 2006.09.22 06:31:50.015--ServerSession(989)--Connection(10332)--Thread(Thread[HttpRequestHandler-86,5,main])--SELECT PROGRAM_ID, CREATED_BY_USERID FROM (SELECT CREATED_BY_USERID, ROWNUM PROGRAM_ID FROM (SELECT DISTINCT(CREATED_BY_USERID) CREATED_BY_USERID, 1 AS PROGRAM_ID FROM PROGRAM))
    (I only see my application specific queries after this... no exceptions or debug logs)... as I said before.. the application gives exception in the session bean at the time of commit, and there's no exception raised from Toplink code in DAO...

  • Exception handling in stored process, loop IF..ELSE

    Hello Guys,
    we want to put in exception handling in the loop but get the following error:
    Error(43,3): PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following: begin case declare end exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe
    create or replace
    PROCEDURE xxxx
    FOR MESSSY IN
    select I.*
    FROM x I
    LOOP
    IF upper(CODE)='N' THEN
    INSERT INTO T_MESS(MP)
    select I.MP_ID
    FROM T_ME
    ELSIF upper(MESSSY.k2)='L' THEN
    DELETE T_MESS WHERE T_MESS.MP = MESSSY.MP;
    END IF;
    EXCEPTION
    WHEN DUP_VAL_ON_INDEX THEN
    A program attempted to insert duplicate values in a column that is constrained by a unique index.
    DBMS_OUTPUT.PUT_LINE ('A program attempted to insert duplicate values in a column that is constrained by a unique index.')
    --No Rollback
    END;
    COMMIT;
    END LOOP;
    END xxxx;
    does someone know why?

    BluShadow wrote:
    Well, your code is missing all sorts of bits and we don't have your data or your exact logic to know what it's supposed to be achieving.
    That is right, you dont have my data and that is why I was suprised by your comment.
    Since the input table might contain a few thousand rows and each of those might need to
    be considered N , D, or C and each case has a different handling I can not imagine how this
    can be all done with a merge statement.
    MERGE
    T_METRICPOINT_META with T_METRICSSYSTEM_LOAD where T_METRICSSYSTEM_LOAD .LOAD_DATE=to_char(sysdate)
    WHEN MATCHED THEN --we know those are the metric points that have to be loaded today, but we still need to do a IF..ELSE to handle them
    WHEN NOT MATCHED THEN -- not considered in todays load
    ----original code-----
    create or replace
    PROCEDURE myprocedure AS
    BEGIN
    --Extracting the records from T_METRICSSYSTEM_LOAD which have todays load date. Corresponding to these MP_System, we extract the MP_IDs from the T_METRICPOINT_META table.
    --Comapring these MP_IDs with the MP_IDs from the source(T_METRICPOINT_IMPORT) and extracting only those Metric points which need to be loaded today.
    FOR METRICSSYSTEM IN
    select I.*
    FROM T_METRICPOINT_IMPORT I
    where I.LOADDATE = TO_CHAR(SYSDATE) AND I.MP_ID IN
    (select a.MP_ID
    from T_METRICPOINT_META a INNER JOIN T_METRICSSYSTEM_LOAD b on a.MP_SYSTEM = b.MP_SYSTEM where b.LOAD_DATE=to_char(sysdate))
    LOOP
    --If mutation code in the source/import data is "N", the record is inserted as it is in the "T_METRICPOINTS" table.
    IF upper(METRICSSYSTEM.MUTATIONCODE)='N' THEN --new
    INSERT INTO T_METRICPOINTS(MP_ID, ......)
    SELECT DISTINCT I.MP_ID,.....
    FROM T_METRICPOINT_IMPORT I WHERE I.MP_ID = METRICSSYSTEM.MP_ID
    ELSIF upper(METRICSSYSTEM.MUTATIONCODE)='D' THEN --delete
    DELETE T_METRICPOINTS WHERE T_METRICPOINTS.MP_ID = METRICSSYSTEM.MP_ID AND T_METRICPOINTS.KEY = METRICSSYSTEM.KEY;
    ELSIF upper(METRICSSYSTEM.MUTATIONCODE)='C' THEN --correction
    UPDATE T_HISTORYMETRICPOINTS H
    SET CHANGE_DATE = to_char(sysdate)
    WHERE H.MP_ID=METRICSSYSTEM.MP_ID AND H.KEY = METRICSSYSTEM.KEY;
    INSERT INTO T_HISTORYMETRICPOINTS(MP_ID, KEY, .....)
    --The distinct here is used, to handle 2 identical records in the input table with correction value "C". This would insert into 1 record in the T_HISTORYMETRICPOINTS table without
    --violating the primary key constraint.
    select DISTINCT I.MP_ID,I.KEY, ....
    FROM T_METRICPOINT_IMPORT I WHERE I.MP_ID = METRICSSYSTEM.MP_ID
    --END IF;
    END IF;
    COMMIT;
    END LOOP;
    END myprocedure;

  • BPM Exception Handling

    I am trying to test my Deadline and Exception handling.But it is not at all working. I will explain what I have done, please guide me where I am going wrong.
    1) Block Step. Properties --- Exception == ERROR1
    2)Switch Step . Success Branch . Send Step. with a Transport Response. And I am sending to the Mail adapter. And in directory I have provided the WRONG URL FOR THIS Mail.
          Otherwsie Branch. Send step, sending to a File.
    3)Dead Lock Branch : Having a Control Step.
                  Properties
                   Action : Throw Exception
                   Exception: ERROR1
    4) Exception Branch.
               Properties
                    Exception Handler : ERROR1
          Send Step : Send a Message to  a File (
    Result
    I am Seeing a Clock in my SXMB_MONI OUTBOUND_Status column, because I am expecting a TRANSPOT Response, and this going to never happen, so I thought the Deadline monitor will wakeup after 1 minute interval and my Exception branch has to Trigger, but it has never triggered my Deadline branch aswell as my Exception Branch.
    WE are in XI SP 12.  We dont have CCMS installed yet, even ALERT management is not installed.
    Please guide me.
    Thanks.

    Hi Anand,
    I looked into the Transaction SWI2_DEAD and I dont see any listings there.
    I am executing 1 Minute deadline Monitoring and from here firing an exception Branch, for my Asynchronous Scenario.
    So definitely after a minute , the DeadLine Branch should have been fired. But it didnot take place.
    In the mean time I have located an OSS notes OSS note 829921 And I am awaiting my Basis team to apply this note.
    symptom
    If the execution of an asynchronous method ends with a "system error" or "application error", the work item is not set to the 'ERROR' status.
    Other terms
    Reason and Prerequisites
    This problem is caused by a program error.
    Solution
    Implement the correction instructions.
    Note the following manual changes that must be implemented BEFORE you use SNOTE to implement the corrections:
    1. Make sure that the SET_EXECUTION_INTERRUPTED method of the CL_SWF_RUN_RESULT class has the following parameters:
    a) IM_CODE, Importing, Optional, Type SWO_RETURN, default Value 0000
    b) IM_ERRORTYPE, Importing, Optional, Type SWO_ERRTYP, Default Value 0
    Note the following manual changes, which you must carry out AFTER you have implemented the corrections:
    1. The M_EXECUTION_INTERRUPTED attribute type of the CL_SWF_RUN_RESULT class must be changed to EXECUTION_INTERRUPTED.

  • UTL file exception handling oracle 11g

    We use oracle 11g
    We use UTL file and exception handling in many place. Thanks in advance.
    We have many utl program and we are writing same exception handling code ,copy and paste .
    It is possible to create new UTL exception procedure and call it.
    I am not sure how to write generic UTL exception procedure and reuse the same.
    I am learning oracle etl files method.
    Please advise.
    sample program 1 :
    DECLARE
    fileHandler UTL_FILE.FILE_TYPE;
    BEGIN
    fileHandler := UTL_FILE.FOPEN('test_dir', 'test_file.txt', 'W');
    UTL_FILE.PUTF(fileHandler, 'Writing TO a file\n');
    UTL_FILE.FCLOSE(fileHandler);
    EXCEPTION
    when utl_file.invalid_path then
    raise_application_error(-20001,
    'INVALID_PATH: File location or filename was invalid.');
    when utl_file.invalid_mode then
    raise_application_error(-20002,
    'INVALID_MODE: The open_mode parameter in FOPEN was invalid.');
    when utl_file.invalid_filehandle then
    raise_application_error(-20002,
    'INVALID_FILEHANDLE: The file handle was invalid.');
    when utl_file.invalid_operation then
    raise_application_error(-20003,
    'INVALID_OPERATION: The file could not be opened or operated on as requested.');
    when utl_file.read_error then
    raise_application_error(-20004,
    'READ_ERROR: An operating system error occurred during the read operation.');
    when utl_file.write_error then
    raise_application_error(-20005,
    'WRITE_ERROR: An operating system error occurred during the write operation.');
    when utl_file.internal_error then
    raise_application_error(-20006,
    'INTERNAL_ERROR: An unspecified error in PL/SQL.');
    when utl_file.invalid_filename then
    raise_application_error(-20010, 'The filename parameter is invalid.');
    WHEN OTHERS THEN
    IF UTL_FILE.IS_OPEN(fileHandler ) THEN
    UTL_FILE.FCLOSE (fileHandler );
    END IF;
    RAISE;
    END;
    How to write generic procedure of utl exception handling ?
    please advise.
    create or replace procedure sp_utl_exception
    begin
    when utl_file.invalid_path then
    raise_application_error(-20001,
    'INVALID_PATH: File location or filename was invalid.');
    when utl_file.invalid_mode then
    raise_application_error(-20002,
    'INVALID_MODE: The open_mode parameter in FOPEN was invalid.');
    when utl_file.invalid_filehandle then
    raise_application_error(-20002,
    'INVALID_FILEHANDLE: The file handle was invalid.');
    when utl_file.invalid_operation then
    raise_application_error(-20003,
    'INVALID_OPERATION: The file could not be opened or operated on as requested.');
    when utl_file.read_error then
    raise_application_error(-20004,
    'READ_ERROR: An operating system error occurred during the read operation.');
    when utl_file.write_error then
    raise_application_error(-20005,
    'WRITE_ERROR: An operating system error occurred during the write operation.');
    when utl_file.internal_error then
    raise_application_error(-20006,
    'INTERNAL_ERROR: An unspecified error in PL/SQL.');
    when utl_file.invalid_filename then
    raise_application_error(-20010, 'The filename parameter is invalid.');
    WHEN OTHERS THEN
    IF UTL_FILE.IS_OPEN(fileHandler ) THEN
    UTL_FILE.FCLOSE (fileHandler );
    END IF;
    RAISE;
    end;

    Mahesh Kaila wrote:
    Hello,
    Common procedure to log exception in log file
    create or replace procedure sp_utl_exception (log_dir varchar2, log_file varchar2, exception_msg varchar2)
    is
    hnd_file   UTL_FILE.file_type;
    begin
    hnd_file := UTL_FILE.fopen (log_dir, log_file, 'A');
    UTL_FILE.put_line (hnd_file, exception_msg);
    UTL_FILE.fclose (hnd_file);
    exception
    when others
    then
    raise;
    end;
    Very poor implementation.
    a) Absolutely no need for that exception handler in there. It should be removed.
    b) As it's a procedure for logging exceptions relating to UTL_FILE, it would seem error prone to be logging the errors with UTL_FILE. For example, what is it supposed to do if the exception is raised because of lack of disk space in those file locations? How is it going to write out the exception with the disk full? Also, if the exception handler is used by multiple processes, then only 1 process at a time can access the log file to write it's exceptions, so it doesn't scale well. Better logging is done by having an autonomous transaction procedure that writes log/trace messages to dedicated table(s). That also means that the logs etc. can be viewed, as appropriate, from any client using SQL (either manually or through a application written to view logs etc.), rather than requiring physical/remote access to the server o/s to go and view the contents of the file, which in itself could lock the file and prevent any process from writing further logs whilst it's being used.

  • Optimistic Locking fails when version field is part of a Aggregate

    I'm trying to persist a Mapped Object using 9.0.3 Toplink.
    The object uses optimistic locking while the Timestamp versioning field is part of an Aggreate Descriptor. This works well in the Workbench (does not complain).
    Unfortunally it does not work whenever I use the UnitOfWork to register and commit the chances.
    Sample code:
    Object original;
    UnitOfWork unitOfWork = ...          
    Object clone =   unitOfWork.registerExistingObject(original);
    clone.setBarcode("bliblalbu");
    unitOfWork.commit();This throws an nasty OptimisticLockException, complaining about a missing versioning field:
    LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-5004] (TopLink - 9.0.3 (Build 423)): oracle.toplink.exceptions.OptimisticLockException
    EXCEPTION DESCRIPTION: An attempt was made to update the object [BusinessObject:{id:12382902,shorttext:null,barcode:bliblablu,ownerLocation:null,IdEntryName:0,idCs:20579121}], but it has no version number in the identity map.
    It may not have been read before the update was attempted.
    CLASS> de.grob.wps.domain.model.BusinessObjectBO PK> [12382902]
         at oracle.toplink.exceptions.OptimisticLockException.noVersionNumberWhenUpdating(Unknown Source)
         at oracle.toplink.descriptors.VersionLockingPolicy.addLockValuesToTranslationRow(Unknown Source)
         at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.updateObjectForWrite(Unknown Source)
         at oracle.toplink.queryframework.WriteObjectQuery.executeCommit(Unknown Source)
         at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.executeWrite(Unknown Source)
         at oracle.toplink.queryframework.WriteObjectQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.internal.sessions.CommitManager.commitAllObjects(Unknown Source)
         at oracle.toplink.publicinterface.Session.writeAllObjects(Unknown Source)
         at oracle.toplink.publicinterface.UnitOfWork.commitToDatabase(Unknown Source)
         at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(Unknown Source)
         at oracle.toplink.publicinterface.UnitOfWork.commitAndResume(Unknown Source)
         at de.grob.wps.dwarf.domainstore.toplink.ToplinkTransaction.commit(ToplinkTransaction.java:60)
         at de.grob.wps.dwarf.domainstore.toplink.ToplinkPersistenceManager.commit(ToplinkPersistenceManager.java:396)
         at de.grob.wps.dwarf.domainstore.toplink.ToplinkPersistenceManagerTest.testPersistSerializableWithBusinessObjects(ToplinkPersistenceManagerTest.java:87)
         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 junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)So what can I to fix this problem? BTW the Object I try to persists has been read from database and the IDE debugger shows what that the aggregate object contains java.sql.Timestamp instances.

    Sorry guys. My debugger fooled me. The locking field wasn't initialized in the database. This caused the problem which is fixed now.
    Thx anyway.
    Bye
    Toby

  • JSF Exception Handling Example

    Here is an example of catching a backend exception and displaying it on the UI. It seems like most of the examples in books and such concern themselves with Validators and Converters. If you are trying to catch a backend exception, and you just want to display a UI message for it, see if this will work for you:
    JSF tags:
    <h:commandLink id="myActionLink" value="#{msgs.myLinkText}" binding="#{MyFormBean.uiComponentLink}" action="#{MyFormBean.linkProcessingMethod}"></h:commandLink>
    <h:messages layout="table" errorClass="Errors" styleClass="AlignLeft"/>
    ...And now the exception handling and message creation inside of the managed bean:
    private HtmlCommandLink uiComponentLink;
    * Method that processes the link action
    * @return String (action ID)
    public String linkProcessingMethod()
         try
              // BEGIN: TEST ONLY
              if(1 == 1)     // Always true
                   throw new Exception("TEST ERROR MESSAGE DISPLAY");
              // END: TEST ONLY
         return "dummyPageReference";     // No reference for this in faces-config.xml. Redisplays same page.
         catch (Exception e)
             addFacesMessageForUI("Exception detected. Message: " +e.getMessage());
             return "dummyPageReference";
    * Add faces message for display on the UI
    * @param String uiMessage
    private void addFacesMessageForUI(String uiMessage)
         FacesMessage facesMessage = new FacesMessage(uiMessage);
         FacesContext facesContext = FacesContext.getCurrentInstance();
         // Passing null for the client ID argument to the FacesContext
         // addMessage() method specifies the message as not belonging
         // to any particular UI component. This will cause the message
         // to be displayed as a general message on the UI
         facesContext.addMessage(null,facesMessage);
    }

    chrisjohn wrote:
    Following link would be helpful
    [http://technologicalbrainstorm.wordpress.com/2009/09/19/exception-handling-in-jsf/]
    Thanks!!Please, don't resurrect old threads, and especially not to post link-spam. Your account will get blocked if you continue with it. I'm locking this thread.
    Kaj

  • Calling EJBs from Global Exception Handler

    Hi, I'm using Weblogic Workshop 8.1.4.
    I have a JPF which calls a EJB to set a lock flag (to prevent the JPF being executed twice at the same time.)
    I want to reset the lock flag in the global exception handler, however, if I call an EJB (Entity or Session) in a perform node in the exception handler, I get a NullPointerException.
    Is this because it's being called in the exception handler? Is there any way to work around this (without building a POJO which does all the persistance logic and SQL calling manually?)
    Thanks.

    You can redirect stdout to wherever you want by using
    System.setOut(PrintStream out). Also, you can give
    printStackTrace a PrintStream.
    hth,
    mI think to solve this problem you should call System.setErr(PrintStream err);

  • ChangeFields optimistic locking

    I am trying to use optmistic locking without changing my database schema by using the descriptor.useChangedFieldsLocking() on my EJB descriptor. Two clients try to do the following.
    1) Query the shallow properties of the EJB (no getters called for unary or collection relationships).
    2) Edit some of that simple data
    3) Submit their changes
    The optimistic locking works okay when just the shallow properties are being retrieved. If a client tries to submit when someone else has already done so, an OptimisticLockException is thrown which is the desired result.
    However, if I wish to traverse one of the relationships on the EJB when it is first queried (by calling a getter for a collection for example) the following happens: When the second client attempts to load and edit this EJB the transaction times out with a deadlock exception.
    I want to traverse relationships for display purposes in this case but in the furture will want to edit something in that relationship with ChangedFieldsLocking also set.
    If anyone could tell me why the second client's transaction times out when it asks for the EJB I would be very grateful.
    Regards
    James.

    Thanks for the reply.
    After further investigation I have found that it's nothing to do with the locking (since I can switch it off and still have the problem) but may be a problem with OC4J (or how I am using it). The situation is as follows:
    1) Client A starts a transaction
    2) Client A asks for ejb1
    3) Client A asks for ejb1.collection()
    4) Client A asks for ejb1.collection(i).someMethod()
    5) Client A uses the result of someMethod()
    (transaction is still open)
    6) Client B starts a transaction
    7) Client B asks for ejb1
    8) Client B asks for ejb1.collection()
    9) Client B asks for ejb1.collection(i).someMethod()
    10) Client B uses the result of someMethod()
    The server hangs on step 9 and never enters someMethod() (the first line is debug and I never see it). Eventually it tells me that the transaction has timed out with a deadlock exception.
    The following comes from the output of a ctrl-break at the point of hanging (someMethod() is getTitle() in this example) :
    "HttpRequestHandler-22629000" prio=5 tid=0x434DE690 nid=0xab4 in Object.wait() [4400f000..4400fd8c]
    at java.lang.Object.wait(Native Method)
    - waiting on <08FC9AC8> (a com.evermind.server.ThreadState)
    at com.evermind.server.ejb.AbstractEJBObject.startCall(AbstractEJBObject.java:226)
    - locked <08FC9AC8> (a com.evermind.server.ThreadState)
    at PersonNamesRemote_EntityBeanWrapper79.getTitle(PersonNamesRemote_EntityBeanWrapper79.java:3227)
    at uk.co.corelogic.framework.common.ejb.entity.PeopleEJB.toBean(PeopleEJB.java:1800)
    at PeopleRemote_EntityBeanWrapper60.toBean(PeopleRemote_EntityBeanWrapper60.java:1742)
    at uk.co.corelogic.framework.common.ejb.session.FrameworkManager.retrieve(FrameworkManager.java:142)
    I am using OC4J 9.0.4, Toplink 9.0.3.3. I have Toplink configured to generate BMP Entity beans.
    My entity bean deployment descriptor has <reentrant>False</reentrant> but <reentrant>True</reentrant> makes no difference. It also has <trans-attribute>Required</trans-attribute> for everything which should be okay and trying <trans-attribute>Supports</trans-attribute> just causes null pointers to be thrown all over the place.
    I will post this message on the OC4J forum too but would appreciate a reply if you have any ideas.
    Thanks.
    James.

Maybe you are looking for

  • How do I change the names associated with numbers on my bill

    I have multiple numbers on my bill that have the wrong names associated with them.  I have tried calling *611 only to wait and then be disconnected. I am the account owner  and am unable to locate where to correct the information.

  • ERROR AT 1st step

    hello experts, i am getting the below error at the very 1st step of the process chain. 21.01.2011     00:15:20     NO_MORE_SPACE: Can not create MTE: no more space: no more MESSAGE_CONTAINER slots available     S     RSAR     51 please suggest what i

  • Att.mail doesn't work with firefox yet is great with IE or google chrome. Won't delete,move or reply

    yahoo comes up, then in switching to mail, the mail appears and I can look at each piece. However, the delete, move, and reply buttons are not responding. Also, I can't generate a new message. The system works fine with IE or Google Chrome.

  • In ME38 If (EKET-MENGE) (EKPO-KTMNG)Schedule lines should not be created

    Hi, Our Requirement is in ME38 which is for creting Schdule line Agrement the system should not allow to create schedule lines if the Total of Schedule Line Quantity > Total Scheduled Quantity           (Sum of all EKET-MENGE) > (EKPO-KTMNG) Can anyb

  • EAP/TLS authentication Issue

    I have several Aironet 1100 AP's which are configure to use EAP/TLS to authenticate against a Cisco ACS server. We are using Aironet 350 pcmcia cards. This setup had been working up until friday when we moved the ACS server to a new IP address. Since