I am trying to implement proper error handling in my code. There is a request component, which hits a specific api. I have to handle the scenario, where "server couldn't send a response" exception occurs.
Mule does not identify it as a HTTP:NOT FOUND error instead it identifies it as MULE:UNKNOWN.
How should I handle this case ? I want mule to identify it as a HTTP error.
EDIT:
How do I handle the MULE:UNKNOWN error type. I dont want to handle it under ANY and the compiler doesn't accept the type MULE : UNKNOWN. ?
org.mule.runtime.deployment.model.api.DeploymentException: Failed to
deploy artifact [] Caused by:
org.mule.runtime.api.exception.MuleRuntimeException:
org.mule.runtime.deployment.model.api.DeploymentInitException:
MuleRuntimeException: Could not find ErrorType for the given
identifier: 'MULE:UNKNOWN' Caused by:
org.mule.runtime.deployment.model.api.DeploymentInitException:
MuleRuntimeException: Could not find ErrorType for the given
identifier: 'MULE:UNKNOWN' Caused by:
org.mule.runtime.core.api.config.ConfigurationException: Could not
find ErrorType for the given identifier: 'MULE:UNKNOWN' Caused by:
org.mule.runtime.api.lifecycle.InitialisationException: Could not find
ErrorType for the given identifier: 'MULE:UNKNOWN' Caused by:
org.mule.runtime.api.lifecycle.LifecycleException: Could not find
ErrorType for the given identifier: 'MULE:UNKNOWN' Caused by:
org.mule.runtime.api.exception.MuleRuntimeException: Could not find
ErrorType for the given identifier: 'MULE:UNKNOWN'
HTTP:NOT FOUND means that the server returned an HTTP 404 (ie not found) response. If the server aborted the response for any reason it is not expected that the HTTP Requester to return a NOT FOUND. Having said that, the MULE:UNKNOWN error indicates an error that the component can not handle. You could try to update the version of the HTTP Connector to the last one to see if it has been improved to handle better that particular situation. Check the release notes to see if a newest one has been released.
error message:
Message : Execution of the expression "payload.get(0).get('ACCESS_TOKEN')" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: LinkedList
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Index: 0, Size: 0 (java.lang.IndexOutOfBoundsException)
java.util.LinkedList:553 (null)
2. null (java.lang.reflect.InvocationTargetException)
sun.reflect.GeneratedMethodAccessor323:-1 (null)
3. cannot invoke method: get (java.lang.RuntimeException)
org.mule.mvel2.optimizers.impl.refl.nodes.MethodAccessor:63 (null)
4. Execution of the expression "payload.get(0).get('ACCESS_TOKEN')" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
5. Execution of the expression "payload.get(0).get('ACCESS_TOKEN')" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: LinkedList (org.mule.api.transformer.TransformerMessagingException)
code:
<db:select config-ref="QB_Oracle_Configuration" doc:name="Access">
<db:parameterized-query><![CDATA[select access_token, access_token_secret from sias_access where EMPLID=#[message.inboundProperties['p_emplId']] AND TRINET_COMPANY=#[message.inboundProperties['p_company']]]]></db:parameterized-query>
</db:select>
<set-session-variable variableName="accessToken" value="#[payload.get(0).get('ACCESS_TOKEN')]" doc:name="Access token"/>
Problem is sometime value comes more than one from select query, how do I filter. I can do by filtering query by WHERE ROWNUM = 1, but how can I handle in Mule instead of this in query?
Can you try with:
#[message.payload[0]['ACCESS_TOKEN']]
If this still throws an exception, please share the full ERROR not just the first line so I can refine my answer.
I'm trying to use MuleSoft's decryption on HTTP requests. I'm doing this also on GET requests.
I get the following error:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ERROR 2015-05-17 13:00:35,630
[[broker1-secure].HTTP_Listener_Configuration.worker.01]
org.mule.exception.DefaultMessagingExceptionStrategy:
******************************************************************************** Message : Failed to invoke decrypt. Message payload is
of type: NullPayload Code : MULE_ERROR-29999
-------------------------------------------------------------------------------- Exception stack is:
1. Could not decrypt the input. The input has to be a byte array,Input Stream or String (java.lang.RuntimeException)
org.mule.modules.security.encryption.encrypters.JCEEncrypterModule:59
(null)
2. Failed to invoke decrypt. Message payload is of type: NullPayload (org.mule.api.MessagingException)
org.mule.devkit.processor.DevkitBasedMessageProcessor:128
(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
-------------------------------------------------------------------------------- Root Exception stack trace: java.lang.RuntimeException: Could not
decrypt the input. The input has to be a byte array,Input Stream or
String at
org.mule.modules.security.encryption.encrypters.JCEEncrypterModule.decrypt(JCEEncrypterModule.java:59)
at
org.mule.modules.security.encryption.EncryptionModule.decrypt(EncryptionModule.java:213)
at
org.mule.modules.security.encryption.processors.DecryptMessageProcessor$1.process(DecryptMessageProcessor.java:165)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
Shouldn't it be possible? Try to decrypt payload, and if nothing to decrypt then continue?
It would be better to only decrypt if the payload is not null: it's better to avoid raising exceptions if you can.
For this, you can use a choice router to decrypt only if the payload is not null.
In my <catch-exception-strategy>, I write error payload to file. But sometimes when flow involves web-service calls and host is unavailable or unknown (for e.g. java.net.UnknownHostException is thrown), payload is not anymore an instance of InputStream or String. If I try to log error then to file, following exception is thrown:
exception.AbstractExceptionListener (AbstractExceptionListener.java:299) -
********************************************************************************
Message : Could not find a transformer to transform "SimpleDataType{type=org.apache.commons.httpclient.methods.PostMethod, mimeType='*/*'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}".
Code : MULE_ERROR-65237
--------------------------------------------------------------------------------
Exception stack is:
1. Could not find a transformer to transform "SimpleDataType{type=org.apache.commons.httpclient.methods.PostMethod, mimeType='*/*'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}". (org.mule.api.transformer.TransformerException)
org.mule.registry.MuleRegistryHelper:252 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.transformer.TransformerException: Could not find a transformer to transform "SimpleDataType{type=org.apache.commons.httpclient.methods.PostMethod, mimeType='*/*'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}".
at org.mule.registry.MuleRegistryHelper.lookupTransformer(MuleRegistryHelper.java:252)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:355)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:313)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
I am thinking of doing a choice block before writing to file to make sure payload is writable. Shall I do something like #[payload instanceof java.io.InputStream]? But then how about cases where payload is DOM or something else? Please advise.
I would use a transformer inside the catch exception strategy and encapsulate there the logic that would consider the input and produce a writable payload.
If you want to check whether there is a transformer available for a specific payload type and output type, I guess you could look up the available transformers from the registry. In Groovy:
transformers = message.getMuleContext().getRegistry().lookupTransformers(
new org.mule.transformer.types.SimpleDataType(payload.getClass()),
new org.mule.transformer.types.SimpleDataType(java.io.InputStream))
if (transformers.size() == 0) {
//set some variable or whatever
}
The WCF service is deployed on different machine.
Im able to get the http://MyServer/MYService.svc/jsdebug file by giving
<identity>
<dns value="ServerName and the portnumber"/>
And I'm able to invoke the service method using javascript.
After invoking the MyMethod.
I get this error in the javascript --> The server method 'MyMethod' failed, status 404 (in failedCallback)
MyMethod returns a Boolean value in svc.cs file after performing a datacheck.
These are the errors came up when I used Firefox Firebug:
When I call the same service using VS2008 in my development environment it works fine.
I found that following are the files which are not loading while using Ajax enabled VS2005
1) MicrosoftAjax.debug.js(3.5)
2) MicrosoftAjaxWebForms.debug.js(3.5) During runtime
Its obvious that 3.5 debug files doesn't load but, 1.0.6 debug files should load without the errors displayed below.
invokeCalledTwice":"Cannot call invoke more than once.",
11"webServiceFailed":"The server method \u0027{0}\u0027 failed with the following error: {1}",
12"argumentType":"Object cannot be converted to the required type.",
13"argumentNull":"Value cannot be null.",
14"controlCantSetId":"The id property can\u0027t be set on a control.",
15"formatBadFormatSpecifier":"Format specifier was invalid.",
16"webServiceFailedNoMsg":"The server method \u0027{0}\u0027 failed.",
17"argumentDomElement":"Value must be a DOM element.",
18"invalidExecutorType":"Could not create a valid Sys.Net.WebRequestExecutor from: {0}.",
19"cannotCallBeforeResponse":"Cannot call {0} when responseAvailable is false.",
20"actualValue":"Actual value was {0}.",
21"enumInvalidValue":"\u0027{0}\u0027 is not a valid value for enum {1}.",
22"scriptLoadFailed":"The script \u0027{0}\u0027 could not be loaded.",
23"parameterCount":"Parameter count mismatch.",
24"cannotDeserializeEmptyString":"Cannot deserialize empty string.",
25"formatInvalidString":"Input string was not in a correct format.",
26"invalidTimeout":"Value must be greater than or equal to zero.",
27"cannotAbortBeforeStart":"Cannot abort when executor has not started.",
28"argument":"Value does not fall within the expected range.",
29"cannotDeserializeInvalidJson":"Cannot deserialize. The data does not correspond to valid JSON.",
30"invalidHttpVerb":"httpVerb cannot be set to an empty or null string.",
31"nullWebRequest":"Cannot call executeRequest with a null webRequest.",
32"eventHandlerInvalid":"Handler was not added through the Sys.UI.DomEvent.addHandler method.",
33"cannotSerializeNonFiniteNumbers":"Cannot serialize non finite numbers.",
34"argumentUndefined":"Value cannot be undefined.",
35"webServiceInvalidReturnType":"The server method \u0027{0}\u0027 returned an invalid type. Expected type: {1}",
36"servicePathNotSet":"The path to the web service has not been set.",
37"argumentTypeWithTypes":"Object of type \u0027{0}\u0027 cannot be converted to type \u0027{1}\u0027.",
38"cannotCallOnceStarted":"Cannot call {0} once started.",
39"badBaseUrl1":"Base URL does not contain ://.",
40"badBaseUrl2":"Base URL does not contain another /.",
41"badBaseUrl3":"Cannot find last / in base URL.",
42"setExecutorAfterActive":"Cannot set executor after it has become active.",
43"paramName":"Parameter name: {0}",
44"cannotCallOutsideHandler":"Cannot call {0} outside of a completed event handler.",
45"format":"One of the identified items was in an invalid format.",
46"assertFailedCaller":"Assertion Failed: {0}\r\nat {1}",
47"argumentOutOfRange":"Specified argument was out of the range of valid values.",
48"webServiceTimedOut":"The server method \u0027{0}\u0027 timed out.",
49"notImplemented":"The method or operation is not implemented.",
50"assertFailed":"Assertion Failed: {0}",
51"invalidOperation":"Operation is not valid due to the current state of the object.",
52"breakIntoDebugger":"{0}\r\n\r\nBreak into debugger?"
Appreciate your inputs.
Seeing as you have Firebug installed, you can use it to check the HTTP request and response to see if they contain more information about what went wrong.
These are the errors came up when I used Firefox Firebug:
When I call the same service using VS2008 in my development environment it works fine.
I found that following are the files which are not loading while using Ajax enabled VS2005
1) MicrosoftAjax.debug.js(3.5)
2) MicrosoftAjaxWebForms.debug.js(3.5) During runtime
Its obvious that 3.5 debug files doesn't load but, 1.0.6 debug files should load without the errors displayed below.
invokeCalledTwice":"Cannot call invoke more than once.",
11"webServiceFailed":"The server method \u0027{0}\u0027 failed with the following error: {1}",
12"argumentType":"Object cannot be converted to the required type.",
13"argumentNull":"Value cannot be null.",
14"controlCantSetId":"The id property can\u0027t be set on a control.",
15"formatBadFormatSpecifier":"Format specifier was invalid.",
16"webServiceFailedNoMsg":"The server method \u0027{0}\u0027 failed.",
17"argumentDomElement":"Value must be a DOM element.",
18"invalidExecutorType":"Could not create a valid Sys.Net.WebRequestExecutor from: {0}.",
19"cannotCallBeforeResponse":"Cannot call {0} when responseAvailable is false.",
20"actualValue":"Actual value was {0}.",
21"enumInvalidValue":"\u0027{0}\u0027 is not a valid value for enum {1}.",
22"scriptLoadFailed":"The script \u0027{0}\u0027 could not be loaded.",
23"parameterCount":"Parameter count mismatch.",
24"cannotDeserializeEmptyString":"Cannot deserialize empty string.",
25"formatInvalidString":"Input string was not in a correct format.",
26"invalidTimeout":"Value must be greater than or equal to zero.",
27"cannotAbortBeforeStart":"Cannot abort when executor has not started.",
28"argument":"Value does not fall within the expected range.",
29"cannotDeserializeInvalidJson":"Cannot deserialize. The data does not correspond to valid JSON.",
30"invalidHttpVerb":"httpVerb cannot be set to an empty or null string.",
31"nullWebRequest":"Cannot call executeRequest with a null webRequest.",
32"eventHandlerInvalid":"Handler was not added through the Sys.UI.DomEvent.addHandler method.",
33"cannotSerializeNonFiniteNumbers":"Cannot serialize non finite numbers.",
34"argumentUndefined":"Value cannot be undefined.",
35"webServiceInvalidReturnType":"The server method \u0027{0}\u0027 returned an invalid type. Expected type: {1}",
36"servicePathNotSet":"The path to the web service has not been set.",
37"argumentTypeWithTypes":"Object of type \u0027{0}\u0027 cannot be converted to type \u0027{1}\u0027.",
38"cannotCallOnceStarted":"Cannot call {0} once started.",
39"badBaseUrl1":"Base URL does not contain ://.",
40"badBaseUrl2":"Base URL does not contain another /.",
41"badBaseUrl3":"Cannot find last / in base URL.",
42"setExecutorAfterActive":"Cannot set executor after it has become active.",
43"paramName":"Parameter name: {0}",
44"cannotCallOutsideHandler":"Cannot call {0} outside of a completed event handler.",
45"format":"One of the identified items was in an invalid format.",
46"assertFailedCaller":"Assertion Failed: {0}\r\nat {1}",
47"argumentOutOfRange":"Specified argument was out of the range of valid values.",
48"webServiceTimedOut":"The server method \u0027{0}\u0027 timed out.",
49"notImplemented":"The method or operation is not implemented.",
50"assertFailed":"Assertion Failed: {0}",
51"invalidOperation":"Operation is not valid due to the current state of the object.",
52"breakIntoDebugger":"{0}\r\n\r\nBreak into debugger?"