Spring和Tomcat 9使用name创建bean时出错

时间:2017-07-12 16:30:28

标签: java hibernate spring-boot

我有一个用eclipse创建的gradle项目:


    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'war'
    archivesBaseName = 'ps'
    version = '1' 
    repositories {
        maven {
            url 'https://repo.spring.io/release'
        }
        mavenCentral()
    }
    dependencies {
        compile 'org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE'
        compile 'org.springframework.boot:spring-boot-starter-data-jpa:1.3.3.RELEASE'
        compile 'org.hibernate:hibernate-core:4.3.6.Final'
        compile 'mysql:mysql-connector-java:5.1.31'
        compile 'commons-dbcp:commons-dbcp:1.4'
        compile 'jstl:jstl:1.2'
        compile 'org.springframework.boot:spring-boot-starter-security:1.3.3.RELEASE'
        compile 'org.springframework.data:spring-data-rest-webmvc:2.6.4.RELEASE'
        compile group: 'org.json', name: 'json', version: '20170516'
        compile 'commons-fileupload:commons-fileupload:1.3.3'
        compile 'commons-io:commons-io:2.5'
        compile group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
        //compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.9.0.pr4'

        providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat:1.3.3.RELEASE'
        //compile("org.slf4j:slf4j-api:1.6.6")
        //compile("ch.qos.logback:logback-classic:1.0.13")
        //compile("org.aspectj:aspectjweaver:1.8.8")    
    }


我已经在本地机器上安装了Tomcat 9 M21并为它配置了eclipse,当我从eclipse运行我的项目时,它工作得很完美。

