在Spring 5中Jetty:run失败并出现NoSuchMethodError

Leos Literak:

我正在尝试将Web应用程序更新为当前库。当我将Spring从3.1.1升级到5.0.0时,它因以下原因而开始失败:

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getStatus()I
    at org.springframework.web.servlet.FrameworkServlet.publishRequestHandledEvent(FrameworkServlet.java:1083)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1009)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)

我发现了两个相关的问题:

解释了很多,我已经升级了码头和servlet规范。但是我的应用程序不断失败。

依存关系:

[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.5:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] +- ch.qos.logback:logback-core:jar:1.1.1:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.1:compile
[INFO] +- org.codehaus.janino:janino:jar:2.6.1:compile
[INFO] |  \- org.codehaus.janino:commons-compiler:jar:2.6.1:compile
[INFO] +- org.springframework:spring-web:jar:5.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:5.0.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-core:jar:5.0.0.RELEASE:compile
[INFO] |     \- org.springframework:spring-jcl:jar:5.0.0.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:5.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.0.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:5.0.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:5.0.0.RELEASE:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] \- junit:junit:jar:4.10:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.1:test

Maven:

    <spring.framework.version>5.0.0.RELEASE</spring.framework.version>
    <maven-jetty-plugin.version>6.1.26</maven-jetty-plugin.version>
    <servlet.api.version>3.1.0</servlet.api.version>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.framework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.framework.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${servlet.api.version}</version>
        <scope>provided</scope>
    </dependency>

<build>
    <finalName>smartpos-backend-device</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <showWarnings>true</showWarnings>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <id>install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>sources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>${maven-jetty-plugin.version}</version>

            <configuration>
                <jettyEnvXml>src/main/resources/jetty/jetty-env.xml</jettyEnvXml>
                <contextPath>smartpos-json</contextPath>
                <scanIntervalSeconds>0</scanIntervalSeconds>

                <connectors>
                    <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                        <port>8080</port>
                    </connector>
                </connectors>
                <systemProperties>
                    <systemProperty>
                        <name>logback.configurationFile</name>
                        <value>logback.xml</value>
                    </systemProperty>
                    <systemProperty>
                        <name>LOG_PATH</name>
                        <value>.</value>
                    </systemProperty>
                </systemProperties>
            </configuration>
        </plugin>
    </plugins>
</build>
然后马库斯:

Spring 5至少需要一个Servlet 3.1容器,但是当您使用Jetty 6.1时(最多)是Servlet 2.5容器。因此,这显然是行不通的。

您将必须升级您的Jetty版本。要升级而不是升级,maven-jetty-plugin您将需要使用适当jetty-maven-plugin的名称(名称已更改),并且它现在是Eclipse的一部分。

<maven-jetty-plugin.version>9.4.7.v20170914</maven-jetty-plugin.version>

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${maven-jetty-plugin.version}</version>
</plugin>

这应该同时使用插件和Jetty的最新版本。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

JHipster Spring启动失败,并出现Logback配置错误

Spring Boot DataJpaTest(用于存储库)失败,并出现java.lang.IllegalStateException:无法加载ApplicationContext

gradle spring boot starter-logging失败并出现Logback错误

用Gradle,Groovy和spring-boot进行springload失败,并出现java.lang.NoSuchFieldException:classCache

WireMock失败,并出现NoSuchMethodError HttpServletResponse.getHeader

在Powermock Spring Boot中出现NoSuchMethodError吗?

在tomcat7上以战争方式部署的Spring Boot应用程序失败,并出现错误“发现了多个名称为[org_apache_tomcat_websocket]的片段”

使用spring-boot和bitronix JTA管理器将XA数据源配置为mysql 8 DB失败,并出现SqlException XAERR_RMERR

“ npm run build”失败,并出现SyntaxError:Unexpected token

Spring Data MongoDB失败,出现“ in”查询

节点启动失败并出现错误:internal.Node.run - Corda 中节点启动 {} 期间出现异常

Spring + Hibernate:JBoss日志记录中的NoSuchMethodError

使用FileSystemXmlApplicationContext编译Spring应用程序时出现NoSuchMethodError

将Spring Boot部署到Weblogic时出现NoSuchMethodError

使用Hibernate JPA启动Spring Boot Application时出现NoSuchMethodError

Spring 3.0 中的 Spring 数据

jersey-spring3(2.25.1)在Jetty-9.3.3中产生“上下文启动失败”错误

在启动中启用CORS失败,并出现预检错误

对dict理解中的locals()下标失败,并出现KeyError

gcloud组件更新在MacOS中失败,并出现UnicodeDecodeError

Git在Visual Studio中失败并出现致命错误

编译失败并出现错误

ElasticsearchIntegrationTest失败,并出现NullPointerException

Spring Boot无法正常工作并出现一些错误?

Spring Boot + Thymeleaf CSS文件无法访问并出现500错误,找不到模板

Spring 4 @AutoWired失败

Spring框架导入失败

Spring Build ContextLoads失败

Spring Boot登录失败