You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "manoj.sahu" <ma...@yahoo.com> on 2012/03/11 08:59:05 UTC

Re: Camel and Tomcat

Hi,

ContextLoaderServlet is deprecated in Spring 3.  

I am getting the exact error.  

java.lang.IllegalArgumentException: Cannot find the deployed servlet, please
configure the ServletComponent or configure a
org.apache.camel.component.servlet.CamelHttpTransportServlet servlet in
web.xml 


I'm using a CamelHttpTransportServlet in my web.xml.  My web.xml looks same
as recommended by  Wilhem.  Is there a solution.  I am using camel 2.4.  Can
someone please give some pointers.

Thanks,
Manoj



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-and-Tomcat-tp3386793p5554245.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel and Tomcat

Posted by "manoj.sahu" <ma...@yahoo.com>.
Thanks for your pointer Willem.  It worked with version 2.7.5.  May be we
could have this information available in wiki so that it saves someone
grief.  

I already wrote an implementation to have it work in 2.4.0.  Here is the
outline of the solution just in case it helps someone who couldn't upgrade.  

Basically I did not register servlet:/// route through the context listener
but manually through spring application context event.  This is called after
web application context is initialized.
 
Here is the registrar:

public class ServletComponentRegistrar implements
ApplicationListener<ContextRefreshedEvent>, CamelContextAware {
	
	CamelContext camelContext;

	public MyService() {
		super();
		System.out.println("Application context listener is created!");
	}

	public void service() throws Exception {
		if (camelContext != null) {
			try {
				camelContext.addRoutes(new ServletComponentRoute());
			} catch (IllegalArgumentException e) {
				System.out.println("Exception is expected. Servlet component is not
initialized yet.  Waiting for next refresh of spring container " +
e.getMessage());
			}
		}
	}

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) throws
Exception {
		if (camelContext != null) {
			try {
				camelContext.addRoutes(new MyRoute());
			} catch (IllegalArgumentException e) {
				System.out.println("Exception is expected. Servlet component is not
initialized yet.  Waiting for next refresh of spring container " +
e.getMessage());
			}
	}
}

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-and-Tomcat-tp3386793p5568617.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel and Tomcat

Posted by Willem Jiang <wi...@gmail.com>.
There are some enhancement on the camel-servlet since camel 2.7.x.
If you want to leverage the spring ContextLoaderListener to load the 
file, you need to upgrade the camel that you use.

If not, you need to ask for commerical support as Apache Camel  2.4.0 
is released for almost 2 years.
 
On Wed Mar 14 03:39:23 2012, manoj.sahu wrote:
> Can someone please  give some guidance.  As per 2.4 servlet spec, Listners
> (ContexLoaderListener) are loaded first before the servlets in the
> container.  I am unsure how can this work.  When the spring context is
> loaded it will never find the necessary component to resolve the route with
> servlet://, which is defined in Spring.
>
> Am I missing something?
>
> I am using spirng 3 and camel 2.4. I am deploying under tomcat 6.
>
> Thanks!
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-and-Tomcat-tp3386793p5562315.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 


Re: Camel and Tomcat

Posted by "manoj.sahu" <ma...@yahoo.com>.
Can someone please  give some guidance.  As per 2.4 servlet spec, Listners
(ContexLoaderListener) are loaded first before the servlets in the
container.  I am unsure how can this work.  When the spring context is
loaded it will never find the necessary component to resolve the route with
servlet://, which is defined in Spring. 

Am I missing something? 

I am using spirng 3 and camel 2.4. I am deploying under tomcat 6.

Thanks!

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-and-Tomcat-tp3386793p5562315.html
Sent from the Camel - Users mailing list archive at Nabble.com.