2015-10-06 115 views
1

Wicket和Java Web开发的新手段。我从Wicket网站上获得了一个快速启动项目,并且试图在本地Tomcat服务器上运行它。主页目前给我一个错误:“javax.servlet.ServletException:过滤器执行引发异常”。Tomcat上的Wicket快速入门:Servlet NoSuchMethodError

这里的堆栈跟踪:

Oct 05, 2015 10:40:18 PM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet default threw exception 
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z 
at org.apache.wicket.protocol.http.servlet.ServletWebResponse.flush(ServletWebResponse.java:319) 
at org.apache.wicket.protocol.http.HeaderBufferingWebResponse.flush(HeaderBufferingWebResponse.java:99) 
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:263) 
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203) 
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) 
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) 
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) 
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
at java.lang.Thread.run(Thread.java:745) 

我已经添加了tomcat的8库及其servlet的api.jar文件到我的类路径。在pom.xml或web.xml中似乎没有关于servlet的任何信息。我读过它可能是一个servlet-api版本问题,但mvn安装似乎正在安装正确的版本(3.1.0)。以下是pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE file distributed with 
this work for additional information regarding copyright ownership. 
The ASF licenses this file to You under the Apache License, Version 2.0 
(the "License"); you may not use this file except in compliance with 
the License. You may obtain a copy of the License at 

    http://www.apache.org/licenses/LICENSE-2.0 
Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. 
--> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 

<modelVersion>4.0.0</modelVersion> 
<groupId>com.drat.proteus</groupId> 
<artifactId>proteus</artifactId> 
<packaging>war</packaging> 
<version>1.0-SNAPSHOT</version> 
    <!-- TODO project name --> 
<name>quickstart</name> 
<description></description> 
<!-- 
    <organization> 
     <name>company name</name> 
     <url>company url</url> 
    </organization> 
--> 
<licenses> 
    <license> 
     <name>The Apache Software License, Version 2.0</name> 
     <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> 
     <distribution>repo</distribution> 
    </license> 
</licenses> 
<properties> 
    <wicket.version>7.0.0</wicket.version> 
    <jetty9.version>9.2.11.v20150529</jetty9.version> 
    <log4j.version>2.3</log4j.version> 
    <junit.version>4.12</junit.version> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <!-- allowed values: R7, 1.0, 1.5, 2.0 or none --> 
    <wtp.version>none</wtp.version> 
</properties> 
<dependencies> 
    <!-- WICKET DEPENDENCIES --> 
    <dependency> 
     <groupId>org.apache.wicket</groupId> 
     <artifactId>wicket-core</artifactId> 
     <version>${wicket.version}</version> 
    </dependency> 
    <!-- OPTIONAL DEPENDENCY 
    <dependency> 
     <groupId>org.apache.wicket</groupId> 
     <artifactId>wicket-extensions</artifactId> 
     <version>${wicket.version}</version> 
    </dependency> 
    --> 

    <!-- LOGGING DEPENDENCIES - LOG4J --> 
    <dependency> 
     <groupId>org.apache.logging.log4j</groupId> 
     <artifactId>log4j-slf4j-impl</artifactId> 
     <version>${log4j.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.logging.log4j</groupId> 
     <artifactId>log4j-core</artifactId> 
     <version>${log4j.version}</version> 
    </dependency> 

    <!-- JUNIT DEPENDENCY FOR TESTING --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>${junit.version}</version> 
     <scope>test</scope> 
    </dependency> 

    <!-- JETTY DEPENDENCIES FOR TESTING --> 
    <dependency> 
     <groupId>org.eclipse.jetty</groupId> 
     <artifactId>jetty-server</artifactId> 
     <version>${jetty9.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.eclipse.jetty</groupId> 
     <artifactId>jetty-webapp</artifactId> 
     <version>${jetty9.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.eclipse.jetty</groupId> 
     <artifactId>jetty-util</artifactId> 
     <version>${jetty9.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.eclipse.jetty</groupId> 
     <artifactId>jetty-jmx</artifactId> 
     <version>${jetty9.version}</version> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 
<build> 
    <resources> 
     <resource> 
      <filtering>false</filtering> 
      <directory>src/main/resources</directory> 
     </resource> 
     <resource> 
      <filtering>false</filtering> 
      <directory>src/main/java</directory> 
      <includes> 
       <include>**</include> 
      </includes> 
      <excludes> 
       <exclude>**/*.java</exclude> 
      </excludes> 
     </resource> 
    </resources> 
    <testResources> 
     <testResource> 
      <filtering>false</filtering> 
      <directory>src/test/resources</directory> 
     </testResource> 
     <testResource> 
      <filtering>false</filtering> 
      <directory>src/test/java</directory> 
      <includes> 
       <include>**</include> 
      </includes> 
      <excludes> 
       <exclude>**/*.java</exclude> 
      </excludes> 
     </testResource> 
    </testResources> 
    <plugins> 
     <plugin> 
      <inherited>true</inherited> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
       <encoding>UTF-8</encoding> 
       <showWarnings>true</showWarnings> 
       <showDeprecation>true</showDeprecation> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-maven-plugin</artifactId> 
      <version>${jetty9.version}</version> 
      <configuration> 
       <systemProperties> 
        <systemProperty> 
         <name>maven.project.build.directory.test-classes</name> 
         <value>${project.build.directory}/test-classes</value> 
        </systemProperty> 
       </systemProperties> 
       <jettyXml>${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml</jettyXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-eclipse-plugin</artifactId> 
      <version>2.9</version> 
      <configuration> 
       <downloadSources>true</downloadSources> 
       <wtpversion>${wtp.version}</wtpversion> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

<repositories> 
    <repository> 
     <id>Apache Nexus</id> 
     <url>https://repository.apache.org/content/repositories/snapshots/</url> 
     <releases> 
      <enabled>false</enabled> 
     </releases> 
     <snapshots> 
      <enabled>true</enabled> 
     </snapshots> 
    </repository> 
</repositories> 
</project> 

谢谢!

+0

自从servlet-api 3.0开始存在isAsyncStarted方法,请参阅https://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#isAsyncStarted%28%29您使用哪个servlet API? –

+0

@MartinStrejc当我进行mvn安装时,servlet-api的所有实例都是3.1.0,但正如我所说的,在pom.xml中没有提到一个servlet,所以我不确定它是从哪里来的。我已将pom文件添加到我的帖子中。 – user3622688

+0

POM中的Maven依赖项具有“提供”范围。这意味着它可以从代码访问,它与该库一起编译,但它不是最终战争的一部分。原因是JAR库有望成为共享目录(例如libs)中的服务器(例如Tomcat)的一部分。见https://github.com/apache/wicket/blob/master/pom.xml –

回答

1

更改版本在web.xml到3.0,现在它仍然是2.5

来自:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
     version="2.5"> 
... 
</web-app> 

到:

<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
     version="3.0"> 
... 
</web-app> 

或:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
    http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
    version="3.1"> 
... 
</web-app> 

也许这有助于。

+0

谢谢!我已经修复了Wicket的快速入门Maven原型。 –

+0

这是否并没有解决servlet问题。虽然做得非常好。 – user3622688