You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jfaath <jf...@apache.org> on 2010/04/08 00:22:00 UTC

Deploying as web app with jetty endpoint

I've deployed my camel app as a web application in tomcat.  Works great.  The
main starting point for my route is an http server endpoint using
camel-jetty.  So, it seems weird to me that tomcat starts and then starts a
jetty instance.  Is there any way to use the actual tomcat instance for this
endpoint?  Does this make any sense?

Regards,

JF
-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28171746.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by jfaath <jf...@apache.org>.


willem.jiang wrote:
> 
> 
> Oh, you want to the camel servlet component be managed by camel web
> console.
> After go through the SpringServlet code I think you set the CamelRoute 
> configure location into the SpringServlet's  init-param just like 
> CamelHttpTransportServlet does, then you can add the 
> ContextLoaderListener as usual.
> 
> Willem
> 
> 

One of the major points of this thread was that you couldn't use the
ContextLoaderListener with the camel-servlet component due to bootstrapping
issues so this won't work at all.

However, I have come very close to getting this all to work.  Turns out
there's a ContextLoaderServlet that does the same thing as the listener. 
So, I can first load the camel-servlet, then load the context loader and
finally the jersey SpringServlet using the load-on-startup directive. 
Everything starts cleanly and the endpoint and routes work fine.  However,
the camel web console doesn't show up.  When I navigate to the url, I just
get a blank page.  Using the jersey SpringServlet as a servlet instead of a
listener seems to break the interface.

Can any web console experts chime in as to why this might be happening?  Can
the console work using the SpringServlet as a servlet as opposed to a
filter?

-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28256874.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by Willem Jiang <wi...@gmail.com>.
jfaath wrote:
> I should note that by turning the
> com.sun.jersey.spi.spring.container.servlet.SpringServlet into a servlet
> instead of a filter, I can start up Tomcat without error.  However, when I
> try to access a page I get this error:
> 
> java.lang.IllegalStateException: No WebApplicationContext found: no
> ContextLoaderListener registered?
> 
> Is there any way to pass the WebApplicationContext created by the camel
> servlet component to jersey's SpringServlet?
> 

Oh, you want to the camel servlet component be managed by camel web console.
After go through the SpringServlet code I think you set the CamelRoute 
configure location into the SpringServlet's  init-param just like 
CamelHttpTransportServlet does, then you can add the 
ContextLoaderListener as usual.

Willem
> 
> jfaath wrote:
>> That seems to finally work...providing I remove the "Jersey Filter" that
>> is used by the web console.  This effectively breaks the Camel web
>> console, so as of now it appears the two are incompatible.
>>
>>
>>
>> willem.jiang wrote:
>>> Oh, you should not use the ContextLoaderLister to load the camel route.
>>> There is a contextConfigLocation parameter that you can pass to the 
>>> CamelHttpTransportServlet to load the camel route.
>>> You can find the example here
>>> https://svn.apache.org/repos/asf/camel/trunk/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
>>>
>>> Willem
>>>
>>> jfaath wrote:
>>>> I played around with this by removing everything below the
>>>> ContextLoaderListener listener.  I still get the same error.  As a rule,
>>>> it
>>>> seems that Tomcat always loads listeners before servlets.
>>>>
>>>> What exactly is the expected behavior of the bootstrap process in the
>>>> servlet container?  What is the contextConfigLocation parameter supposed
>>>> to
>>>> do?
>>>>
>>>> Is there a sample of using this component in an actual servlet
>>>> container?
>>>>
>>>>
>>>> willem.jiang wrote:
>>>>> Hi,
>>>>>
>>>>> Can you remove the web console part and try again?
>>>>> Maybe there are some side effect of the web console configure.
>>>>>
>>>>> Willem
>>>>>
>>>>> jfaath wrote:
>>>>>> So should I post a JIRA on this?  The servlet component doesn't seem
>>>>>> to
>>>>>> work
>>>>>> in v2.2 when used in the web console.
>>>>>
>>>
>>>
>>
> 


Re: Deploying as web app with jetty endpoint

Posted by jfaath <jf...@apache.org>.
I should note that by turning the
com.sun.jersey.spi.spring.container.servlet.SpringServlet into a servlet
instead of a filter, I can start up Tomcat without error.  However, when I
try to access a page I get this error:

java.lang.IllegalStateException: No WebApplicationContext found: no
ContextLoaderListener registered?

Is there any way to pass the WebApplicationContext created by the camel
servlet component to jersey's SpringServlet?


