2
我收到以下錯誤:拋出java.lang.ClassNotFoundException:org.apache.camel.Component在wildfly
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]
請檢查您的類路徑。這是缺少駱駝組件的jar。如果可能的話,用類路徑中的activeMQ相關jar更新問題。 –