camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From james555 <luke...@gmx.net>
Subject exception handling of transacted servlet route
Date Fri, 18 Mar 2016 12:06:07 GMT

Hello,

i have a problem with exception handling in transacted routes (Camel version
2.16.2):

sceanrio:
I use a camel servlet with Oracle WebLogicServer 12c which gets a HTTP POST
request, inserts a String into a jms queue (transacted camel route with
Oracle DB / Advanced Queueing) and sends synchroniously  HTTP response back
to the HTTP client.

problem:
In case of database desaster I would like to catch Oracle exceptions
followed by a return of a regular response with a defined error message.
Sounds simple, but HTTP client only gets a stacktrace (see below
org.springframework.transaction.CannotCreateTransactionException) and no
regular message when database is down.

I found out that by commenting out line:    .transacted()    the exception
handling works correctly, but I need this obviously for jms rollback
scenarios.
So this problem seems similar to
http://camel.465427.n5.nabble.com/Problem-with-exception-handler-onException-on-Camel-2-12-X-routes-tc5742605.html,
but there was also no solution mentioned.

Is this a camel bug ? Thanks for any advice !

	James


Codes:

CamelContextLifecycle class:
…
AQjmsConnectionFactory connectionFactory = (AQjmsConnectionFactory)
AQjmsFactory.getQueueConnectionFactory((DataSource) apsExternalDb);

JmsTransactionManager tm = new JmsTransactionManager();
tm.setConnectionFactory(connectionFactory);
            
SpringTransactionPolicy policy = new SpringTransactionPolicy();
policy.setTransactionManager(tm);
policy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
registry.put("PropagationPolicy", policy);

JmsComponent jmsComponent = new JmsComponent(camelContext);
jmsComponent.setConnectionFactory(connectionFactory);
jmsComponent.setTransactionManager(tm);
camelContext.addComponent("jms", jmsComponent);
…

Route class:
…
from("servlet:///in?servletName=WebService")
.transacted()
.doTry()
   .log(LoggingLevel.INFO, "HTTP-POST-Request")
   .convertBodyTo(String.class)
   .to(ExchangePattern.InOnly, "jms:test_queue?jmsMessageType=Text")
   .setHeader(Exchange.CONTENT_TYPE, constant("text/plain; charset=" +
MISCELLANEOUS.ENCODING_UTF_8)) 
   .setHeader(Exchange.HTTP_RESPONSE_CODE,
constant(HttpServletResponse.SC_OK))
   .setBody(constant("ok"))
.endDoTry()     
.doCatch(Exception.class)
   .log(LoggingLevel.ERROR, "ERROR")
   .setBody(simple("Severe Error: ${exception.message}"))
   .markRollbackOnly()
.end()          
.end();


Exception:

org.springframework.transaction.CannotCreateTransactionException: Could not
create JMS transaction; nested exception is oracle.jms.AQjmsException:
weblogic.common.resourcepool.ResourceDisabledException: Pool TEST_ds is
Suspended, cannot allocate resources to applications..
	at
org.springframework.jms.connection.JmsTransactionManager.doBegin(JmsTransactionManager.java:216)
	at
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
	at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
	at
org.apache.camel.spring.spi.TransactionErrorHandler.doInTransactionTemplate(TransactionErrorHandler.java:174)
	at
org.apache.camel.spring.spi.TransactionErrorHandler.processInTransaction(TransactionErrorHandler.java:134)
	at
org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:103)
	at
org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:112)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)
	at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:143)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
	at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
	at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
	at
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
	at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
	at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
	at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432)
	at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
	at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
	at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
	at
weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
	at
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
	at
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
	at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
	at
weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
Caused by: oracle.jms.AQjmsException:
weblogic.common.resourcepool.ResourceDisabledException: Pool TEST_ds is
Suspended, cannot allocate resources to applications..
	at
oracle.jms.AQjmsDBConnMgr.checkForSecurityException(AQjmsDBConnMgr.java:939)
	at oracle.jms.AQjmsDBConnMgr.getConnection(AQjmsDBConnMgr.java:617)
	at oracle.jms.AQjmsDBConnMgr.<init>(AQjmsDBConnMgr.java:399)
	at oracle.jms.AQjmsConnection.<init>(AQjmsConnection.java:258)
	at
oracle.jms.AQjmsConnectionFactory.createConnection(AQjmsConnectionFactory.java:522)
	at
org.springframework.jms.connection.JmsTransactionManager.createConnection(JmsTransactionManager.java:288)
	at
org.springframework.jms.connection.JmsTransactionManager.doBegin(JmsTransactionManager.java:186)
	... 29 more
Caused by: weblogic.jdbc.extensions.PoolDisabledSQLException:
weblogic.common.resourcepool.ResourceDisabledException: Pool TEST_ds is
Suspended, cannot allocate resources to applications..
	at
weblogic.jdbc.common.internal.JDBCUtil.wrapAndThrowResourceException(JDBCUtil.java:269)
	at weblogic.jdbc.pool.Driver.connect(Driver.java:153)
	at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:662)
	at weblogic.jdbc.jts.Driver.connect(Driver.java:128)
	at
weblogic.jdbc.common.internal.RmiDataSource.getConnectionInternal(RmiDataSource.java:589)
	at
weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:545)
	at
weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:538)
	at oracle.jms.AQjmsDBConnMgr.getConnection(AQjmsDBConnMgr.java:566)
	... 34 more




--
View this message in context: http://camel.465427.n5.nabble.com/exception-handling-of-transacted-servlet-route-tp5779274.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message