jfaath wrote:
> 
> That seems to finally work...providing I remove the "Jersey Filter" that
> is used by the web console.  This effectively breaks the Camel web
> console, so as of now it appears the two are incompatible.
> 
> 
> 
> willem.jiang wrote:
>> 
>> Oh, you should not use the ContextLoaderLister to load the camel route.
>> There is a contextConfigLocation parameter that you can pass to the 
>> CamelHttpTransportServlet to load the camel route.
>> You can find the example here
>> https://svn.apache.org/repos/asf/camel/trunk/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
>> 
>> Willem
>> 
>> jfaath wrote:
>>> I played around with this by removing everything below the
>>> ContextLoaderListener listener.  I still get the same error.  As a rule,
>>> it
>>> seems that Tomcat always loads listeners before servlets.
>>> 
>>> What exactly is the expected behavior of the bootstrap process in the
>>> servlet container?  What is the contextConfigLocation parameter supposed
>>> to
>>> do?
>>> 
>>> Is there a sample of using this component in an actual servlet
>>> container?
>>> 
>>> 
>>> willem.jiang wrote:
>>>> Hi,
>>>>
>>>> Can you remove the web console part and try again?
>>>> Maybe there are some side effect of the web console configure.
>>>>
>>>> Willem
>>>>
>>>> jfaath wrote:
>>>>> So should I post a JIRA on this?  The servlet component doesn't seem
>>>>> to
>>>>> work
>>>>> in v2.2 when used in the web console.
>>>>
>>>>
>>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28248126.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by jfaath <jf...@apache.org>.
That seems to finally work...providing I remove the "Jersey Filter" that is
used by the web console.  This effectively breaks the Camel web console, so
as of now it appears the two are incompatible.



willem.jiang wrote:
> 
> Oh, you should not use the ContextLoaderLister to load the camel route.
> There is a contextConfigLocation parameter that you can pass to the 
> CamelHttpTransportServlet to load the camel route.
> You can find the example here
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
> 
> Willem
> 
> jfaath wrote:
>> I played around with this by removing everything below the
>> ContextLoaderListener listener.  I still get the same error.  As a rule,
>> it
>> seems that Tomcat always loads listeners before servlets.
>> 
>> What exactly is the expected behavior of the bootstrap process in the
>> servlet container?  What is the contextConfigLocation parameter supposed
>> to
>> do?
>> 
>> Is there a sample of using this component in an actual servlet container?
>> 
>> 
>> willem.jiang wrote:
>>> Hi,
>>>
>>> Can you remove the web console part and try again?
>>> Maybe there are some side effect of the web console configure.
>>>
>>> Willem
>>>
>>> jfaath wrote:
>>>> So should I post a JIRA on this?  The servlet component doesn't seem to
>>>> work
>>>> in v2.2 when used in the web console.
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28243271.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by Willem Jiang <wi...@gmail.com>.
Oh, you should not use the ContextLoaderLister to load the camel route.
There is a contextConfigLocation parameter that you can pass to the 
CamelHttpTransportServlet to load the camel route.
You can find the example here
https://svn.apache.org/repos/asf/camel/trunk/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml

Willem

jfaath wrote:
> I played around with this by removing everything below the
> ContextLoaderListener listener.  I still get the same error.  As a rule, it
> seems that Tomcat always loads listeners before servlets.
> 
> What exactly is the expected behavior of the bootstrap process in the
> servlet container?  What is the contextConfigLocation parameter supposed to
> do?
> 
> Is there a sample of using this component in an actual servlet container?
> 
> 
> willem.jiang wrote:
>> Hi,
>>
>> Can you remove the web console part and try again?
>> Maybe there are some side effect of the web console configure.
>>
>> Willem
>>
>> jfaath wrote:
>>> So should I post a JIRA on this?  The servlet component doesn't seem to
>>> work
>>> in v2.2 when used in the web console.
>>
>>
> 


Re: Deploying as web app with jetty endpoint

Posted by jfaath <jf...@apache.org>.
I played around with this by removing everything below the
ContextLoaderListener listener.  I still get the same error.  As a rule, it
seems that Tomcat always loads listeners before servlets.

What exactly is the expected behavior of the bootstrap process in the
servlet container?  What is the contextConfigLocation parameter supposed to
do?

Is there a sample of using this component in an actual servlet container?


willem.jiang wrote:
> 
> Hi,
> 
> Can you remove the web console part and try again?
> Maybe there are some side effect of the web console configure.
> 
> Willem
> 
> jfaath wrote:
>> So should I post a JIRA on this?  The servlet component doesn't seem to
>> work
>> in v2.2 when used in the web console.
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28230521.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Can you remove the web console part and try again?
Maybe there are some side effect of the web console configure.

Willem

jfaath wrote:
> So should I post a JIRA on this?  The servlet component doesn't seem to work
> in v2.2 when used in the web console.


Re: Deploying as web app with jetty endpoint

Posted by jfaath <jf...@apache.org>.
So should I post a JIRA on this?  The servlet component doesn't seem to work
in v2.2 when used in the web console.
-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28219175.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by jfaath <jf...@apache.org>.
Yea, I tried that based on thread I saw yesterday.  I still get the same
error.  I'm wondering if it has something to do with the way the camel web
console works.  Do I need to put anything in the beans file
(applicationContext.xml)?  Here is my web.xml:


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
  <description>
    Apache Camel Web Console
  </description>

  <display-name>Camel Console</display-name>
 
  <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>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>CamelServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

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

  <filter>
    <filter-name>sitemesh</filter-name>
   
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <filter>
    <filter-name>Jersey Filter</filter-name>
   
<filter-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</filter-class>
    <init-param>
     
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
     
<param-value>org.apache.camel.web.util.CamelResourceConfig</param-value>
    </init-param>
    <init-param>
      <param-name>com.sun.jersey.config.feature.Redirect</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
     
