You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Indu <ne...@gmail.com> on 2010/09/16 23:27:32 UTC

Camel Cxf example. Jetty Server starting while JBoss already Running

Hi Team,
 
 I have a simple Camel CXF example running, which is based from the Camel In
Action examples provided.

 I am able to build and run successfully. But here is the problem I am
coming across.

 I am building the war and then deploying in the JBoss AS which is running
at localhost:8080. But meanwhile even Jetty server is strating up and
creating the Bind problems and causing :

HTTP ERROR: 404

Problem accessing /camel-cxf/index.jsp. Reason:

    NOT_FOUND

Powered by Jetty://


Now except for my wsdl, nothing comes up.

For example:
I get the following one fine.
http://localhost:8080/camel-cxf/web-services/order?wsdl  

But when I try to access all the reaming pages like;
http://localhost:8080/camel-cxf/index.jsp
http://localhost:8080/

I get the following error.
HTTP ERROR: 
Problem accessing /camel-cxf/index.jsp. Reason:

    NOT_FOUND

Powered by Jetty://


My question:
How do I avoid Jetty to start the server along with the webservice, when my
Jboss is already running?

Here is my 
1) META-INF/spring/camel-cfg.xml:

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

  <import resource="classpath:META-INF/cxf/cxf.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
  
  
  
  <cxf:cxfEndpoint id="orderEndpoint"
                  
address="http://localhost:8080/camel-cxf/web-services/order"
                   serviceClass="camelinaction.order.OrderEndpoint"/>
</beans>



2) META-INF/spring/camel-route.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-2.5.xsd
         http://camel.apache.org/schema/spring 
         http://camel.apache.org/schema/spring/camel-spring.xsd">

  <import resource="classpath:META-INF/spring/camel-cxf.xml" />

  <camelContext xmlns="http://camel.apache.org/schema/spring">
  
    <route>
      <!-- route starts from the cxf webservice, see camel-cxf.xml for
details -->
      <from uri="cxf:bean:orderEndpoint" />
      <to uri="seda:incomingOrders" />
      <!-- and then create the OK reply for the webservice which is still
waiting for a reply -->
      <transform>
        <constant>OK. Successful!</constant>
      </transform>
    </route>
  
    <!-- test route -->
    <route>
      <from uri="seda:incomingOrders" />
      <to uri="mock:end"/>
    </route>
  </camelContext>

</beans>

3) WEB_INF/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> 

  <context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>
		classpath:META-INF/spring/camel-route.xml
	</param-value>
  </context-param>

  <servlet>
    <servlet-name>Context servlet</servlet-name>
   
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
  </servlet>
  
  <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>
    <load-on-startup>4</load-on-startup>
  </servlet>

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

  
</web-app>



