concept Apache Tomcat in category camel

appears as: Apache Tomcat
Camel in Action

This is an excerpt from Manning's book Camel in Action.

This example is packaged as a WAR deployment unit that can be deployed to any Java EE web server such as Apache Tomcat or WildFly. We’ll now show you how to test your deployments running inside WildFly.

  • Running Camel in a web environment such as Apache Tomcat
  • Figure 15.8 Using SoapUI to test the web service from the deployed application in Apache Tomcat

    15_08.png

    Using Apache Tomcat for HTTP inbound endpoints

    When using Camel in an existing servlet container, such as Apache Tomcat, you may have to adjust Camel components in your application to tap into the servlet container. In the Rider Auto Parts application, it’s the CXF component you must adjust. First, you have to add CXFServlet to the web.xml file, as shown in the following listing.

    Listing 15.7 The web.xml file with CXFServlet to tap into Apache Tomcat
    <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> </web-app>
    Camel in Action

    This is an excerpt from Manning's book Camel in Action.

    For the special case where you can’t start up an embedded Jetty server and need to hook in to the existing servlet container (like Apache Tomcat), you can use the Servlet component.

  • Running Camel in a web environment on Apache Tomcat
  • Let’s look at how you can run Camel as a web application in Apache Tomcat.

    Figure 13.8. Using SoapUI testing the web service from the deployed application in Apache Tomcat
    Listing 13.7. The web.xml file with CXFServlet to tap into Apache Tomcat
    <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> </web-app>