我正在使用apache camel寻找休息服务

时间:2017-05-04 12:36:48

标签: apache-camel

获取错误servlet不可用。使用驼峰的休息服务计划 获取错误servlet不可用。使用驼峰的休息服务计划 获取错误servlet不可用。使用驼峰的休息服务计划 获取错误servlet不可用。使用驼峰的休息服务计划

  17:03:15,180 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/my]] (ServerService Thread Pool -- 57) JBWEB000289: Servlet myServlet threw load() exception: java.lang.ClassNotFoundException: org.apache.camel.component.servlet.CamelHttpTransportServlet from [Module "deployment..war:main" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.7.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.7.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.7.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.7.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.7.Final-redhat-1]
        at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:78) [jboss-as-web-7.5.10.Final-redhat-2.jar:7.5.10.Final-redhat-2]
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1166) [jbossweb-7.5.17.Final-redhat-1.jar:7.5.17.Final-redhat-1]
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1112) [jbossweb-7.5.17.Final-redhat-1.jar:7.5.17.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3593) [jbossweb-7.5.17.Final-redhat-1.jar:7.5.17.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3802) [jbossweb-7.5.17.Final-redhat-1.jar:7.5.17.Final-redhat-1]
        at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.10.Final-redhat-2.jar:7.5.10.Final-redhat-2]
        at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.10.Final-redhat-2.jar:7.5.10.Final-redhat-2]
        at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.10.Final-redhat-2.jar:7.5.10.Final-redhat-2]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_121]
        at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_121]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_121]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122)

    web.xml::
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
       <servlet>
        <display-name>Camel Http Transport Servlet</display-name>
        <servlet-name>apiServlet</servlet-name>
        <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
        <init-param>
        <param-name>ignoreDuplicateServletName</param-name>
        <param-value>true</param-value>
      </init-param>
      </servlet>
      <servlet-mapping>
        <servlet-name>myServlet</servlet-name>
        <url-pattern>/*</url-pattern>
      </servlet-mapping> 
    </web-app>

    pom.xml::
    <!-- Provided -->
            <dependency>
                <groupId>javax.enterprise</groupId>
                <artifactId>cdi-api</artifactId>
                <version>1.2</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-cdi</artifactId>
                <version>2.14.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-http</artifactId>
                <version>2.14.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-http4</artifactId>
                <version>2.14.1</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
                <version>1.0.0.Final-redhat-1</version>
                <scope>system</scope>
                <systemPath>${project.basedir}/lib/hibernate-jpa-2.1-api-1.0.0.Final-redhat-1.jar</systemPath>
            </dependency>
            <dependency>
                <groupId>org.jboss.spec.javax.ejb</groupId>
                <artifactId>jboss-ejb-api_3.1_spec</artifactId>
                <version>1.0.2.Final</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.spec.javax.servlet</groupId>
                <artifactId>jboss-servlet-api_3.0_spec</artifactId>
                <version>1.0.2.Final</version>
                <scope>provided</scope>
            </dependency>
jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>

<jboss-web>
    <context-root>my</context-root>
</jboss-web>

routeBuilder::
public class MYRouteBuilder extends RouteBuilder {
    @Inject
     private MYRouteBuilderRequestResponseHandler requestResponse;

    @Override
    public void configure() throws Exception {
        CommonUtils commonUtils=new CommonUtils(); 
        restConfiguration().component("servlet").contextPath("/my").bindingMode(RestBindingMode.off).endpointProperty("servletName", "myServlet") .port(8084);

1 个答案:

答案 0 :(得分:1)

阿迪提

你将很多东西混合在一起,希望它能够发挥作用本身&#39;。它没有赢。您必须将Camel上下文配置为servlet。

首先,您可能需要查看一些示例,例如https://camel.apache.org/servlet-tomcat-example.html