Anish Mittal
Anish Mittal

Reputation: 1182

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z in Wicket Web Hello World Project

I'm writing Wicket Framework Hello World application 1st time using Maven build. In Eclipse I've created Maven project. Build is getting successful. But while running , it is throwing "java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z".

pom.xml

<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.practice.wicket</groupId>
<artifactId>WicketFirst</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>8.5.0</wicket.version>
    <jetty9.version>9.4.18.v20190429</jetty9.version>
    <slf4j.version>1.7.26</slf4j.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 - SLF4J-SIMPLE -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>${slf4j.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-webapp</artifactId>
        <scope>test</scope>
        <version>${jetty9.version}</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-jmx</artifactId>
        <version>${jetty9.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- uncomment if WebSocket support is needed
    <dependency>
        <groupId>org.eclipse.jetty.websocket</groupId>
        <artifactId>javax-websocket-server-impl</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.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
            <configuration>
              <url>http://localhost:8080</url>
            </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.10</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>

web.xml:

<?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://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd"
     version="3.0">

<display-name>WicketFirst</display-name>

<filter>
    <filter-name>wicket.WicketFirst</filter-name>
    <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
    <init-param>
        <param-name>applicationClassName</param-name>
        <param-value>com.practice.wicket.WicketApplication</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>wicket.WicketFirst</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

Project Structure:

WicketFirst
    /src/main/java/
        com.practice.wicket
            WicketApplication.java

I have not put tomcat 7 .jar in libs. I've used plugin for this in pom.xml and ran mvn package and mvn install from command prompt. It has build successfully but when I run it using Maven in Eclipse and try to open http://localhost:8080/WicketFirst , it throws above mentioned error.

Upvotes: 1

Views: 876

Answers (1)

Jeroen Steenbeeke
Jeroen Steenbeeke

Reputation: 4048

Tomcat 7 supports Servlet API 3.0. For Wicket 8 you need to use a container which supports at least Servlet API 3.1, which would be Tomcat 8 or higher.

See also: http://tomcat.apache.org/whichversion.html

Upvotes: 1

Related Questions