You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by kristian meier <kr...@jentro.com> on 2003/12/12 15:30:23 UTC
Re: automatic failover
Hi,
to avoid OJBRuntimeException which are used by OJB to wrap SQLException,
we simply catch them and wrap them into our PersistentException which is
an application exception. that works fine for us.
try {
this.ojb.broker().store(account);
}
catch (OJBRuntimeException e) {
throw new PersistentException(
"OJB error creating account: " + account,
e);
}
best wishes Kristian
Stephen Ting wrote:
> Can anybody give me some hints on how to design a failover system with
> OJB in appserver to database layer?
>
> I use OJB PB api within a session bean. The following code snippet
> roughly show roughly what i did. whenever the
> link from the application server to the database is down. I was not able
> catch the exception at the session bean to handle
> it properly. and the sql exception is propagate to the presentation
> layer. Does anybody have any experience how to design
> an automatic failover in this scenario. I try to catch SQLException, but
> ecplise won't compile.. it said, the catch block
> is unreachable.
>
>
> try{
> ...
> broker = getBroker();
> Collection col = broker.getCollectionByQuery(query);
> ...
> }catch(PersistenceBrokerException ex){
> ...
> }
>
> any help are very much appreciated.. thanks
>
> Regards,
>
> Stephen Ting
>
>
> 2003-12-11 11:43:30,156 INFO [STDOUT]
> [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR:
> 2003-12-11 11:43:30,156 INFO [STDOUT] SQLException during the execution
> of the query (for a my.com.shinyang.eply.model.LogSupplier):
> Communication link failure: java.io.IOException, underlying cause:
> Unexpected end of input stream
>
> ** BEGIN NESTED EXCEPTION **
>
> java.io.IOException
> MESSAGE: Unexpected end of input stream
>
> STACKTRACE:
>
> java.io.IOException: Unexpected end of input stream
> at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1405)
> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1775)
> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1020)
> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1109)
> at com.mysql.jdbc.Connection.execSQL(Connection.java:2030)
> at
> com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:156
> 3)
> at
> org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(Wr
> appedPreparedStatement.java:302)
> at
> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown
> Source)
> at org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(Unknown
> Source)
> at org.apache.ojb.broker.accesslayer.RsIterator.<init>(Unknown Source)
> at
> org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(Unknow
> n Source)
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(
> Unknown Source)
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Un
> known Source)
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Un
> known Source)
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Un
> known Source)
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Un
> known Source)
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Un
> known Source)
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQu
> ery(Unknown Source)
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQu
> ery(Unknown Source)
> at
> my.com.shinyang.eply.service.ejb.SearchSessionBean.doSearch(SearchSessio
> nBean.java:308)
> at
> my.com.shinyang.eply.service.ejb.SearchSessionBean.doSearch(SearchSessio
> nBean.java:373)
> 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.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stat
> elessSessionContainer.java:683)
> at
> org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(
> CachedConnectionInterceptor.java:185)
> at
> org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(Statele
> ssSessionInstanceInterceptor.java:72)
> at
> org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterce
> ptor.java:84)
> at
> org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptor
> CMT.java:267)
> 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 $Proxy60.doSearch(Unknown Source)
> at
> my.com.shinyang.eply.bd.SearchDelegateEJBImpl.doSearch(SearchDelegateEJB
> Impl.java:70)
> at
> my.com.shinyang.eply.syl.webdesk.SylSupplierAction.searchSupplier(SylSup
> plierAction.java:254)
> 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)
>
>
> ** END NESTED EXCEPTION **
>
>
>
--
----------------------------------------------------------------------
Jentro Technologies GmbH
Kristian Meier, Developer
----------------------------------------------------------------------
Rosenheimer Str. 145e 81671 Munich, Germany
Tel. +49 89 189 169 80 mailto: Kristian.Meier@jentro.com
Fax. +49 89 189 169 99 internet: http://www.jentro.com
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org