当我尝试在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 {
我尝试包含依赖项,排除依赖项,添加依赖项......但我无法解决它。任何人都知道如何解决它?
答案 0 :(得分:1)
检查你的依赖树 - 很可能你正在使用的版本依赖于旧的javax.servlet api。在Servlet API 3.1中添加了HttpServletRequest.getContentLengthLong()方法,如
中所述。http://docs.oracle.com/javaee/7/api/javax/servlet/ServletRequest.html#getContentLengthLong--
答案 1 :(得分:0)
最后我使用Tomcat 8解决了这个问题,因为包含在tomcat 7中的javax-servlet对我不起作用。