java org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;) 和连锁反应

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17593610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 02:25:05  来源:igfitidea点击:

org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;) and chain reaction

javaspringmaven

提问by brbtsl

I was trying to make a web application (not coded by me) to run, but, upon deployment, I am getting the following exceptions.

我试图让一个 Web 应用程序(不是我编码的)运行,但是,在部署时,我收到以下异常。

  1. java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V

  1. java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V

I have already checked and validated that there are no version conflicts for the spring-blabla jars in the WEB-INF/libsfolder (I am using spring version 3.2.0.M1) and the dependecies in the pom.xmlfile have the following form.

我已经检查并验证了WEB-INF/libs文件夹中的 spring-blabla jars 没有版本冲突(我使用的是 spring 版本 3.2.0.M1)并且pom.xml文件中的依赖项具有以下内容形式。

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>

I have been quite desperate, so, as a last resort, I checked a chinese site and experimented with the following listener in the *web.xml*file

我一直很绝望,所以,作为最后的手段,我检查了一个中文网站,并在 * web.xml* 文件中尝试了以下侦听器

<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>

under the already existing one:

在已经存在的一个下:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

When I am running the application, I am no longer receiving the previous exception, but another one,

当我运行应用程序时,我不再收到之前的异常,而是另一个异常,

Context initialization failed org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.context.support.XmlWebApplicationContext]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.jndi.JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()Z

上下文初始化失败 org.springframework.beans.BeanInstantiationException:无法实例化 bean 类 [org.springframework.web.context.support.XmlWebApplicationContext]:构造函数抛出异常;嵌套异常是 java.lang.NoSuchMethodError: org.springframework.jndi.JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()Z

and I really have no idea what to do ...

我真的不知道该怎么办......

回答by gerrytan

It's very likely your runtime is reading Spring 2.0 instead of 3.2. Take a look at Spring 2 ConfigurableWebApplicationContext, it doesn't have setId(String)method.

您的运行时很可能正在读取 Spring 2.0 而不是 3.2。看看 Spring 2 ConfigurableWebApplicationContext,它没有setId(String)方法。

I would start debugging the problem by checking the jar/war file, see if any duplicate version of Spring. Also check the web container classpath (eg: tomcat lib folder). If there's a Spring 2 jars in there it could cause confusion

我将通过检查 jar/war 文件开始调试问题,看看是否有任何重复的 Spring 版本。还要检查 Web 容器类路径(例如:tomcat lib 文件夹)。如果那里有 Spring 2 罐子,可能会引起混淆