I have a Camel application that uses a servlet to expose a REST API. I'm using SpringBoot alongside Camel. After building the WAR, I can run it using java -jar, and it works fine. Now, when I deploy the same WAR into tomcat/webapps I get the following error in the logs:
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)
This is my 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>
I'm using Tomcat 10.0.10 and Camel 3.8
Any help is appreciated.