4) POM file:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>camel-proj</groupId>
  <artifactId>camel-cxf</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>Simple CXF project using spring configuration</name>
  
  <properties>
		<camel-version>2.2.0</camel-version>
		<cxf-version>2.2.7</cxf-version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>
  
 
  <dependencies>
  <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
      <version>${camel-version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-cxf</artifactId>
      <version>${camel-version}</version>
    </dependency>

    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.16</version>
    </dependency>

    <!-- cxf using slf4j -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.5.8</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.8</version>
    </dependency>

    <!-- using Jetty with CXF -->
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
      <version>2.2.8</version>
    </dependency><!--

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test</artifactId>
      <version>${camel-version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
 
	<dependency>
		<groupId>org.apache.camel</groupId>
		<artifactId>camel-servlet</artifactId>
		<version>2.1.0</version>
		<type>jar</type>
		<scope>compile</scope>
    </dependency>
	<dependency>
		<groupId>javax.xml</groupId>
		<artifactId>jaxp-api</artifactId>
		<version>1.4.2</version>
		<type>jar</type>
		<scope>compile</scope>
	</dependency>
	</dependencies>

  <build>
  
  <finalName>camel-cxf</finalName>
  
    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.5</source>
            <target>1.5</target>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-eclipse-plugin</artifactId>
          <configuration>
           
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
            <wtpmanifest>true</wtpmanifest>
            <wtpapplicationxml>true</wtpapplicationxml>
            <wtpversion>2.0</wtpversion>
          </configuration>
        </plugin>
        </plugins>
    </pluginManagement>
  </build>
  </project>


5) OrderEndpoint.java

package camelinaction.order;

import javax.jws.WebService;

@WebService
public interface OrderEndpoint {
    public String order(String partName, int amount, String customerName);
}


I would really appreciate some direction, even though it may be simple
answer.

I was thinking the import statement is causing the jetty to run, when when I
take it off, I am getting errors.

 <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>




-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-Cxf-example-Jetty-Server-starting-while-JBoss-already-Running-tp2843017p2843017.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Cxf example. Jetty Server starting while JBoss already Running

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

See the section title _USING APACHE TOMCAT FOR HTTP INBOUND ENDPOINTS_
in the Camel in Action book, chapter 13.
It shows how to leverage the http server inside Tomcat (but it should
be the same for JBoss).




On Thu, Sep 16, 2010 at 11:27 PM, Indu <ne...@gmail.com> wrote:
>
> Hi Team,
>
>  I have a simple Camel CXF example running, which is based from the Camel In
> Action examples provided.
>
>  I am able to build and run successfully. But here is the problem I am
> coming across.
>
>  I am building the war and then deploying in the JBoss AS which is running
> at localhost:8080. But meanwhile even Jetty server is strating up and
> creating the Bind problems and causing :
>
> HTTP ERROR: 404
>
> Problem accessing /camel-cxf/index.jsp. Reason:
>
>    NOT_FOUND
>
> Powered by Jetty://
>
>
> Now except for my wsdl, nothing comes up.
>
> For example:
> I get the following one fine.
> http://localhost:8080/camel-cxf/web-services/order?wsdl
>
> But when I try to access all the reaming pages like;
> http://localhost:8080/camel-cxf/index.jsp
> http://localhost:8080/
>
> I get the following error.
> HTTP ERROR:
> Problem accessing /camel-cxf/index.jsp. Reason:
>
>    NOT_FOUND
>
> Powered by Jetty://
>
>
> My question:
> How do I avoid Jetty to start the server along with the webservice, when my
> Jboss is already running?
>
> Here is my
> 1) META-INF/spring/camel-cfg.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xmlns:cxf="http://camel.apache.org/schema/cxf"
>       xsi:schemaLocation="
>         http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>         http://camel.apache.org/schema/cxf
>         http://camel.apache.org/schema/cxf/camel-cxf.xsd">
>
>  <import resource="classpath:META-INF/cxf/cxf.xml"/>
>  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
>  <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
>
>
>
>  <cxf:cxfEndpoint id="orderEndpoint"
>
> address="http://localhost:8080/camel-cxf/web-services/order"
>                   serviceClass="camelinaction.order.OrderEndpoint"/>
> </beans>
>
>
>
> 2) META-INF/spring/camel-route.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-2.5.xsd
>         http://camel.apache.org/schema/spring
>         http://camel.apache.org/schema/spring/camel-spring.xsd">
>
>  <import resource="classpath:META-INF/spring/camel-cxf.xml" />
>
>  <camelContext xmlns="http://camel.apache.org/schema/spring">
>
>    <route>
>      <!-- route starts from the cxf webservice, see camel-cxf.xml for
> details -->
>      <from uri="cxf:bean:orderEndpoint" />
>      <to uri="seda:incomingOrders" />
>      <!-- and then create the OK reply for the webservice which is still
> waiting for a reply -->
>      <transform>
>        <constant>OK. Successful!</constant>
>      </transform>
>    </route>
>
>    <!-- test route -->
>    <route>
>      <from uri="seda:incomingOrders" />
>      <to uri="mock:end"/>
>    </route>
>  </camelContext>
>
> </beans>
>
> 3) WEB_INF/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>
>
>  <context-param>
>        <param-name>contextConfigLocation</param-name>
>        <param-value>
>                classpath:META-INF/spring/camel-route.xml
>        </param-value>
>  </context-param>
>
>  <servlet>
>    <servlet-name>Context servlet</servlet-name>
>
> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
>    <load-on-startup>2</load-on-startup>
>  </servlet>
>
>  <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>
>    <load-on-startup>4</load-on-startup>
>  </servlet>
>
>  <servlet-mapping>
>    <servlet-name>CamelServlet</servlet-name>
>    <url-pattern>/web-services/*</url-pattern>
>  </servlet-mapping>
>
>
> </web-app>
>
>
>
> 4) POM file:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>  <modelVersion>4.0.0</modelVersion>
>  <groupId>camel-proj</groupId>
>  <artifactId>camel-cxf</artifactId>
>  <version>0.0.1-SNAPSHOT</version>
>  <packaging>war</packaging>
>  <name>Simple CXF project using spring configuration</name>
>
>  <properties>
>                <camel-version>2.2.0</camel-version>
>                <cxf-version>2.2.7</cxf-version>
>                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>
> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>  </properties>
>
>
>  <dependencies>
>  <dependency>
>      <groupId>org.apache.camel</groupId>
>      <artifactId>camel-core</artifactId>
>      <version>${camel-version}</version>
>    </dependency>
>
>    <dependency>
>      <groupId>org.apache.camel</groupId>
>      <artifactId>camel-cxf</artifactId>
>      <version>${camel-version}</version>
>    </dependency>
>
>    <dependency>
>      <groupId>log4j</groupId>
>      <artifactId>log4j</artifactId>
>      <version>1.2.16</version>
>    </dependency>
>
>    <!-- cxf using slf4j -->
>    <dependency>
>      <groupId>org.slf4j</groupId>
>      <artifactId>slf4j-api</artifactId>
>      <version>1.5.8</version>
>    </dependency>
>    <dependency>
>      <groupId>org.slf4j</groupId>
>      <artifactId>slf4j-log4j12</artifactId>
>      <version>1.5.8</version>
>    </dependency>
>
>    <!-- using Jetty with CXF -->
>    <dependency>
>      <groupId>org.apache.cxf</groupId>
>      <artifactId>cxf-rt-transports-http-jetty</artifactId>
>      <version>2.2.8</version>
>    </dependency><!--
>
>    <dependency>
>      <groupId>org.apache.camel</groupId>
>      <artifactId>camel-test</artifactId>
>      <version>${camel-version}</version>
>      <scope>test</scope>
>    </dependency>
>
>    <dependency>
>      <groupId>junit</groupId>
>      <artifactId>junit</artifactId>
>      <version>4.8.1</version>
>      <scope>test</scope>
>    </dependency>
>
>        <dependency>
>                <groupId>org.apache.camel</groupId>
>                <artifactId>camel-servlet</artifactId>
>                <version>2.1.0</version>
>                <type>jar</type>
>                <scope>compile</scope>
>    </dependency>
>        <dependency>
>                <groupId>javax.xml</groupId>
>                <artifactId>jaxp-api</artifactId>
>                <version>1.4.2</version>
>                <type>jar</type>
>                <scope>compile</scope>
>        </dependency>
>        </dependencies>
>
>  <build>
>
>  <finalName>camel-cxf</finalName>
>
>    <pluginManagement>
>      <plugins>
>
>        <plugin>
>          <groupId>org.apache.maven.plugins</groupId>
>          <artifactId>maven-compiler-plugin</artifactId>
>          <configuration>
>            <source>1.5</source>
>            <target>1.5</target>
>          </configuration>
>        </plugin>
>        <plugin>
>          <groupId>org.apache.maven.plugins</groupId>
>          <artifactId>maven-eclipse-plugin</artifactId>
>          <configuration>
>
> <projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
>            <wtpmanifest>true</wtpmanifest>
>            <wtpapplicationxml>true</wtpapplicationxml>
>            <wtpversion>2.0</wtpversion>
>          </configuration>
>        </plugin>
>        </plugins>
>    </pluginManagement>
>  </build>
>  </project>
>
>
> 5) OrderEndpoint.java
>
> package camelinaction.order;
>
> import javax.jws.WebService;
>
> @WebService
> public interface OrderEndpoint {
>    public String order(String partName, int amount, String customerName);
> }
>
>
> I would really appreciate some direction, even though it may be simple
> answer.
>
> I was thinking the import statement is causing the jetty to run, when when I
> take it off, I am getting errors.
>
>  <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Cxf-example-Jetty-Server-starting-while-JBoss-already-Running-tp2843017p2843017.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Camel Cxf example. Jetty Server starting while JBoss already Running

Posted by Willem Jiang <wi...@gmail.com>.
On 9/17/10 10:49 PM, Indu wrote:
>
> Claus, Willem
>    The solution worked like a charm.
>
>    Big Thanks for you all.
>
>    Meanwhile I am reading the chapters more closely to see how I can use the
> CamelHttpTransportServlet
>    to handle all the endpoints in Java DSL because it is already handling few
> of then like servlet:///, JMS, and others.
>    I am using this servlet to map all the requests in the web.xml under
> /services.
>
>    so now if I am using CXF Servlet to handle the web service endpoint and
> mapping with /services then it would be two Servlets to process the
> routes/endpoints.
>
>    so I have to see how I can integrate them where all my endpoints in the
> router (configure) with one servlet, possibly CamelHttpTransportServlet?
>

It depends on how you define the route?
There is a CamelTransport for CXF[1] that you may take a look.
You can do the same thing on the camel-cxf endpoint.

[1]http://camel.apache.org/cxf-example.html#CXFExample-CXFexampleforusingCameltransport

Willem

>   please suggest any possible solutions or pertinent reading.
>
>   Thanks for your quick support, I will be a active user/contributor to this
> forum.
>
>   Indu.




Re: Camel Cxf example. Jetty Server starting while JBoss already Running

Posted by Indu <ne...@gmail.com>.
Claus, Willem
  The solution worked like a charm.

  Big Thanks for you all.

  Meanwhile I am reading the chapters more closely to see how I can use the
CamelHttpTransportServlet
  to handle all the endpoints in Java DSL because it is already handling few
of then like servlet:///, JMS, and others. 
  I am using this servlet to map all the requests in the web.xml under
/services.

  so now if I am using CXF Servlet to handle the web service endpoint and
mapping with /services then it would be two Servlets to process the
routes/endpoints.

  so I have to see how I can integrate them where all my endpoints in the
router (configure) with one servlet, possibly CamelHttpTransportServlet? 

 please suggest any possible solutions or pertinent reading.

 Thanks for your quick support, I will be a active user/contributor to this
forum.

 Indu.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-Cxf-example-Jetty-Server-starting-while-JBoss-already-Running-tp2843017p2843807.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Cxf example. Jetty Server starting while JBoss already Running

Posted by Willem Jiang <wi...@gmail.com>.
On 9/17/10 5:27 AM, Indu wrote:
>
> Hi Team,
>
>   I have a simple Camel CXF example running, which is based from the Camel In
> Action examples provided.
>
>   I am able to build and run successfully. But here is the problem I am
> coming across.
>
>   I am building the war and then deploying in the JBoss AS which is running
> at localhost:8080. But meanwhile even Jetty server is strating up and
> creating the Bind problems and causing :
>
> HTTP ERROR: 404
>
> Problem accessing /camel-cxf/index.jsp. Reason:
>
>      NOT_FOUND
>
> Powered by Jetty://
>
>
> Now except for my wsdl, nothing comes up.
>
> For example:
> I get the following one fine.
> http://localhost:8080/camel-cxf/web-services/order?wsdl
>
> But when I try to access all the reaming pages like;
> http://localhost:8080/camel-cxf/index.jsp
> http://localhost:8080/
>
> I get the following error.
> HTTP ERROR:
> Problem accessing /camel-cxf/index.jsp. Reason:
>
>      NOT_FOUND
>
> Powered by Jetty://
>
>
> My question:
> How do I avoid Jetty to start the server along with the webservice, when my
> Jboss is already running?
>

>
> I was thinking the import statement is causing the jetty to run, when when I
> take it off, I am getting errors.
>
>   <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
>
>
You need to take a look the user guide of CXF servlet transport.
[1]http://cxf.apache.org/docs/servlet-transport.html

Then you can do the same thing on the camel-cxf endpoint.

Willem
>
>