java.lang.ClassNotFoundException:wildfly中的org.apache.camel.Component

时间:2015-04-07 10:38:51

标签: servlets apache-camel activemq wildfly-8

我收到以下错误:

java.lang.ClassNotFoundException: org.apache.camel.Component

我正在使用wildfly服务器。

我的代码是:

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class CamelRouter extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        try {

            CamelContext context = new DefaultCamelContext();
            context.addComponent("activemq",ActiveMQComponent.activeMQComponent(ActiveMQConnection.DEFAULT_BROKER_URL));
            context.addRoutes(new RouteBuilder() {
                public void configure() {
                    from("activemq:queue:testMQ").to(
                            "activemq:queue:testMQDestination");
                }
            });

            context.start();
            Thread.sleep(1000);
            context.stop();
            System.out.println("Done");
        } catch (Exception e) {
            System.out.println(e);
        }

    }


}

[注意:我使用普通的servlet。没有春天,没有maven]

1 个答案:

答案 0 :(得分:1)

您可能希望使用wildfly-camel模块在WildFly服务器中运行Apache Camel。