apache tomcat catalina as maven dependency for CORS filter
Asked Answered
D

2

11

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,

Disclaim answered 25/3, 2014 at 12:30 Comment(1)
I've started using CORS filter from com.thetransactioncompany and serves my purpose. But I'd still like to know a solution for the above.Disclaim
P
8

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.

Puree answered 21/4, 2014 at 1:43 Comment(1)
I came here using Tomcat 7.0.37 in a normal webapp, however the above snipped initally did not work for me. The problem is that you need at least Tomcat 7.0.41 for the CORS filter to be available as you can see in the changelog for 7.0.41 at tomcat.apache.org/oldnews-2013.htmlSnappish
T
0

You can add the jar to your repository and modify the .openshift/config/catalina.properties to let tomcat see it:

shared.loader=${catalina.home}/../app-root/runtime/repo/_your_jar_folder_

You can also use the common.loader - look up tomcat's refs for difference.

Trichromatism answered 3/12, 2014 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.