camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravi21588 <ravi21...@gmail.com>
Subject NoTypeConversionAvailableException exception while running junit test case
Date Tue, 09 May 2017 16:48:02 GMT
Hi iam getting NoTypeConversionAvailableException  while using xpath in
camel,iam using camel 2.10.Iam getting this exception only in junit test
case,but it is working fine while deployed in Jboss EAP server.

My camel route is as below:

<?xml version="1.0" encoding="ASCII"?>
<routes xmlns="http://camel.apache.org/schema/spring">
	<route id="TranslatorRoute" streamCache="true">
		<from uri="switchyard://TranslatorService" />
		<doTry>
			<choice>
				<when>
					<xpath>//response-type='ERROR'</xpath>
					<log message="choice ${body} " loggingLevel="INFO"/> 
				</when>
				<otherwise>
					<log message="Otherwise ${body} " loggingLevel="INFO"/> 
					
				</otherwise>
			</choice>
			
			<doCatch>
				<exception>java.lang.Exception</exception>
				<handled>
					<constant>false</constant>
				</handled>
				<log message="Exception " loggingLevel="INFO" />
			</doCatch>
		</doTry>
	</route>
</routes>

iam sending a jaxb object as input for the switchyard://TranslatorService
service when invoking from Junit test case.

Iam getting the below type conversion exception when it is calling the camel
XPATH.


org.apache.camel.RuntimeCamelException:
org.apache.camel.NoTypeConversionAvailableException: No type converter
available to convert from type: com.company.esb.message.model.v2.EsbMessage
to the required type: org.w3c.dom.Document with value <?xml version="1.0"
encoding="UTF-8" standalone="yes"?>
<ns2:esb-message xmlns:ns2="http://messagev2.esb.company.com/">
	<header>
		<identity>
			<user-id>esb_USER</user-id>
		</identity>
		<esb-service-name>createPolicy</esb-service-name>
		<source-system-id>CU_MC</source-system-id>
		<message-type>RES</message-type>
		<message-id>ID-CG02B459-61540-1470327657377-0-4</message-id>
		<correlation-id>ID-CG02B459-61540-1470327657377-0-4</correlation-id>
		<source-transaction-id>1234567890</source-transaction-id>
		<message-date-time>2017-05-09T17:21:33</message-date-time>
		<esb-environment>DEV</esb-environment>
                <response-type>DONE</response-type>
	</header>
</ns2:esb-message>


I have already defined the typeconverter for the Object as below and added
the TypeConverter file in META-INF services.

package com.company.esb.message.camel;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.apache.camel.Converter;

import com.company.esb.message.esbMessageHandler;
import com.company.esb.message.model.v2.esbMessage;

@Converter
public class esbMessageConverter {

	@Converter
	public static InputStream toInputStream (esbMessage msg) throws Exception {
		String val=new esbMessageHandler(msg).getMessageAsString();
		return new ByteArrayInputStream(val.getBytes("UTF-8"));
	}
	
	@Converter
	public static String toString (esbMessage msg) throws Exception {
		return new esbMessageHandler(msg).getMessageAsString();
	}
	
	@Converter
	public static esbMessage fromString (String src) throws Exception {
		return esbMessageHandler.readesbMessageFromXml(src);
	}
}

can you please help me with this issue.





--
View this message in context: http://camel.465427.n5.nabble.com/NoTypeConversionAvailableException-exception-while-running-junit-test-case-tp5799177.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message