tomcat部署兩個使用了Druid數據數據庫鏈接池的項目

加班部署兩個基本一致的項目到同一個tomcat7中,出現如下錯誤:java

Error starting ApplicationContext. To display the auto-configuration report enabled debug logging (start with --debug)


2015-05-17 18:09:42,[localhost-startStop-1] ERROR org.springframework.boot.SpringApplication  - Application startup failed
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [{
	CreateTime:"2015-05-17 18:09:38",
	ActiveCount:0,
	PoolingCount:0,
	CreateCount:0,
	DestroyCount:0,
	CloseCount:0,
	ConnectCount:0,
	Connections:[
	]
}

[
]] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: com.alibaba.druid.pool:name=dataSource,type=DruidDataSource
	at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625)
	at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550)
	at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
	at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)
	at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
	at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68)
	at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5456)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1229)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.management.InstanceAlreadyExistsException: com.alibaba.druid.pool:name=dataSource,type=DruidDataSource
	at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
	at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:195)
	at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:670)
	at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:615)
	... 24 more
2015-05-17 18:09:42,[localhost-startStop-1] INFO  org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext  - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@37b73e96: startup date [Sun May 17 18:09:35 CST 2015]; root of context hierarchy
2015-05-17 18:09:42,[localhost-startStop-1] WARN  org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext  - Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@37b73e96: startup date [Sun May 17 18:09:35 CST 2015]; root of context hierarchy
	at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:357)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:877)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:150)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:342)
	at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)
	at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
	at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68)
	at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5456)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1229)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

 

錯誤緣由:druid出現了相同的bean,致使錯誤。查找到資料代表是druid前期的版本出現的bean是全局bean,因此當部署兩個項目時會報錯,注意本次出現錯誤的版本是1.0.16。web

解決:將druid版本升級到1.0.20,完美解決。spring

相關文章
相關標籤/搜索