gpt4 book ai didi

maven - 带有 scalatra 错误的 Tomcat - NoSuchMethodError HttpServletRequest.getContentLengthLong

转载 作者:行者123 更新时间:2023-11-28 22:17:06 24 4
gpt4 key购买 nike

当我尝试在 Tomcat 中运行程序时出现以下错误:

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getContentLengthLong()J
org.scalatra.servlet.HttpServletRequestReadOnly.<init>(HttpServletRequestReadOnly.scala:56)
org.scalatra.ScalatraContext$class.scalatraContext(ScalatraContext.scala:71)

我正在使用 Scalatra 和 Tomcat 7,并且我正在尝试使用 (akka actor) 执行 AsyncResult。我正在使用 maven,我的依赖项如下

<!-- https://mvnrepository.com/artifact/org.scalaj/scalaj-http_2.11 -->
<dependency>
<groupId>org.scalaj</groupId>
<artifactId>scalaj-http_2.11</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.5</version>
</dependency>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra_2.11</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra-scalate_2.11</artifactId>
<version>2.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor_2.11 -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.4.16</version>
</dependency>

<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.11</artifactId>
<version>2.0.0-M3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scala-lang/scala-reflect -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>2.11.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scala-lang/scala-compiler -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>2.11.8</version>
</dependency>


<!--Spark dependencies-->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.1.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql_2.11 -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.databricks</groupId>
<artifactId>spark-xml_2.11</artifactId>
<version>0.4.1</version>
</dependency>
<dependency>
<groupId>org.json4s</groupId>
<artifactId>json4s-native_2.11</artifactId>
<version>3.5.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.scalatra/scalatra-swagger_2.11 -->
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra-swagger_2.11</artifactId>
<version>2.5.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.scalatra/scalatra-json_2.11 -->
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra-json_2.11</artifactId>
<version>2.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.databinder.dispatch/dispatch-core_2.11 -->
<dependency>
<groupId>net.databinder.dispatch</groupId>
<artifactId>dispatch-core_2.11</artifactId>
<version>0.11.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.11 -->
<dependency>
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-xml_2.11</artifactId>
<version>1.0.6</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.scalatest/scalatest_2.11 -->
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>

我收到错误的行代码是

new AsyncResult {
val is =
Future {

我尝试了包含依赖、排除依赖、添加依赖……但我无法解决。任何人都知道如何解决它?

最佳答案

检查您的依赖关系树 - 您使用的版本很可能依赖于较旧的 javax.servlet api。 HttpServletRequest.getContentLengthLong() 方法已添加到 Servlet API 3.1 中,如

中所述

http://docs.oracle.com/javaee/7/api/javax/servlet/ServletRequest.html#getContentLengthLong--

关于maven - 带有 scalatra 错误的 Tomcat - NoSuchMethodError HttpServletRequest.getContentLengthLong,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42367193/

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