Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener. ...nested exception is java.lang.NoSuchMethodError:


ssh 中,項目部署到服務器的時候,出現這樣的奇葩的事情:

21-Oct-2017 11:27:15.953 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
21-Oct-2017 11:27:15.991 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
21-Oct-2017 11:27:16.045 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
 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.core.convert.converter.ConverterRegistry.addConverter(Ljava/lang/Class;Ljava/lang/Class;Lorg/springframework/core/convert/converter/Converter;)V
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:339)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:281)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1092)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1834)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoSuchMethodError: org.springframework.core.convert.converter.ConverterRegistry.addConverter(Ljava/lang/Class;Ljava/lang/Class;Lorg/springframework/core/convert/converter/Converter;)V
	at org.springframework.core.convert.support.DefaultConversionService.addScalarConverters(DefaultConversionService.java:62)
	at org.springframework.core.convert.support.DefaultConversionService.addDefaultConverters(DefaultConversionService.java:53)
	at org.springframework.core.convert.support.DefaultConversionService.<init>(DefaultConversionService.java:42)
	at org.springframework.core.env.AbstractPropertyResolver.<init>(AbstractPropertyResolver.java:44)
	at org.springframework.core.env.PropertySourcesPropertyResolver.<init>(PropertySourcesPropertyResolver.java:42)
	at org.springframework.core.env.AbstractEnvironment.<init>(AbstractEnvironment.java:101)
	at org.springframework.core.env.StandardEnvironment.<init>(StandardEnvironment.java:54)
	at org.springframework.web.context.support.StandardServletEnvironment.<init>(StandardServletEnvironment.java:43)
	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.createEnvironment(AbstractRefreshableWebApplicationContext.java:139)
	at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:227)
	at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:217)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:82)
	at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:51)
	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.<init>(AbstractRefreshableWebApplicationContext.java:94)
	at org.springframework.web.context.support.XmlWebApplicationContext.<init>(XmlWebApplicationContext.java:62)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
	... 17 more

21-Oct-2017 11:27:45.646 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext
21-Oct-2017 11:27:45.919 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
21-Oct-2017 11:27:45.919 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()

  

上網查詢,有人說是 環境變量 讀取不一致問題等等。

下面是我處理的過程:

1.若你的項目所連接的是本地的數據庫,請保證你安裝的數據庫 是可以運行本地訪問,既在linux shell 中 可以mysql -uroot -p密碼等進去,若不能,不經授權了遠程登錄還的,還請自行將數據的localhost方式登錄的權限授權

   如出現:#mysql -u root -p 
    提示”Access denied for user ‘root’@’localhost’ (using password: YES)”

   可以:grant all privileges on . to ‘root’@’localhost’ identified by ‘mypassword’ with grant option; 
             grant all privileges on . to ‘root’@’118.192.91.xxx’ identified by ‘mypassword’ with grant option;

             flush privileges; 

    查考:http://www.linuxidc.com/Linux/2015-04/116492.htm

2.確保你的環境 java 版本 和你工作的IDE編譯環境一直, 說白了, 本地IDE編譯 是用java7 , 在部署到 服務器Linux 也是 java 7

 

(ps: 上面的情況是 , 在本地跑程序是沒有問題的, 已部署到linux服務器出現上面粘貼的問題,通過上面兩個步驟,在常試,可以了,不報上面的錯誤了)

 

目前發現就這么多問題,分享與大家,若您也存在這樣的問題,可以留言給我,希望可以幫助您!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM