我有一个Camel应用程序,它使用servlet来公开REST API。我在Camel旁边使用SpringBoot。构建完WAR后,我可以使用java-jar运行它,它运行得很好。现在,当我将同一个WAR部署到tomcat/webapps中时,我在日志中得到以下错误:
java.lang.ClassCastException: class org.apache.camel.component.servlet.CamelHttpTransportServlet cannot be cast to class jakarta.servlet.Servlet (org.apache.camel.component.servlet.CamelHttpTransportServlet is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @4f2613d1; jakarta.servlet.Servlet is in unnamed module of loader java.net.URLClassLoader @520a3426)
这是我的web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>
org.apache.camel.component.servlet.CamelHttpTransportServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SpringApplicationContext</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Camel servlet mapping -->
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/srv/*</url-pattern>
</servlet-mapping>
</web-app>
我使用的是Tomcat 10.0.10和Camel 3.8
任何帮助都是感激不尽的。
1条答案
按热度按时间0yycz8jy1#
使用Tomcat 9解决了该问题