You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2010/01/05 15:43:33 UTC

camel-servlet / Karaf / War / Tomcat

Hi,

I have packaged my OSGI project including camel context in a WAR file. This
WAR file contains Felix Karaf server which is started by the Tomcat Web
Application Server though a bundle activator.

My camel context uses camel-servlet endpoint to have access to servlet
published by Tomcat

        <camel:route>
            <camel:from uri="servlet:///?matchOnUriPrefix=true" />
            <camel:to uri="cxfbean:restFulService" />
        </camel:route>

Question :

Can the camel-servlet endpoint (bundle started by karaf) retrieve the
servlet org.apache.camel.component.servlet.CamelHttpTransportServlet if this
one is created by Tomcat ?

<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
">

  <listener>

<listener-class>org.apache.felix.karaf.web.WebAppListener</listener-class>
  </listener>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <servlet>
    <servlet-name>CamelServlet</servlet-name>
    <display-name>Camel Http Transport Servlet</display-name>

<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
  </servlet>

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


</web-app>


I don't think so because classloading of osgi cannot see what tomcat loads.

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm

Re: camel-servlet / Karaf / War / Tomcat

Posted by Charles Moulliard <cm...@gmail.com>.
yep but in this case, we create a dependency between
CamelHttpTransportServlet and Karaf bootsrap class.

This is not really important as I'm not sure that using camel + karaf or
SMX4 embedded in a WAR is the best choice. It is better to create a
classical WAR in this case containing camel/spring classes without osgi.

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm


On Wed, Jan 6, 2010 at 3:25 AM, Willem Jiang <wi...@gmail.com> wrote:

> Hi Charles,
>
> I think if you can make sure the servlet is deployed before the camel
> context started, the camel-servlet endpoint can get the access the
> CamelHttpTransportServlet instance.
> As the CamelHttpTransportServlet and Karaf are using the same classloader,
> I think it should be OK for camel-servlet endpoint accessing the
> CamelHttpTransportServlet instance.
>
> If you extends the CamelHttpTransportServlet and load the Karaf when the
> Servlet start, maybe we can workaround the camelContext starting issue.
>
> Willem
>
>
> Charles Moulliard wrote:
>
>> Hi,
>>
>> I have packaged my OSGI project including camel context in a WAR file.
>> This
>> WAR file contains Felix Karaf server which is started by the Tomcat Web
>> Application Server though a bundle activator.
>>
>> My camel context uses camel-servlet endpoint to have access to servlet
>> published by Tomcat
>>
>>        <camel:route>
>>            <camel:from uri="servlet:///?matchOnUriPrefix=true" />
>>            <camel:to uri="cxfbean:restFulService" />
>>        </camel:route>
>>
>> Question :
>>
>> Can the camel-servlet endpoint (bundle started by karaf) retrieve the
>> servlet org.apache.camel.component.servlet.CamelHttpTransportServlet if
>> this
>> one is created by Tomcat ?
>>
>> <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
>> ">
>>
>>  <listener>
>>
>> <listener-class>org.apache.felix.karaf.web.WebAppListener</listener-class>
>>  </listener>
>>
>>  <welcome-file-list>
>>    <welcome-file>index.jsp</welcome-file>
>>  </welcome-file-list>
>>
>>  <servlet>
>>    <servlet-name>CamelServlet</servlet-name>
>>    <display-name>Camel Http Transport Servlet</display-name>
>>
>>
>> <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
>>  </servlet>
>>
>>  <servlet-mapping>
>>    <servlet-name>CamelServlet</servlet-name>
>>    <url-pattern>/services/*</url-pattern>
>>  </servlet-mapping>
>>
>>
>> </web-app>
>>
>>
>> I don't think so because classloading of osgi cannot see what tomcat
>> loads.
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>>
>> Apache Camel Group :
>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>>
>>
>
>

Re: camel-servlet / Karaf / War / Tomcat

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

I think if you can make sure the servlet is deployed before the camel 
context started, the camel-servlet endpoint can get the access the 
CamelHttpTransportServlet instance.
As the CamelHttpTransportServlet and Karaf are using the same 
classloader, I think it should be OK for camel-servlet endpoint 
accessing the CamelHttpTransportServlet instance.

If you extends the CamelHttpTransportServlet and load the Karaf when the 
Servlet start, maybe we can workaround the camelContext starting issue.

Willem

Charles Moulliard wrote:
> Hi,
> 
> I have packaged my OSGI project including camel context in a WAR file. This
> WAR file contains Felix Karaf server which is started by the Tomcat Web
> Application Server though a bundle activator.
> 
> My camel context uses camel-servlet endpoint to have access to servlet
> published by Tomcat
> 
>         <camel:route>
>             <camel:from uri="servlet:///?matchOnUriPrefix=true" />
>             <camel:to uri="cxfbean:restFulService" />
>         </camel:route>
> 
> Question :
> 
> Can the camel-servlet endpoint (bundle started by karaf) retrieve the
> servlet org.apache.camel.component.servlet.CamelHttpTransportServlet if this
> one is created by Tomcat ?
> 
> <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
> ">
> 
>   <listener>
> 
> <listener-class>org.apache.felix.karaf.web.WebAppListener</listener-class>
>   </listener>
> 
>   <welcome-file-list>
>     <welcome-file>index.jsp</welcome-file>
>   </welcome-file-list>
> 
>   <servlet>
>     <servlet-name>CamelServlet</servlet-name>
>     <display-name>Camel Http Transport Servlet</display-name>
> 
> <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
>   </servlet>
> 
>   <servlet-mapping>
>     <servlet-name>CamelServlet</servlet-name>
>     <url-pattern>/services/*</url-pattern>
>   </servlet-mapping>
> 
> 
> </web-app>
> 
> 
> I don't think so because classloading of osgi cannot see what tomcat loads.
> 
> Regards,
> 
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
> 
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
> 
> Apache Camel Group :
> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>