I'm using org.apache.catalina.filters.CorsFilter in my webapp. So I specify the maven dependency
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.50</version>
</dependency>
Now, If I say the scope is "provide" or "runtime" the server doesn't start, because of
java.lang.ClassNotFoundException: org.apache.catalina.filters.CorsFilter
This class is not available in the catalina jar from jbossews/lib which is 7.0.40
Is it easy to "upgrade" tomcat on openshift? or if anybody can suggest a solution, it is much appreciated.
Many thanks,
Tomcat is actually composed of a number of components, including a Tomcat JSP engine and a variety of different connectors, but its core component is called Catalina. Catalina provides Tomcat's actual implementation of the servlet specification; when you start up your Tomcat server, you're actually starting Catalina.
CORS Filter Introduction. This filter is an implementation of W3C's CORS (Cross-Origin Resource Sharing) specification, which is a mechanism that enables cross-origin requests. The filter works by adding required Access-Control-* headers to HttpServletResponse object.
This worked for me:
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.42</version>
<scope>provided</scope>
</dependency>
Trying 7.0.50 also worked. Can you double-check that there are no competing jar file versions lying around? Perhaps there is an older version without the class actually getting used by the JVM. Under Linux, "ls -l /proc/$CATALINA_PID/fd", may show which jar file is being used.
Also make sure to run this in a recent enough version of the Tomcat server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With