Hi Stephen,

Stephen Ting wrote:

Hi Armin,

Ya, I didn't knows I have to use setRollbackOnly() to rollback on cm-tx.
Bad, on my limited
Knowledge on J2EE.
But when I include the setRollbackOnly() just before the method return
statement. I get the following exception. Is this expected or there is
something wrong which I didn't realize or
Overlook.

This is expected, signals that ODMG-api does not commit.
By the way, I forget to say this will only work with declarative tx (cm-tx), if you are using programmatic tx (bm-tx) you have to use the
"normal" userTransaction.rollback()/setRollbackOnly() methods.


regards,
Armin



Your help are very much appreciated.


Regards,
Stephen

2003-11-29 08:39:23,514 INFO [STDOUT]
[org.apache.ojb.odmg.J2EETransactionImpl] ERROR: 2003-11-29 08:39:23,514 INFO [STDOUT] Could not commit, because tx
status was marked rollback
2003-11-29 08:39:23,530 ERROR [STDERR]
org.apache.ojb.broker.OJBRuntimeException: Could not commit, because tx
status was marked rollback
at
org.apache.ojb.odmg.J2EETransactionImpl.beforeCompletion(Unknown Source)
at
org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:130
4)
at
org.jboss.tm.TransactionImpl.rollback(TransactionImpl.java:452)
at
org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.j
ava:390)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptor
CMT.java:277)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.jav
a:118)
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryF
inderInterceptor.java:122)
at
org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionC
ontainer.java:331)
at org.jboss.ejb.Container.invoke(Container.java:700)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDi
spatcher.java:284)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at
org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
at
org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:9
0)
at
org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.jav
a:46)
at
org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at
org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionI
nterceptor.java:100)
at
org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy72.updateDoc(Unknown Source)
at
my.com.shinyang.eply.bd.LogPondDelegateEJBImpl.updateDoc(LogPondDelegate
EJBImpl.java:85)
at
my.com.shinyang.eply.syl.webdesk.SylLogPondAction.editLogPond(SylLogPond
Action.java:707)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.j
ava:280)
at
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216
)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestPr
ocessor.java:484)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
274)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
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
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:256)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
at
org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurity
MgrRealm.java:220)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator
Base.java:553)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.ja
va:246)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(Container
StatsValve.java:76)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241
6)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:180)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
lve.java:171)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:172)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
sociationValve.java:65)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577
)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:174)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:60
1)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:56
5)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:619)
at java.lang.Thread.run(Thread.java:534)





-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: 29 November 2003 05:08
To: OJB Users List
Subject: Re: Container managed Transaction



Hi,


Stephen Ting wrote:


I didn't called the sessionContext.setRollbackOnly(). Simply I just call the return statement.


You said you are using a cm-tx and you do only a return if something does not match. The container does not know about that and commit the tx after method return --> OJB commit dirty objects too.


If you want to rollback the tx use setRollbackOnly()


tx = odmg.currentTransaction();
broker = ((NarrowTransaction)tx).getBroker();

//update the changed document ((NarrowTransaction)tx).markDirty(document);

List origBlock = document.getLogPondBlockList();
if(origBlock != null){                  
        Iterator orig = origBlock.iterator();
        while(orig.hasNext()){
                ((NarrowTransaction)tx).markDirty(orig.next());
        }
}

Collection existed = broker.getCollectionByQuery(query);
LogPond dbLogPond = (LogPond)existed.iterator().next(); 



List dbBlock = dbLogPond.getLogPondBlockList();
if(dbBlock != null){                    
        Iterator i = dbBlock.iterator();
        while(i.hasNext()){
                LogPondBlock dbLogPondBlock = (LogPondBlock)i.next();

                if(document.getLogPondBlock(dbLogPondBlock) == null){
                        ((NarrowTransaction)tx).markDelete(orig.next());

}else{

===> getSessionContext().setRollbackOnly();


hmm, maybe I misunderstood your question.

regards,
Armin


///error.. Can't delete this item ON EXIST OF THIS METHOD, I FOUND THAT THE

ABOVE MARK DIRTY STILL


TAKE EFFECT
                  return;       
                }
        }
}

Regards,
Stephen 




-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: 28 November 2003 16:17
To: OJB Users List
Subject: Re: Container managed Transaction


Hi Stephen,


Stephen Ting wrote:


Can i programatic rollback managed transaction in ODMG api?

I have the following challenge.

1. ((NarrowTransaction)tx).markDirty(document1);
2. ((NarrowTransaction)tx).markDirty(subDoc1);
3. ((NarrowTransaction)tx).markDelete(subDoc2);

In the above sequence, says I excute statement 1 and 2 successfully,
before reaching statement 3 I detected some errors and need to exit the method and rollback. In my testing, the
SQL Statement in 1 and 2 will get excuted.

What do you do when the error was detected? Did you call sessionContext.setRollbackOnly() ? Could you post some pseudo code?

Normally 1 and 2 shouldn't be executed when all method
calls made in a cm-tx.

regards,
Armin



My question is can I rollback
sql statement 1 and 2 and assume I didn't mark document1

and subDoc1?


Thanks

Regards,
Stephen Ting


------------------------------------------------------------

---------


To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]








--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to