【问题标题】:Spring Framework upgrade from 5.3.1 to 5.3.14 getting white label errorSpring Framework 从 5.3.1 升级到 5.3.14 出现白标错误
【发布时间】:2022-01-04 01:57:44
【问题描述】:

我在尝试将 Spring 框架库从 5.3.1 升级到 5.3.14 时遇到了一些问题。当我使用 5.3.1 版本时,没有白标错误页面。但是,在我将库升级到 5.3.14 后,我在启动时收到此错误消息:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Jan 04 09:54:57 SGT 2022
There was an unexpected error (type=Internal Server Error, status=500). 

在我的记录器中,我收到以下错误消息:

[1/4/22 11:40:33:606 SGT] 000000cb ServletWrappe E 

com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause dispatcherServlet: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: javax/servlet/http/HttpServletResponse.setContentLengthLong(J)V (loaded from file:/C:/Program Files (x86)/IBM/WebSphere/AppServer/plugins/javax.j2ee.servlet.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@85b881d1) called from class org.springframework.http.server.ServletServerHttpResponse (loaded from file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/backend_war.ear/backend.war/WEB-INF/lib/spring-web-5.3.14.jar by 
com.ibm.ws.classloader.CompoundClassLoader@c5d284c9[appwar:backend_war]

我正在使用 springframework.boot 2.4.0 和 springframework 5.3.14。

我尝试了here 的方法来禁用白标错误,但它仍然显示。任何想法为什么会这样?谢谢!

【问题讨论】:

  • 您使用什么版本的 WebSphere?我认为您的版本与 Spring servlet 版本不兼容。 java.lang.NoSuchMethodError: javax/servlet/http/HttpServletResponse.setContentLengthLong
  • @Saljack 我正在使用 8.5.5.12 可以与您核实是否兼容?如果没有,我该如何解决?

标签: java spring spring-framework-beans


【解决方案1】:

您使用的 WebSphere 8.5.5 版本太旧,其中包含与 Spring 5.x 不兼容的 Servlet 3.0。 Spring 5.x 需要 Servlet 3.1 or 4.0。因此,如果您想使用 Spring 5,则必须按照升级页面中的说明将 WebSphere 升级到 9。

【讨论】:

  • 对不起 Spring 5 和 spring-core-5.3.1 及更高版本?我的应用程序设法使用 spring-core-5.3.1 运行,它仅在我尝试将其升级到 5.3.14 时才会中断
  • No Spirng 5.0 >= 需要 Servlet 3.1 或 4.0。您很幸运,您没有使用 Servlet 3.1 中的任何功能,但代码中可能有一些更改,并且使用了自 Servlet 3.1 以来的setContentLengthLong。我强烈建议您升级您的 WebSphere 或不要将 Spring 5 与 Servlet 3.0 一起使用,因为在运行时可能会发生类似的错误。
猜你喜欢
  • 2013-11-04
  • 2015-06-03
  • 2017-01-06
  • 2019-05-21
  • 2016-11-22
  • 2023-02-08
  • 2015-06-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多