gpt4 book ai didi

java - Grails 项目 - Servlet 调用 - ClassNotFoundException : javax. servlet.AsyncContext

转载 作者:搜寻专家 更新时间:2023-11-01 03:05:58 32 4
gpt4 key购买 nike

我正在使用

  • intellij idea 终极版 12..4
  • Grails 2.2.0 ,
  • buildConfig.groovy 文件中的 grails.servlet.version = "2.5"

并实现了简单的 servlet 发布请求。使用 RESTClient 发布请求我发现了这些场景

场景:

  • 当我在本地使用时它工作正常。网址:localhost:9090/testProject/api/testReport

  • 但是当我在本地服务器中部署它时,会显示以下错误消息 URL:192.168.1.10:9090/testProject/api/testReport

本地服务器配置与 localhost 一样....

code:   
ERROR errors.GrailsExceptionResolver - ClassNotFoundException occurred when processing request: [POST] /testProject/api/testReport
javax.servlet.AsyncContext. Stacktrace follows:
java.lang.ClassNotFoundException: javax.servlet.AsyncContext
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.grails.jaxrs.support.ConverterUtils.jsonToMap(ConverterUtils.groovy:94)
at org.grails.jaxrs.support.DomainObjectReaderSupport.readFromJson(DomainObjectReaderSupport.groovy:124)
at org.grails.jaxrs.support.DomainObjectReaderSupport.readFrom(DomainObjectReaderSupport.groovy:93)
at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:474)
at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:123)
at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:46)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:183)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
at org.grails.jaxrs.web.JaxrsContext$JaxrsServiceImpl.process(JaxrsContext.java:192)
at org.grails.jaxrs.JaxrsController$_closure1.doCall(JaxrsController.groovy:48)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at org.grails.jaxrs.web.JaxrsFilter.doFilterInternal(JaxrsFilter.java:46)
at java.lang.Thread.run(Thread.java:722)

最佳答案

经过几天的搜索和整合,我找到了解决方案......

  1. 为什么这里出现ClassNotFoundException异常最频繁这篇文章真不错...

    http://javarevisited.blogspot.com/2011/08/classnotfoundexception-in-java-example.html

  2. 问题的主要原因是日志java.lang.ClassNotFoundException: javax.servlet.AsyncContext

    这意味着它没有找到 javax.servlet-3.0 提供的 asyncContext 类。在 servlet 2.5 中它丢失了。

我在跑Apache Tomcat 7在本地主机中,但在本地服务器 192.168.1.10 中,我正在运行 Apache Tomcat 6 .在给定的链接中,apache 文档说明了 servlet 版本。

 So the solution is either anyone upgrade the Apache Tomcat 6 to Apache Tomcat 7
or posting the file javax.servlet-3.0 in Apache Tomcat 6 lib folder.
[Here][3] is the jar file.

关于java - Grails 项目 - Servlet 调用 - ClassNotFoundException : javax. servlet.AsyncContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22296126/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com