You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by anshuman <an...@gmail.com> on 2012/07/05 15:24:56 UTC

Need Help for Camel Servlet example for ServiceMix

Im comparatively a novice in the Camel and ServiceMix . So I was trying to
learn a simple servlet example using Camel and deploying in ServiceMix. 

I tried the Camel-Servlet-Tomcat example which came with the distribution
and it worked fine with Tomcat .

However, Im facing difficulty in deploying it in the ServiceMix.

Exception:
~~~~~~~~~~~~~
17:56:19,382 | ERROR | l Console Thread | ContextLoader                    |
?                                   ? | 219 -
file____E__ECLIPSE__CAMEL_01_CamelExample_target_01_CamelExample-1.0.war -
0.0.0 | Context initialization failed
org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToCreateRouteException: Failed to create route
route1: Route[[From[camel/hello]] -> [Choice[[When[header{name} -> [...
because of No endpoint could be found for: camel/hello, please check your
classpath contains the needed Camel component jar.
        at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1145)[219:file____E__ECLIPSE__CAMEL_01_CamelExample_target_01_CamelExample-1.0.war:0]
        at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)[219:file____E__ECLIPSE__CAMEL_01_CamelExample_target_01_CamelExample-1.0.war:0]


camel-config.xml
~~~~~~~~~~~~~~~~~~~
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
	xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

	<camelContext xmlns="http://camel.apache.org/schema/spring">
		<route>
			
			<from uri="camel/hello" />
			<choice>
				<when>
					<header>name</header>
					<transform>
						<simple>Hello ${header.name}, How are you?</simple>
					</transform>
				</when>
				<otherwise>
					<transform>
						<constant>Add a name parameter to URI, eg "?name=foo"</constant>
					</transform>
				</otherwise>
			</choice>
		</route>
	</camelContext>

</beans>

web.xml
~~~~~~~
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

	<display-name>My Web Application</display-name>

	
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:camel-config.xml</param-value>
	</context-param>

	
	<listener>
	
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	
	<servlet>
		<servlet-name>CamelServlet</servlet-name>
	
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
		<init-param>
			<param-name>matchOnUriPrefix</param-name>
			<param-value>true</param-value>
		</init-param></servlet>

	
	<servlet-mapping>
		<servlet-name>CamelServlet</servlet-name>
		<url-pattern>/camel/hello</url-pattern>
	</servlet-mapping>

</web-app>

Both the files are there in the WEB-INF . Im using camel-2.8.0-fuse-05-03 
and apache-servicemix-4.4.1-fuse-06-03 .

Please guide me how I can fix this problem , so that I can move further . I
have already tried to access many blogs to fix the problem since last 10
days or so . 


Thanks in advance .


--
View this message in context: http://servicemix.396122.n5.nabble.com/Need-Help-for-Camel-Servlet-example-for-ServiceMix-tp5713835.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Need Help for Camel Servlet example for ServiceMix

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You need to install camel-servlet feature first

Run from the SMX shell
features:install camel-serlvet

And how do you deploy your application?
Do you use the WAR url handler, or drop the WAR file in the deploy directory?


On Thu, Jul 5, 2012 at 3:24 PM, anshuman <an...@gmail.com> wrote:
> Im comparatively a novice in the Camel and ServiceMix . So I was trying to
> learn a simple servlet example using Camel and deploying in ServiceMix.
>
> I tried the Camel-Servlet-Tomcat example which came with the distribution
> and it worked fine with Tomcat .
>
> However, Im facing difficulty in deploying it in the ServiceMix.
>
> Exception:
> ~~~~~~~~~~~~~
> 17:56:19,382 | ERROR | l Console Thread | ContextLoader                    |
> ?                                   ? | 219 -
> file____E__ECLIPSE__CAMEL_01_CamelExample_target_01_CamelExample-1.0.war -
> 0.0.0 | Context initialization failed
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.FailedToCreateRouteException: Failed to create route
> route1: Route[[From[camel/hello]] -> [Choice[[When[header{name} -> [...
> because of No endpoint could be found for: camel/hello, please check your
> classpath contains the needed Camel component jar.
>         at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1145)[219:file____E__ECLIPSE__CAMEL_01_CamelExample_target_01_CamelExample-1.0.war:0]
>         at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)[219:file____E__ECLIPSE__CAMEL_01_CamelExample_target_01_CamelExample-1.0.war:0]
>
>
> camel-config.xml
> ~~~~~~~~~~~~~~~~~~~
> <beans xmlns="http://www.springframework.org/schema/beans"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:camel="http://camel.apache.org/schema/spring"
>         xsi:schemaLocation="
>        http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>        http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd">
>
>         <camelContext xmlns="http://camel.apache.org/schema/spring">
>                 <route>
>
>                         <from uri="camel/hello" />
>                         <choice>
>                                 <when>
>                                         <header>name</header>
>                                         <transform>
>                                                 <simple>Hello ${header.name}, How are you?</simple>
>                                         </transform>
>                                 </when>
>                                 <otherwise>
>                                         <transform>
>                                                 <constant>Add a name parameter to URI, eg "?name=foo"</constant>
>                                         </transform>
>                                 </otherwise>
>                         </choice>
>                 </route>
>         </camelContext>
>
> </beans>
>
> web.xml
> ~~~~~~~
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>
>         <display-name>My Web Application</display-name>
>
>
>         <context-param>
>                 <param-name>contextConfigLocation</param-name>
>                 <param-value>classpath:camel-config.xml</param-value>
>         </context-param>
>
>
>         <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>         </listener>
>
>
>         <servlet>
>                 <servlet-name>CamelServlet</servlet-name>
>
> <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
>                 <init-param>
>                         <param-name>matchOnUriPrefix</param-name>
>                         <param-value>true</param-value>
>                 </init-param></servlet>
>
>
>         <servlet-mapping>
>                 <servlet-name>CamelServlet</servlet-name>
>                 <url-pattern>/camel/hello</url-pattern>
>         </servlet-mapping>
>
> </web-app>
>
> Both the files are there in the WEB-INF . Im using camel-2.8.0-fuse-05-03
> and apache-servicemix-4.4.1-fuse-06-03 .
>
> Please guide me how I can fix this problem , so that I can move further . I
> have already tried to access many blogs to fix the problem since last 10
> days or so .
>
>
> Thanks in advance .
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Need-Help-for-Camel-Servlet-example-for-ServiceMix-tp5713835.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen