2011-09-23 152 views
1

我一直在試圖得到一個servlet終端的基本例子,在駱駝工作。我的例子是基於這樣的:http://camel.apache.org/servlet-tomcat-example.html使用駱駝Servlet

當我試圖在Jetty中運行這個雖然我得到以下異常:'java.lang.IllegalStateException:沒有資源在org.apache.camel.component.servlet.CamelHttpTransportServlet/httpRegistry 「

這裏是我的web.xml

<!-- Camel 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>1</load-on-startup> 
</servlet> 

<!-- Camel servlet mapping --> 
<servlet-mapping> 
    <servlet-name>CamelServlet</servlet-name> 
    <url-pattern>/camel/*</url-pattern> 
</servlet-mapping> 


<!-- the listener that kick-starts Spring --> 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 
<!-- location of spring xml files --> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/applicationContext.xml</param-value> 
</context-param> 

這裏是我的applicationContext.xml:

<bean id="route" class="com.routes.smppRoute" /> 
<!-- the camel context --> 
<camelContext xmlns="http://camel.apache.org/schema/spring" id="camel"> 
    <routeBuilder ref="route" /> 
</camelContext> 

路線簡單獲取輸入和輸出到控制檯

public class smppRoute extends RouteBuilder { 
@Override 
public void configure() throws Exception { 
    from("servlet:///").to("stream:out"); 

} 

}

我敢肯定,我在所有的依賴關係,這裏是pom.xml中:

<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>com.fundamo</groupId> 
<artifactId>fundamo-platform-smpp-camel</artifactId> 
<version>1.0-SNAPSHOT</version> 

<name>Camel Router Application</name> 
<description>Camel project that deploys the Camel routes as a WAR</description> 
<url>http://www.myorganization.org</url> 

<packaging>war</packaging> 

<repositories> 
    <repository> 
     <id>org.apache.camel</id> 
     <url>https://repository.apache.org/content/groups/snapshots-group</url> 
    </repository> 
</repositories> 

<dependencies> 

    <!-- Camel Dependencies --> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-core</artifactId> 
     <version>2.7-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-spring</artifactId> 
     <version>2.7-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-stream</artifactId> 
     <version>2.7-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-servlet</artifactId> 
     <version>2.7-SNAPSHOT</version> 
    </dependency> 
    <!-- Spring Web --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 

    <!-- logging --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.5.11</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.16</version> 
    </dependency> 

</dependencies> 

<build> 
    <defaultGoal>install</defaultGoal> 

    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 

     <!-- plugin so you can run mvn jetty:run --> 
     <plugin> 
      <groupId>org.mortbay.jetty</groupId> 
      <artifactId>jetty-maven-plugin</artifactId> 
      <version>7.2.2.v20101205</version> 

      <configuration> 
       <webAppConfig> 
        <contextPath>/</contextPath> 
       </webAppConfig> 

       <systemProperties> 
        <!-- enable easy JMX connection to JConsole --> 
        <systemProperty> 
         <name>com.sun.management.jmxremote</name> 
         <value /> 
        </systemProperty> 
       </systemProperties> 
       <scanIntervalSeconds>10</scanIntervalSeconds> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

+1

好吧,現在這個工作,我更新了我使用的駱駝版本。看起來像有一個錯誤的種類 – Ren

回答

1

您可以嘗試將版本更改爲2.8.1而不是使用2.7-SNAPSHOT? 我只是做了一些測試駱駝樹幹中的camel-example-servlet-tomcat,它不會拋出這樣的錯誤。