10

I have RESTful web service deployed on tomcat' the web service is working fine in the client/server on same domain scenario' but I am required to make the Web Service available from cross domain' for this purpose I have used CORS filter.

I have included filter's jars in both myProjects/lib and tomcat/lib' and also have included following in my web.xml file of web service project'

<filter>
    <filter-name>CORS</filter-name>
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
</filter>

<init-param>
    <param-name>cors.supportedHeaders</param-name>
    <param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modified</param-value>
</init-param>

<filter-mapping>
    <filter-name>CORS</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

But when I try to start the web service I get following error regarding CORS filter:

SEVERE: Exception starting filter CORS
java.lang.NoClassDefFoundError: com/thetransactioncompany/util/PropertyParseException
at com.thetransactioncompany.cors.CORSFilter.init(CORSFilter.java:100)

kindly guide me to figure out what is wrong with this situation'

4

5 回答 5

16

您还需要将 java-properties-utils-1.7.1.jar 文件添加到类路径中,因为 cors 过滤器依赖于它。

http://search.maven.org/#browse%7C-411787350

于 2013-05-07T15:17:02.710 回答
2

就我而言,在 tomcat lib 文件夹中添加这两个 jar 文件解决了这个问题:

  • cors-filter-2.5.jar
  • java-property-utils-1.10.jar
于 2016-12-07T03:31:20.903 回答
0

可能是版本问题。我有同样的问题,事实证明这个过滤器至少需要 Tomcat 版本 7.0.41 才能工作,根据:http ://enable-cors.org/server_tomcat.html

作为参考,Debian 7.8 附带不支持原生 CORS 的 Tomcat 7.0.28。

于 2015-08-06T09:17:15.817 回答
0

我有同样的问题。就我而言,问题是 maven 依赖项已从Deployment Assemblyproject 的部分中删除properties。希望它可以帮助某人。

于 2016-08-02T09:46:12.353 回答
0

我有同样的问题,但在 ma 的情况下,首先,我的服务器状态是未绑定的,所以我通过“构建路径”更改它但仍然没有工作.. 我的朋友检查了一下,他发现了 Eclipse 的“自动构建”功能。然后效果很好!

于 2019-02-08T02:21:36.740 回答