简体   繁体   中英

java.lang.NoSuchFieldError: ASYNC

The page can't be visited and showed following error message:

java.lang.NoSuchFieldError: ASYNC
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:505)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)

This is part of the error message in the page.

As my experience, this error is caused by the wrong reference using JSTL. Say I set a User in Controller . If I want to show the user name, I use <c:out value="${user.name}"/> . But if I use <c:out value="${user.namee}"/> , this error will occur.

So I wonder if I have lots of objects set in Controller , and have the message of these objects shown on page. How can I locate which one causes the error?

In the standard Java EE API, ASYNC is recognizable as a field of DispatcherType enum .

This enum was introduced in Servlet 3.0. This problem thus suggests that webapp's runtime classpath is polluted with mixed Servlet API versions. Eg Servlet 2.5 and Servlet 3.0 mixed. The implementation was loaded for Servlet 3.0 or newer (likely Jetty itself), but the API was loaded for Servlet 2.5 or older (likely via webapp).

The most common cause for this is that the WAR file mistakenly contains an Servlet API JAR file or even a Java EE JAR file in /WEB-INF/lib . You should make sure that the WAR's /WEB-INF/lib does not contain any libraries which are already provided by the target runtime itself (in your case, Jetty). This is regardless of the version used. Even if you align out the versions, you are just not supposed to provide server-specific libraries along with the webapp.

When you're using Maven, mark server-provided libraries as <scope>provided</scope> in webapp's pom.xml . When you're manually carrying around JARs, simply physically remove server-provided libraries from /WEB-INF/lib folder.

Do note that this has nothing to do with JSTL.

See also:

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