相反,当我启动远程服务器时,我发现了这个错误:


    18:02:03.213 [http-nio-80-exec-1] DEBUG o.h.internal.SessionFactoryRegistry - Initializing SessionFactoryRegistry : org.hibernate.internal.SessionFactoryRegistry@6e78f0fa
    18:02:03.213 [http-nio-80-exec-1] DEBUG o.h.internal.SessionFactoryRegistry - Registering SessionFactory: 7d3e4836-433c-428d-8972-13161a699d69 ()
    18:02:03.213 [http-nio-80-exec-1] DEBUG o.h.internal.SessionFactoryRegistry - Not binding SessionFactory to JNDI, no JNDI name configured
    18:02:03.213 [http-nio-80-exec-1] DEBUG o.h.internal.SessionFactoryImpl - Instantiated session factory
    18:02:03.218 [http-nio-80-exec-1] DEBUG o.h.internal.NamedQueryRepository - Checking 0 named HQL queries
    18:02:03.219 [http-nio-80-exec-1] DEBUG o.h.internal.NamedQueryRepository - Checking 0 named SQL queries
    18:02:03.225 [http-nio-80-exec-1] DEBUG o.h.s.internal.StatisticsInitiator - Statistics initialized [enabled=false]
    18:02:03.234 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'sessionFactory' to allow for resolving potential circular references
    18:02:03.245 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    18:02:03.245 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    18:02:03.381 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'sessionFactory'
    18:02:03.381 [http-nio-80-exec-1] DEBUG o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - Autowiring by type from bean name 'colloquiHibernateDao' to bean named 'sessionFactory'
    18:02:03.381 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    18:02:03.381 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    18:02:03.384 [http-nio-80-exec-1] WARN  o.s.w.c.s.AnnotationConfigWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'colloquiHibernateDao' defined in file [/opt/tomcat8/webapps/ps-1/WEB-INF/classes/it/ps/dao/impl/ColloquiHibernateDao.class]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getQualifiedMethodName(Ljava/lang/reflect/Method;Ljava/lang/Class;)Ljava/lang/String;
    18:02:03.385 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@729028a4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,appConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,colloquiHibernateDao,clientiHibernateDao,tipologiaContrattoHibernateDao,commercialiHibernateDao,regioneHibernateDao,comuneHibernateDao,istruzioniHibernateDao,provinciaHibernateDao,cwHibernateDao,certificazioniHibernateDao,clientiListHibernateDao,secSecurityConfig,DBConfig,customizedRestMvcConfiguration,secureAspect,binderInizializer,genericEditorRegistrar,clientiService,customLogoutSuccessHandler,myLogoutSuccessHandlerTwo,myLogoutSuccessHandlerOne,pingController,tipologiaContrattoController,istruzioniController,commercialiController,clientiController,certificazioniController,comuneController,cwController,colloquiController,org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration,authenticationManagerBuilder,enableGlobalAuthenticationAutowiredConfigurer,org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration,delegatingApplicationListener,webSecurityExpressionHandler,springSecurityFilterChain,privilegeEvaluator,autowiredWebSecurityConfigurersIgnoreParents,org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration,objectPostProcessor,org.springframework.security.config.annotation.web.configuration.WebMvcSecurityConfiguration,requestDataValueProcessor,passwordEncoder,org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration,org.springframework.transaction.config.internalTransactionAdvisor,transactionAttributeSource,transactionInterceptor,org.springframework.transaction.config.internalTransactionalEventListenerFactory,hibernateTemplate,sessionFactory,getDataSource,hibTransMan,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration,handlerExceptionResolver,requestMappingHandlerMapping,mvcPathMatcher,mvcUrlPathHelper,mvcContentNegotiationManager,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,mvcResourceUrlProvider,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcConversionService,mvcValidator,mvcUriComponentsContributor,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,mvcViewResolver,viewResolver,multipartResolver]; root of factory hierarchy
    18:02:03.392 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy method 'close' on bean with name 'sessionFactory'
    18:02:03.392 [http-nio-80-exec-1] DEBUG o.h.internal.SessionFactoryImpl - HHH000031: Closing
    18:02:03.393 [http-nio-80-exec-1] DEBUG o.h.b.r.i.BootstrapServiceRegistryImpl - Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
    18:02:03.393 [http-nio-80-exec-1] DEBUG o.h.s.i.AbstractServiceRegistryImpl - Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
    18:02:03.393 [http-nio-80-exec-1] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy method 'close' on bean with name 'getDataSource'
    18:02:03.400 [http-nio-80-exec-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'colloquiHibernateDao' defined in file [/opt/tomcat8/webapps/ps-1/WEB-INF/classes/it/ps/dao/impl/ColloquiHibernateDao.class]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getQualifiedMethodName(Ljava/lang/reflect/Method;Ljava/lang/Class;)Ljava/lang/String;
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4743)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:507)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1654)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
        at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1483)
        at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:279)
        at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:200)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:595)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getQualifiedMethodName(Ljava/lang/reflect/Method;Ljava/lang/Class;)Ljava/lang/String;
        at org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource.getTransactionAttribute(AbstractFallbackTransactionAttributeSource.java:111)
        at org.springframework.transaction.interceptor.TransactionAttributeSourcePointcut.matches(TransactionAttributeSourcePointcut.java:41)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:242)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:279)
        at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:311)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:119)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:89)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:70)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:346)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:298)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        ... 60 common frames omitted
    12-Jul-2017 18:02:03.403 SEVERE [http-nio-80-exec-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
    12-Jul-2017 18:02:03.405 SEVERE [http-nio-80-exec-1] org.apache.catalina.core.StandardContext.startInternal Context [/ps-1] startup failed due to previous errors
    12-Jul-2017 18:02:03.457 WARNING [http-nio-80-exec-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ps-1] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
    12-Jul-2017 18:02:03.462 WARNING [http-nio-80-exec-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ps-1] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
     java.lang.Object.wait(Native Method)
     java.lang.ref.ReferenceQueue.remove(Unknown Source)
     com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:41)
    12-Jul-2017 18:02:03.498 INFO [http-nio-80-exec-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archi

ve [/opt/tomcat8/webapps/ps-1.war] has finished in [12,109] ms

为什么会这样? 在本地我有Windows和Maria DB,而在远程服务器上我有Centos6和Mysql 5.1.73

1 个答案:

答案 0 :(得分:0)

在远程服务器上,问题从此处开始:


    10:15:33.061 [http-nio-80-exec-5] DEBUG o.h.internal.SessionFactoryImpl - Instantiated session factory
    10:15:33.067 [http-nio-80-exec-5] DEBUG o.h.internal.NamedQueryRepository - Checking 0 named HQL queries
    10:15:33.067 [http-nio-80-exec-5] DEBUG o.h.internal.NamedQueryRepository - Checking 0 named SQL queries
    10:15:33.076 [http-nio-80-exec-5] DEBUG o.h.s.internal.StatisticsInitiator - Statistics initialized [enabled=false]
    10:15:33.092 [http-nio-80-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'sessionFactory' to allow for resolving potential circular references
    10:15:33.097 [http-nio-80-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    10:15:33.097 [http-nio-80-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    10:15:33.295 [http-nio-80-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'sessionFactory'
    10:15:33.296 [http-nio-80-exec-5] DEBUG o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - Autowiring by type from bean name 'colloquiHibernateDao' to bean named 'sessionFactory'
    10:15:33.296 [http-nio-80-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    10:15:33.296 [http-nio-80-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
    10:15:33.300 [http-nio-80-exec-5] WARN  o.s.w.c.s.AnnotationConfigWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'colloquiHibernateDao' defined in file [/opt/tomcat8/webapps/ps-1/WEB-INF/classes/it/ps/dao/impl/ColloquiHibernateDao.class]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getQualifiedMethodName(Ljava/lang/reflect/Method;Ljava/lang/Class;)Ljava/lang/String;

在同一点的本地机器上,我有这个:


    09:58:59.467 [main] DEBUG o.h.internal.SessionFactoryImpl - Instantiated session factory
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing hbm.xml files
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Process annotated classes
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing fk mappings (*ToOne and JoinedSubclass)
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing extends queue
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing extends queue
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing collection mappings
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing native query and ResultSetMapping mappings
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing association property references
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Creating tables' unique integer identifiers
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Processing foreign key constraints
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Resolving reference to class: it.ps.entity.Comune
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Resolving reference to class: it.ps.entity.TipologiaContratto
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Resolving reference to class: it.ps.entity.Clienti
    09:58:59.482 [main] DEBUG org.hibernate.cfg.Configuration - Resolving reference to class: it.ps.entity.Provincia
    ...