搜索

此内容没有您所选择的语言版本。

5.2. Deploy the Apache Camel Servlet

download PDF

Overview

This tutorial takes a standard Apache Camel example (the camel-example-servlet-tomcat example) and shows you how to deploy it into a Web server, by packaging the application as a WAR.

Prerequisites

The following prerequisites are needed to build and run this example:
  • Either of the following Web servers are installed:
    • JBoss Web Server, or
    • JBoss Enterprise Application Platform
  • Java version 1.7 or later is installed.
  • Apache Maven 3.0.0 or later is installed.
  • Maven is configured to access the JBoss Fuse repositories, as described in Section 3.1, “Preparing to use Maven”.
  • You have access to the Internet, so that Maven can download dependencies from remote repositories.

Install Apache Camel

To obtain the code for the camel-example-servlet-tomcat example, you need to install the Apache Camel kit, apache-camel-2.17.0.redhat-630xxx.zip, provided in the extras/ directory of the JBoss Fuse installation.
Install the Apache Camel kit as follows:
  1. Find the Apache Camel kit at the following location:
    InstallDir/extras/apache-camel-2.17.0.redhat-630xxx.zip
  2. Using a suitable archive utility on your platform, unzip the apache-camel-2.17.0.redhat-630xxx.zip file and extract it to a convenient location, CamelInstallDir.

The camel-example-servlet-tomcat example

The camel-example-servlet-tomcat example is located under the following sub-directory of the Apache Camel installation:
CamelInstallDir/examples/camel-example-servlet-tomcat/

Build and run the example

To build and run the camel-example-servlet-tomcat example, perform the following steps:
  1. Build the camel-example-servlet-tomcat example using Maven. Change directory to the CamelInstallDir/examples/camel-example-servlet-tomcat/ directory, open a command prompt, and enter the following command at the command line:
    mvn package
    If this command executes successfully, you should be able to find the WAR file, camel-example-servlet-tomcat-2.17.0.redhat-630xxx.war, under the camel-example-servlet-tomcat/target sub-directory.
  2. Make sure that the Web server is already running (a simple way to test this is to enter the URL, http://localhost:8080, into your browser). If you need to start the Web server, you can typically do this from the command line. The command to start the Web server depends on the particular product you are using, as follows:
    • JBoss Web Server (WS)—open a new command prompt and execute the startup.sh script from the tomcat8/bin/ directory (or the tomcat7/bin/ directory, as appropriate). For more details about how to configure and launch the WS, see the Installation Guide from the JBoss Web Server library.
    • JBoss Enterprise Application Platform (EAP)—for a standalone instance, open a new command prompt and execute the bin/standalone.sh script. For more details about how to configure and launch the EAP, see the Administration and Configuration Guide from the JBoss Enterprise Application Platform library.
  3. Deploy the camel-example-servlet-tomcat example to the running Web server. Manually copy the camel-example-servlet-tomcat-2.17.0.redhat-630xxx.war WAR file from the camel-example-servlet-tomcat/target directory to the Web server's deployment directory, as follows:
    • JBoss Web Server (WS)—copy the camel-example-servlet-tomcat-2.17.0.redhat-630xxx.war WAR file to the tomcat8/webapps directory (or tomcat7/webapps directory, as appropriate).
    • JBoss Enterprise Application Platform (EAP)—copy the camel-example-servlet-tomcat-2.17.0.redhat-630xxx.war WAR file to the standalone/deployments directory.
  4. Navigate to the following URL in your browser:
    http://localhost:8080/camel-example-servlet-tomcat-2.17.0.redhat-630xxx/
    When the page loads, you should see the following text in your browser window:
  5. Click the highlighted link in the line To get started click this link. and follow the on-screen instructions to test the servlet.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.