apache tomcat catalina as maven dependency for CORS filter

南笙酒味 提交于 2019-12-12 08:27:04

问题


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,


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/22634691/apache-tomcat-catalina-as-maven-dependency-for-cors-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!