简体   繁体   中英

WebFilter Java8 and Maven

I am playing with a tutorial and have the following:

*maven project

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>8.0</version>
    <scope>provided</scope>
</dependency>

*Docker Wildfly 10

FROM jboss/wildfly:10.1.0.Final

*Java Code

@WebFilter(urlPatterns = "/*")
public class TokenFilter extends HttpFilter {...}

*And of course the error :)

Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpFilter from [Module "deployment.api.war:main" from Service Module Loader]

Maven marks Java 8 as provided, wildfly should have it. I am pretty sure I am missing a dependency in maven, but not sure which one. The other bits of this software are working just fine (REST bits)

Any hints?

I think the problem is, your wildfly version is older than the java-ee version you specified as provided. (java-ee 8 is released 1 year later than your wildfly version. And HttpFilter class is available since this version)

If you remove the provided it should work(unless some dependency inconsistencies happens. If that the case you have to upgrade wildfly version)

https://www.oracle.com/corporate/pressrelease/java-se-9-and-ee-8-092117.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM