有谁知道可能导致以下ClassCastException: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request
当我尝试doGet(HttpServletRequest req, ..)
HttpServlet
内Request baseRequest = (Request) req;
会发生这种情况
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<jettyXml>src/main/webapp/WEB-INF/jetty.xml</jettyXml>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8081</port>
</connector>
</connectors>
<stopPort>18080</stopPort>
<stopKey>STOP</stopKey>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>
</dependencies>
</plugin>
答案 0 :(得分:2)
您需要确保将jetty-server打包为实际应用程序的一部分;这通常是通过将范围设置为提供来完成的:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>