<param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>org.apache.camel.web</param-value>
    </init-param>
    <init-param>
     
<param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
      <param-value>/(images|css|js)/.*</param-value>
    </init-param>
    <init-param>
     
<param-name>com.sun.jersey.config.property.WadlResourceUri</param-name>
      <param-value>/api</param-value>
    </init-param>
  </filter>

  <filter-mapping>
    <filter-name>Jersey Filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <jsp-config>
    <jsp-property-group>
      <url-pattern>*.jsp</url-pattern>
      <include-prelude>/WEB-INF/jspf/header.jspf</include-prelude>
    </jsp-property-group>
  </jsp-config>
</web-app>








willem.jiang wrote:
> 
> You need make sure the CamelHttpTransportServle is deployed first, than 
> load the camel context.
> You can take a look at this example first[1].
> 
> [1] 
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
> jfaath wrote:
>> This is exactly like what I was looking for.  However, I tried out the
>> simple
>> example defined in the link you provided and I keep getting this error:
>> 
>> SEVERE: Exception sending context initialized event to listener instance
>> of
>> class org.springframework.web.context.ContextLoaderListener
>> org.apache.camel.RuntimeCamelException:
>> 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 
>> 
>> which appears to happen when the route is being read.  Any ideas?
>> 
>> 
>> 
>> willem.jiang wrote:
>>> Hi,
>>>
>>> If you don't want start the jetty engine, you can try to use the 
>>> camel-servlet[1] component.
>>>
>>> [1]http://camel.apache.org/servlet.html
>>>
>>>
>>> Willem
>>>
>>> jfaath wrote:
>>>> I've deployed my camel app as a web application in tomcat.  Works
>>>> great. 
>>>> The
>>>> main starting point for my route is an http server endpoint using
>>>> camel-jetty.  So, it seems weird to me that tomcat starts and then
>>>> starts
>>>> a
>>>> jetty instance.  Is there any way to use the actual tomcat instance for
>>>> this
>>>> endpoint?  Does this make any sense?
>>>>
>>>> Regards,
>>>>
>>>> JF
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28191050.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by Willem Jiang <wi...@gmail.com>.
You need make sure the CamelHttpTransportServle is deployed first, than 
load the camel context.
You can take a look at this example first[1].

[1] 
https://svn.apache.org/repos/asf/camel/trunk/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
jfaath wrote:
> This is exactly like what I was looking for.  However, I tried out the simple
> example defined in the link you provided and I keep getting this error:
> 
> SEVERE: Exception sending context initialized event to listener instance of
> class org.springframework.web.context.ContextLoaderListener
> org.apache.camel.RuntimeCamelException: 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 
> 
> which appears to happen when the route is being read.  Any ideas?
> 
> 
> 
> willem.jiang wrote:
>> Hi,
>>
>> If you don't want start the jetty engine, you can try to use the 
>> camel-servlet[1] component.
>>
>> [1]http://camel.apache.org/servlet.html
>>
>>
>> Willem
>>
>> jfaath wrote:
>>> I've deployed my camel app as a web application in tomcat.  Works great. 
>>> The
>>> main starting point for my route is an http server endpoint using
>>> camel-jetty.  So, it seems weird to me that tomcat starts and then starts
>>> a
>>> jetty instance.  Is there any way to use the actual tomcat instance for
>>> this
>>> endpoint?  Does this make any sense?
>>>
>>> Regards,
>>>
>>> JF
>>
>>
> 


Re: Deploying as web app with jetty endpoint

Posted by jfaath <jf...@apache.org>.
This is exactly like what I was looking for.  However, I tried out the simple
example defined in the link you provided and I keep getting this error:

SEVERE: Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
org.apache.camel.RuntimeCamelException: 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 

which appears to happen when the route is being read.  Any ideas?



willem.jiang wrote:
> 
> Hi,
> 
> If you don't want start the jetty engine, you can try to use the 
> camel-servlet[1] component.
> 
> [1]http://camel.apache.org/servlet.html
> 
> 
> Willem
> 
> jfaath wrote:
>> I've deployed my camel app as a web application in tomcat.  Works great. 
>> The
>> main starting point for my route is an http server endpoint using
>> camel-jetty.  So, it seems weird to me that tomcat starts and then starts
>> a
>> jetty instance.  Is there any way to use the actual tomcat instance for
>> this
>> endpoint?  Does this make any sense?
>> 
>> Regards,
>> 
>> JF
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Deploying-as-web-app-with-jetty-endpoint-tp28171746p28184153.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Deploying as web app with jetty endpoint

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

If you don't want start the jetty engine, you can try to use the 
camel-servlet[1] component.

[1]http://camel.apache.org/servlet.html


Willem

jfaath wrote:
> I've deployed my camel app as a web application in tomcat.  Works great.  The
> main starting point for my route is an http server endpoint using
> camel-jetty.  So, it seems weird to me that tomcat starts and then starts a
> jetty instance.  Is there any way to use the actual tomcat instance for this
> endpoint?  Does this make any sense?
> 
> Regards,
> 
> JF