i'm trying to catch Exception in CAMEL, when there is no connection, like this :
<from uri="imap://Uri"/>
<onException>
<exception>javax.mail.MessagingException</exception>
<exception>java.net.NoRouteToHostException</exception>
<handled>
<constant>true</constant>
</handled>
<transform>
<simple>Error reported: ${exception.message} - cannot process this message.</simple>
</transform>
</onException>
But it dont work. I got this error message:
javax.mail.MessagingException: No route to host: connect;
nested exception is:
java.net.NoRouteToHostException: No route to host: connect
What's wrong ?
If the error is from the consumer, eg the <from> then you need to bridge the error handler from the consumer.
See this FAQ:
http://camel.apache.org/why-does-my-file-consumer-not-pick-up-the-file-and-how-do-i-let-the-file-consumer-use-the-camel-error-handler.html
The bridge option is also possible for the mail component.
Related
I'm using geoserver-2.20.3.war together with Apache Tomcat/9.0.36 on Linux. Everything works as it should but if i try to access the server status via the web administration interface i only get Error messages. I can't really figure out the problem and how to fix it.
`HTTP Status 500 – Internal Server Error
Type Exception Report
Message Handler dispatch failed; nested exception is java.lang.InternalError: java.lang.reflect.InvocationTargetException
Beschreibung The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.InternalError: java.lang.reflect.InvocationTargetException
...
Root Cause
java.lang.InternalError: java.lang.reflect.InvocationTargetException
...
Root Cause
java.lang.reflect.InvocationTargetException
...
Root Cause
java.lang.NullPointerException
java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
...
I tried to find a similar issue but unfortunately did not stumble over something really helpful.
I found a solution! The problem were missing fonts. After following these very helpful steps by Andreas Ahlenstorf and installing the font-package dejavu-fonts on linux everything works fine.
how to handle connection refused exception while pushing messages in the camel exchange to Kafka end point.Kafka may be down or it will be down during the process.. please help me how to handle this type of scenarios
I tried with onException block it is not working
you can try this:
`
.doTry()
.to("kafka:....)
.endDoTry()
.doCatch(Exception.class)
.to("direct:handleTechnicalCommunicationError")
.end()
`
Write a separete route direct:handleTechnicalCommunicationError for handling this error
When i have a error on a database connection, i need to log it (with Database name and username that tried to connect to the db, don't need to log the password), I use Sprig-Mybatis on my aplication.
Any ideas how to do that?
Best Regards
There is no other special way to do as a simple try/catch in java will get you the expection.
For example a simple program where I am calling a mybatis mapper method:
try{
List result = mapper.myBatisMapperMethod();//this is responsible to set up
//a connection and run a query
}
Suppose the above call fails due to invalid authentication say the below where my password is wrong connection
exception that I usually get in mybatis:
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Login failed for user 'applicationUsername'.)
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Login failed for user 'applicationUsername'.)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
... 65 more
Caused by:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'applicationUsername'.
what I do is have a simple catch to above try you can have an sql exception catched but here I use simply Exception.
catch(Exception e){
//Suppose you are using Log4j You can simply
logger.error("This is my error log message"+e.getMessage());
//The above will log any kind of exception including the authentication fail or you
can specifically log a particular kind of exception.Java wont log failed password it just logs the user who tried unless you explicitly want to log it.
}
I am developing a SOAP client with Apache CXF. One method of the request returns me this stack in the client. With SOAPUI the same request returns me the expected response. Maybe I lost a library in JNLP? Maybe it is a binding problem?
2013-11-08 15:31:16,593 ERROR [es.isoftsanidad.eprescribe.comunclient.paneles.buscadorfarmacos.ListadoPF5Controlador] [setListaObjetos] Error en establecer el listado de los objetos
javax.xml.ws.soap.SOAPFaultException: Couldn't create SOAP message due to exception: Unable to create StAX reader or writer
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
at
.....
Caused by: org.apache.cxf.binding.soap.SoapFault: Couldn't create SOAP message due to exception: Unable to create StAX reader or writer
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:140)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:71)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:835)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1606)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1502)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:627)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
Check the logs on the server side. This is the message that the server is sending back in it's SOAP fault. Thus, something is happening on the server side that needs investigating.
Using JBOSS 4.3 with Java 1.5.0_15 connecting to IBM WebSphere MQ 6.0.2.3
When JBOSS is started these errors occur.
Stack Trace
Caused by: javax.resource.spi.ResourceAdapterInternalException: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'uatmq1sun:UATMQ1SUN'
at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:297)
at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:333)
at org.jboss.resource.deployment.RARDeployment.endpointActivation(RARDeployment.java:271)
at org.jboss.resource.deployment.RARDeployment.internalInvoke(RARDeployment.java:226)
at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBeanSupport.java:156)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.ejb3.JmxClientKernelAbstraction.invoke(JmxClientKernelAbstraction.java:46)
at org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory.activate(JBossMessageEndpointFactory.java:343)
... 147 more
Caused by: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'uatmq1sun:UATMQ1SUN'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:614)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2549)
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1899)
at com.ibm.mq.jms.MQConnection.<init>(MQConnection.java:862)
at com.ibm.mq.jms.MQConnectionFactory.createConnection(MQConnectionFactory.java:4821)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.initializeJMSConnection(ResourceAdapterConnectionPool.java:445)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.createNewConnection(ResourceAdapterConnectionPool.java:359)
at com.ibm.mq.connector.ResourceAdapterConnectionPool.allocateConnection(ResourceAdapterConnectionPool.java:284)
... 155 more
At the end of the JBOSS server.log file.
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:ear=AmxBol.ear,jar=AmxBol.jar,name=BOLCFulfillmentMDB,service=EJB3
State: FAILED
Reason: org.jboss.deployment.DeploymentException: Endpoint activation failed ra=jboss.jca:service=RARDeployment,name='wmq.jmsra.rar' activationSpec=javax.jms.Queue:bolcustomizable#UATMQ1SUN#uatmq1sun; - nested throwable: (javax.resource.spi.ResourceAdapterInternalException: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'uatmq1sun:UATMQ1SUN')
ObjectName: jboss.j2ee:ear=AmxBol.ear,jar=AmxBol.jar,name=BOLPaymentMDB,service=EJB3
State: FAILED
Reason: org.jboss.deployment.DeploymentException: Endpoint activation failed ra=jboss.jca:service=RARDeployment,name='wmq.jmsra.rar' activationSpec=javax.jms.Queue:bolpayment#UATMQ1SUN#uatmq1sun; - nested throwable: (javax.resource.spi.ResourceAdapterInternalException: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'uatmq1sun:UATMQ1SUN')
ObjectName: jboss.j2ee:ear=AmxBol.ear,jar=AmxBol.jar,name=BOLPFulfillmentMDB,service=EJB3
State: FAILED
Reason: org.jboss.deployment.DeploymentException: Endpoint activation failed ra=jboss.jca:service=RARDeployment,name='wmq.jmsra.rar' activationSpec=javax.jms.Queue:bolpersonalized#UATMQ1SUN#uatmq1sun; - nested throwable: (javax.resource.spi.ResourceAdapterInternalException: javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'uatmq1sun:UATMQ1SUN')
I'm unsure if it is related but a patch was recently applied to JBOSS. The queue manager (UATMQ1SUN) is up and running but it does not seem to want to connect. Any ideas as to what could be wrong? MQ and JBOSS live on the same box.
hostname = uatmq1sun
QManagerName = UATMQ1SUN
[mqm#uatmq1sun ~]$ strmqm UATMQ1SUN
WebSphere MQ queue manager running.
[mqm#uatmq1sun ~]$ netstat -an | grep 1416
tcp 0 0 :::1416 :::* LISTEN
JMS throws nested exceptions where the high-level exception contains a generic JMS failure code and the linked exception contains the provider-specific exception. So, for example, of all the possible reasons that creation of the QMgr object failed, some are local and include things like configuration errors and some only happen if the connection is attempted. In other words, some cases of the error you are reporting are code and some are MQ. If there's no linked exception, the problem isn't with MQ.
Of the ones that only happen when the connection has attempted (those that are MQ problems), the linked exception tells you explicitly whether it connected but found the wrong QMgr name, or that there was no listener, or that the channel negotiation failed, etc. But these very specific explanations are only available if the code bothers to print the linked exception.
In many of the shops where I've worked or consulted, it is considered a Sev-1 defect if JMS code is found to not print linked exceptions, and this is tested for. Such code is prevented from being promoted to production and if found in production it is pulled and fixed as an emergency change. What is expected is that the code either prints the linked exception or else prints that it checked but no linked exception is present. Without these, the best we can do here (or your operations team can do in an actual outage) is just to guess.
From the WebSphere MQ Infocenter page on JMS exceptions:
catch (JMSException je) {
System.err.println("Caught JMSException");
// Check for linked exceptions in JMSException
Throwable t = je;
while (t != null) {
// Write out the message that is applicable to all exceptions
System.err.println("Exception Msg: " + t.getMessage());
// Write out the exception stack trace
t.printStackTrace(System.err);
// Add on specific information depending on the type of exception
if (t instanceof JMSException) {
JMSException je1 = (JMSException) t;
System.err.println("JMS Error code: " + je1.getErrorCode());
if (t instanceof JmsExceptionDetail){
JmsExceptionDetail jed = (JmsExceptionDetail)je1;
System.err.println("JMS Explanation: " + jed.getExplanation());
System.err.println("JMS Explanation: " + jed.getUserAction());
}
} else if (t instanceof MQException) {
MQException mqe = (MQException) t;
System.err.println("WMQ Completion code: " + mqe.getCompCode());
System.err.println("WMQ Reason code: " + mqe.getReason());
} else if (t instanceof JmqiException){
JmqiException jmqie = (JmqiException)t;
System.err.println("WMQ Log Message: " + jmqie.getWmqLogMessage());
System.err.println("WMQ Explanation: " + jmqie.getWmqMsgExplanation());
System.err.println("WMQ Msg Summary: " + jmqie.getWmqMsgSummary());
System.err.println("WMQ Msg User Response: "
+ jmqie.getWmqMsgUserResponse());
System.err.println("WMQ Msg Severity: " + jmqie.getWmqMsgSeverity());
}
// Get the next cause
t = t.getCause();
}
}
Please print the linked exception when attempting to debug any JMS exceptions, with any transport provider. The spec defines a nested data structure to convey exception diagnostic conditions and there is no justification for failure to print that information.