Could not obtain transaction-synchronized Session

excel数据导入数据库的小逻辑,断点调试发现走了dao层的save方法,但是并没有sql语句输出,而且数据库也没有数据。用spring-test测试dao层的save方法报错org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
at org.springframework.orm.hibernate5.SpringSessionContext.currentSession(SpringSessionContext.java:132)
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:692)
at com.balaiduo.tcm.dao.impl.HibernateDao.getCurrentSession(HibernateDao.java:13)
at com.balaiduo.tcm.test.DaoTest.addEmploy(DaoTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

3个回答

记录一下解决方法,我在配置文件中加入了thread之后把dao层改为
Session session = getCurrentSession();
Transaction tx = session.beginTransaction();
try{
session.save(employ);
tx.commit();
}catch(Exception ex){
tx.rollback();
}
之后就可以了,但是还是不知道原因是啥,我配置了事务管理器的,为什么还要在dao层这样操作才行,等大神指导解答

derrickie
derrickie 配置文件中加入了<prop key="hibernate.current_session_context_class">thread</prop>
3 年多之前 回复
derrickie
derrickie 虽然我不是用这些方法解决的,但是还是谢谢
3 年多之前 回复

在Dao实现类上添加一个注解@Transactional

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
springboot hibernate整合问题

在一个service方法中调用sessionFactory.getCurrentSession()的时候报如下异常Could not obtain transaction-synchronized Session for current thread 网上查询报错原因是说必须加@Transactional(readOnly = true),按说明加确实是可以解决。但是这个service方法仅仅是一个查询,不想用事务方式,能否在不写@Transactional(readOnly = true)情况下正常获取session,并进行查询。不想为每个查询service都加@Transactional(readOnly = true), 也不想用openSession方式。 非常感谢,如解决追加分数

请问,这个问题在java中的常见犯错点在哪里呢,新人求解答

HTTP Status 500 - Request processing failed; nested exception is org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread

关于hibernate的session何时获取的问题

http://zhidao.baidu.com/link?url=wttsNVBIGk7vmHOVydePyPWPPRuKKuy6b7coinmVGlyL6p4CZObGxJWplj8tqgMe-QN6MrVB6G0AnDx5tRhH-q 这个地方说的是否正确呢??实际项目开发中是怎么样的??

Hibernate4测试报错,无法创建表

在用Hibernate4创建一张表,测试报错 报错代码:sessionFactory = configuration.buildSessionFactory(serviceRegistry); ![图片说明](https://img-ask.csdn.net/upload/201508/15/1439628426_38980.png) 以下是测试类 ``` public class HibernateTest extends TestCase { private SessionFactory sessionFactory; private Session session; private Transaction transaction; @Override protected void setUp() throws Exception { // TODO Auto-generated method stub Configuration configuration = new Configuration().configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()) .buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); session = sessionFactory.openSession(); transaction = session.beginTransaction(); } @Override protected void tearDown() throws Exception { // TODO Auto-generated method stub transaction.commit(); session.close(); sessionFactory.close(); } public void testHib(){ } } ```

spring4+hibernate4 在getCurrentSession时候出现异常

错误是:Could not obtain transaction-synchronized Session for current thread spring4+hibernate 事务管理的时候遇到一个问题,如题,openSession是可以的,但是sessionFactory.getCurrentSession()时候就出现上面的问题 而且郁闷的是junit4测试的时候也是可以getCurrentSession的,一步步运行进去可以看到是SpringSessionContent这个类中的currentSession方法报错的,抛出异常是因为 TransactionSynchronizationManager.isSynchronizationActive()为false 求大神指点迷津...

eclipse连接hadoop报错Could not obtain block

1.hadoop2.7.7版本 2报错截图![图片说明](https://img-ask.csdn.net/upload/201901/23/1548209349_373821.png) 3.没有出现挂datanode的问题[图片] ![图片说明](https://img-ask.csdn.net/upload/201901/23/1548209377_858284.png) 4.可以从web端正常访问和下载

tomcat启动后包错,HHH000342: Could not obtain connection to query metadata

2019-03-26 17:27:09,539 [localhost-startStop-1] WARN [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] - HHH000342: Could not obtain connection to query metadata : Failed to grow the connection pool 2019-03-26 17:27:09,540 [localhost-startStop-1] INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@63be73ae: defining beans [logAspect,logSpELParseImpl,logDaoImpl,baseCommonRedisDao,baseRedisDao,redisTemplateUtil,restController,baseService,i18NService,sysLogTplService,baseSmsService,appCtxUtils,invokeRest,commonDataController,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.aop.config.internalAutoProxyCreator,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,desktopResourceDaoImpl,userDesktopDaoImpl,reqLogRedisDao,userDesktopService,reqLogService,commonRedisDao,sysCommonDaoImpl,checkDataDaoImpl,argumentsConfigurateDaoImpl,argumentsConfigurateRedisDao,ftpProcessLogDaoImpl,ftpServerDaoImpl,ftpUtilDaoImpl,sysLogAnalyzeDaoImpl,sysLogAuditDaoImpl,sysLogDaoImpl,sysLogStatisticsDaoImpl,sysRegionLogDaoImpl,sysUserOnlineLogDaoImpl,sysMonitorNDaoImpl,sysMonitorNIndicatorDaoImpl,sysMonitorNMappingDaoImpl,sysMonitorNServerDaoImpl,notificationDaoImpl,notificationLogDaoImpl,notificationRedisDao,portalDaoImpl,portalOperationDaoImpl,portletConfDaoImpl,projectInfoConfigDaoImpl,redisKeyValuesDao,monitorAlarmDaoImpl,monitorIndicatorDaoImpl,monitorInstantAlarmDaoImpl,monitorLogCacheDaoImpl,monitorLogCpuDaoImpl,monitorLogDatabaseDaoImpl,monitorLogDiskDaoImpl,monitorLogIoDaoImpl,monitorLogLoadaverageDaoImpl,monitorLogMemDaoImpl,monitorLogMqDaoImpl,monitorLogNetDaoImpl,monitorLogProcDaoImpl,monitorMappingDaoImpl,monitorResourceConfDaoImpl,monitorServerDaoImpl,sysCommonService,checkDataService,argumentsConfigurateService,ftpProcessLogServiceImpl,ftpServerServiceImpl,ftpUtilService,ftpUtilServiceProxy,sysLogAnalyzeService,sysLogsAuditService,sysLogService,sysLogStatisticsService,sysRegionLogService,sysUserOnlineLogService,sysMonitorNIndicatorService,sysMonitorNMappingService,sysMonitorNServerService,sysMonitorNService,notificationLogService,notificationRedisService,notificationService,portalOperationService,portalService,portletConfService,projectInfoConfigService,redisKeyValuesService,monitorAlarmService,monitorIndicatorService,monitorLogCacheService,monitorLogCpuService,monitorLogDatabaseService,monitorLogDiskService,monitorLogIoService,monitorLogLoadaverageService,monitorLogMemService,monitorLogMqService,monitorLogNetService,monitorLogProcService,monitorMappingService,monitorServerService,esdpBaseDao,clusterMngDaoImpl,esdpModNodeOperationsImpl,esdpModNodeStatusImpl,esdpJobContainerMngDaoImpl,esdpTaskMngDaoImpl,taskFilterPoolDapImpl,taskFilterSelectedDaoImpl,taskParamDaoImpl,esdpFtpInfoDaoImpl,esdpJobDaoImpl,esdpJobGroupDaoImpl,esdpJobParamDaoImpl,esdpJobSchDaoImpl,esdpJobSchRedoDaoImpl,jobAttributeDaoIpml,jobServiceDaoImpl,jobServiceGroupDaoImpl,jobServiceVarDaoIpml,esdpBaseService,clusterMngService,esdpJobContainerService,esdpTaskMngService,taskFilterPoolService,taskFilterSelectedService,taskParamService,jobService,jobServiceService,departmentDaoImpl,deptRedisDao,menuVisitedRedisDao,onlineUserRedisDao,resourceDaoImpl,resourceRedisDao,roleDaoImpl,userDaoImpl,userDepartmentDaoImpl,userRoleRedisDao,BaseFrameSysmngService,departmentService,menuVisitedService,resourceService,roleService,systemUserService,userDepartmentService,userService,configurationExtensionRedisDao,resourceExtensionDaoImpl,resourceExtensionRedisDao,roleExtensionDaoImpl,userExtensionDaoImpl,userExtensionRedisDao,configurationExtensionService,resourceExtensionService,roleExtensionService,userExtensionService,org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor#0,baseConfigurer,entitymanagerfactory,eastcomPersistenceUnitManager,jpaVendor,atomikosTransactionManager,atomikosUserTransaction,transactionManager,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,defaultConfigurer,dataSource,esdpManagerFactory,esdpConfigurer,esdpDataSource,redisConfigurer,connectionFactory,userDesktopController,loginExtensionController,projectInfoController,userGuideController,loginController,mainV3Controller,subjectV1Controller,SSOController,validateCodeController,menuVisitedLogController,sysCommonController,argumentsConfigurateController,ftpProcessLogController,ftpServerController,sysLogAnalyzeController,sysLogAuditController,sysLogController,sysLogStatisticsController,sysRegionLogController,sysUserOnlineLogController,sysMonitorController,notificationController,notificationLogController,portalOperationController,portletConfController,initRedisDataController,redisDataController,monitorController,clusterMngController,esdpJobContainerController,esdpTaskMngController,esdpJobController,jobServiceController,casSecurityService,departmentController,resourceController,roleController,userController,userDepartmentController,configurationExtensionController,userExtensionController,redisTemplate,jedisPoolConfig,requestLogFilter,reqLogFilterUrls,reqLogFuzzyFilterUrls,shiroConfigurer,securityManager,casRealm,casSubjectFactory,ncspRealm,ncspAuth,safelessList,xssFilter,csrfFilter,hostFilter,customFilter,hostIpFilter,casFilter,authc,shiroFilterChainDefinitionsMap,shiroFilter,cacheManager,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy 2019-03-26 17:27:09,544 [localhost-startStop-1] ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in file [/home/bca/bca_app/apache-tomcat-7.0.92/webapps/web-esdp/WEB-INF/classes/security/applicationContext-shiro.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in file [/home/bca/bca_app/apache-tomcat-7.0.92/webapps/web-esdp/WEB-INF/classes/security/applicationContext-shiro.xml]: Cannot resolve reference to bean 'ncspRealm' while setting bean property 'realm'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ncspRealm': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.eastcom_sw.core.service.security.UserService com.eastcom_sw.core.service.security.NcspRealm.userService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.eastcom_sw.common.dao.jpa.LogDao com.eastcom_sw.common.service.BaseService.logDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logDaoImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entitymanagerfactory' defined in file [/home/bca/bca_app/apache-tomcat-7.0.92/webapps/web-esdp/WEB-INF/classes/default-db/applicationContext-default.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: defaultPU] Unable to build EntityManagerFactory at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)

为什么我没有用到数据库,却 Could not obtain connection metadata

![图片说明](https://img-ask.csdn.net/upload/201511/15/1447559307_565695.png) struts的配置文件是这样的 ![图片说明](https://img-ask.csdn.net/upload/201511/15/1447559391_552273.png)

Could not obtain connection metadata java.sql.SQLException错误,大家帮忙看看,着急

使用SpringMVC、Hibernate,现在tomcat启动报错。报错信息如下,请大家帮忙看看。谢谢! [color=green][color=blue]org.hibernate.connection.ConnectionProviderFactory.initializeConnectionProviderFromConfig(ConnectionProviderFactory.java:173) [INFO] - Initializing connection provider: org.springframework.orm.hibernate3.TransactionAwareDataSourceConnectionProvider 2013-07-08 16:20:18.933 [main] org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:140) [WARN] - Could not obtain connection metadata java.sql.SQLException: Io exception: The Network Adapter could not establish the connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:328) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:361) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:151) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:154) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113) at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:210) at $Proxy19.getMetaData(Unknown Source) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:116) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4172) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:701) at org.apache.catalina.startup.Catalina.start(Catalina.java:585) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)[/color][/color]

Could not obtain connection metadata java.sql.SQLException: Io exception

启动tomcat的时候就报下面的错。求大神指引。。。。。。。 谢谢 [INFO] - Initializing connection provider: org.springframework.orm.hibernate3.TransactionAwareDataSourceConnectionProvider 2013-07-08 16:20:18.933 [main] org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:140) [WARN] - Could not obtain connection metadata java.sql.SQLException: Io exception: The Network Adapter could not establish the connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:328) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:361) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:151) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:154) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113) at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:210) at $Proxy19.getMetaData(Unknown Source) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:116) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4172) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:701) at org.apache.catalina.startup.Catalina.start(Catalina.java:585) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

帮我看下配置文件,dao层一直报错、求指导,谢谢

报的错: `Messages: Could not obtain transaction-synchronized Session for current thread File: org/springframework/orm/hibernate5/SpringSessionContext.java Line number: 133 `` ``` 配置Spring-text.xml如下 ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <!-- **********************************************Admin************************************************ --> <bean id="AdminAction" class="com.lanou.admin4ZND.controllor.AdminAction" scope="prototype"> <property name="adminService" ref="AdminService"></property> </bean> <bean id="AdminService" class="com.lanou.admin4ZND.services.impl.AdminService"> <property name="adminDao" ref="AdminDao"></property> </bean> <bean id="AdminDao" class="com.lanou.admin4ZND.Dao.impl.AdminDao"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- **************************************************SESSIONFACTORY****************************************************************** --> <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <!--注入数据源, --> <property name="dataSource" ref="dataSource"></property> <!-- 配置别的属性 --> <property name="hibernateProperties"> <props> <prop key="show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> </props> </property> <property name="mappingLocations" value="classpath:com/lanou/ssh/entity/mappings/*.hbm.xml"></property> </bean> <!-- *******************************************DATASOURCE********************************************************** --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ZND?characterEncoding=utf-8&amp;useSSL=false" /> <property name="user" value="root" /> <property name="password" value="root" /> <property name="maxPoolSize" value="30"></property> <property name="minPoolSize" value="5" /> <property name="acquireIncrement" value="1"></property> </bean> <!-- ************************************TRANSCATION********************************************* --> <!-- 配置transactionManager --> <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:advice id="logicTx" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" timeout="-1" read-only="false" rollback-for="java.long.Exception" isolation="DEFAULT" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="find*" propagation="REQUIRED" /> <tx:method name="query*" propagation="REQUIRED" /> <tx:method name="select*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <!-- ******************************************AOP********************************************** --> <aop:config> <!-- 配置切点 --> <aop:pointcut expression="execution(* com.lanou.ssh.service.impl.*.*(..))" id="pointcut" /> <!-- 通知 --> <aop:advisor advice-ref="logicTx" pointcut-ref="pointcut" /> </aop:config> </beans> ```

Spring+Hibernate 在getCurrentSession的时候报错

以下是我的配置: spring-mvc.xml: ``` <!-- 加载配置文件 --> <context:property-placeholder location="WEB-INF/config/db.config.properties" /> <!-- 自动注入为bean --> <context:component-scan base-package="com.cherry.mall" /> <!-- 启动注解驱动的spring MVC功能,注册请求url和注解POJO类方法的映射 --> <mvc:annotation-driven> <!-- 返回json数据,@response使用 --> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 对模型视图名称的解析,在请求时模型视图名称添加前后缀 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/pages/" /> <property name="suffix" value=".jsp" /> </bean> <!--这里是对静态资源的映射 --> <!-- <mvc:resources mapping="/js/**" location="/resources/js/" /> <mvc:resources mapping="/css/**" location="/resources/css/" /> <mvc:resources mapping="/img/**" location="/resources/img/" /> --> ``` srping-hibernate: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd"> <!-- 配置数据源 c3p0 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${jdbc.driver}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- 请求超时时间 --> <property name="checkoutTimeout" value="30000" /> <!-- 每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 --> <property name="idleConnectionTestPeriod" value="30" /> <!-- 连接数据库连接池最大空闲时间 --> <property name="maxIdleTime" value="30" /> <!-- 连接池初始化连接数 --> <property name="initialPoolSize" value="5" /> <property name="minPoolSize" value="5" /> <property name="maxPoolSize" value="20" /> <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。默认值: 3 --> <property name="acquireIncrement" value="5" /> </bean> <!-- 配置hibernate的SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <!-- 注入数据源 相关信息看源码 --> <property name="dataSource" ref="dataSource" /> <!-- hibernate配置信息 --> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <!-- 开启二级缓存 ehcache --> <!-- <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop> <prop key="hibernate.cache.provider_configuration_file_resource_path">${hibernate.cache.provider_configuration_file_resource_path} </prop> --> </props> </property> <!-- 扫描hibernate注解配置的entity --> <property name="packagesToScan" value="com.cherry.mall.**.model" /> </bean> <!-- mybatis配置 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="/WEB-INF/config/mybatis-config.xml"></property> <property name="mapperLocations" value="classpath*:com/cherry/mall/**/mapping/*.xml"></property> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置事务增强处理Bean,指定事务管理器 --> <tx:advice id="transactionAdvice" transaction-manager="transactionManager"> <!-- 配置详细事务处理语义 --> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="create*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="alter*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="get*" propagation="SUPPORTS" read-only="true" /> <tx:method name="query*" propagation="SUPPORTS" read-only="true" /> <tx:method name="find*" propagation="SUPPORTS" read-only="true" /> <tx:method name="select*" propagation="SUPPORTS" read-only="true" /> <tx:method name="load*" propagation="SUPPORTS" read-only="true" /> <!-- 其他采用默认事务方式 --> <tx:method name="*" /> </tx:attributes> </tx:advice> <!-- Spring aop事务管理 --> <aop:config> <!-- 配置切入点 --> <aop:pointcut id="transactionPointcut" expression="execution(* com.cherry.mall..*.service..*.*(..))" /> <!-- 指定在txAdvice切入点应用txAdvice事务增强处理 --> <aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /> </aop:config> </beans> ``` 报错信息: ``` org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014) at com.cherry.mall.common.dao.CommonDAO.getHBSession(CommonDAO.java:29) at com.cherry.mall.common.dao.CommonDAO.create(CommonDAO.java:48) at com.cherry.mall.common.service.CommonServiceImpl.create(CommonServiceImpl.java:72) at com.cherry.mall.message.service.impl.MessageServiceImpl.create(MessageServiceImpl.java:30) at com.cherry.mall.message.service.impl.MessageServiceImpl.create(MessageServiceImpl.java:1) at com.cherry.mall.message.controller.MessageController.save(MessageController.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) ``` 报错地点: ![图片说明](https://img-ask.csdn.net/upload/201708/17/1502946641_931733.png) 求大神指教

Could not get JDBC Connection

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' ### The error may exist in cn/drzk/wanda/cinema/dao/form/dao/TicketsFromDao.java (best guess) ### The error may involve cn.drzk.wanda.cinema.dao.form.dao.TicketsFromDao.count ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'

Spring Security OAuth2

在使用Spring Security OAuth2测试时,授权之后报错: Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Dec 20 16:14:18 CST 2017 There was an unexpected error (type=Unauthorized, status=401). Authentication Failed: Could not obtain user details from token 客户端DEBUG信息: 2017-12-20 16:14:17.948 DEBUG 7932 --- [nio-8082-exec-4] o.s.s.oauth2.client.OAuth2RestTemplate : Created GET request for "http://localhost:8081/resource/user" 2017-12-20 16:14:17.967 DEBUG 7932 --- [nio-8082-exec-4] o.s.s.oauth2.client.OAuth2RestTemplate : Setting request Accept header to [application/json, application/*+json] 2017-12-20 16:14:18.204 DEBUG 7932 --- [nio-8082-exec-4] o.s.s.oauth2.client.OAuth2RestTemplate : GET request for "http://localhost:8081/resource/user" resulted in 401 (null); invoking error handler 2017-12-20 16:14:18.213 WARN 7932 --- [nio-8082-exec-4] o.s.b.a.s.o.r.UserInfoTokenServices : Could not fetch user details: class org.springframework.security.oauth2.common.exceptions.InvalidRequestException, Possible CSRF detected - state parameter was required but no state could be found 2017-12-20 16:14:18.280 DEBUG 7932 --- [nio-8082-exec-4] uth2ClientAuthenticationProcessingFilter : Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Could not obtain user details from token 认证服务器DEBUG信息: 2017-12-20 16:14:08.230 DEBUG 8704 --- [nio-8080-exec-7] o.s.s.w.a.i.FilterSecurityInterceptor : Secure object: FilterInvocation: URL: /favicon.ico; Attributes: [authenticated] 2017-12-20 16:14:08.230 DEBUG 8704 --- [nio-8080-exec-7] o.s.s.w.a.i.FilterSecurityInterceptor : Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@6fa90ed4: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffc7f0c: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 41D379AFB367FD4316A06BAC18AB91DA; Granted Authorities: ROLE_ANONYMOUS 2017-12-20 16:14:08.230 DEBUG 8704 --- [nio-8080-exec-7] o.s.s.access.vote.AffirmativeBased : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@72127537, returned: -1 2017-12-20 16:14:08.231 DEBUG 8704 --- [nio-8080-exec-7] o.s.s.w.a.ExceptionTranslationFilter : Access is denied (user is anonymous); redirecting to authentication entry point 资源服务器DEBUG信息: 2017-12-20 16:14:18.132 DEBUG 10100 --- [nio-8081-exec-1] o.s.security.web.FilterChainProxy : /user at position 5 of 11 in additional filter chain; firing Filter: 'OAuth2AuthenticationProcessingFilter' 2017-12-20 16:14:18.137 DEBUG 10100 --- [nio-8081-exec-1] p.a.OAuth2AuthenticationProcessingFilter : Authentication request failed: error="invalid_token", error_description="Invalid access token: fbde02a4-d6b9-41c8-a8aa-332390482c1e" 2017-12-20 16:14:18.192 DEBUG 10100 --- [nio-8081-exec-1] w.c.HttpSessionSecurityContextRepository : SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession. 2017-12-20 16:14:18.199 DEBUG 10100 --- [nio-8081-exec-1] s.s.o.p.e.DefaultOAuth2ExceptionRenderer : Written [error="invalid_token", error_description="Invalid access token: fbde02a4-d6b9-41c8-a8aa-332390482c1e"] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@74bcb39b] 2017-12-20 16:14:18.200 DEBUG 10100 --- [nio-8081-exec-1] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed 网上找了很久都没有解决,有研究过的大神指教一下

message": "Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Access denied for user 'root'@'49.232.89.109' (using password: YES)",

我用springboot搭了一套框架本地win10系统启动项目访问linux的mysql数据库没问题,可以访问,打包成jar后在linux部署,在访问接口报 "status": 500, "error": "Internal Server Error", "message": "Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Access denied for user 'root'@'49.232.89.109' (using password: YES)", 请大神看一下是什么问题?新人第一次来,请见谅

hibernate 不能自动连接数据库创建表

2016-05-17 10:54:24,536 INFO (Version.java:54) - HHH000412: Hibernate Core {4.3.10.Final} 2016-05-17 10:54:24,545 INFO (Environment.java:239) - HHH000206: hibernate.properties not found 2016-05-17 10:54:24,551 INFO (Environment.java:346) - HHH000021: Bytecode provider name : javassist 2016-05-17 10:54:25,510 WARN (JdbcServicesImpl.java:204) - HHH000342: Could not obtain connection to query metadata : Cannot create PoolableConnectionFactory (Table 'performance_schema.session_variables' doesn't exist) 2016-05-17 10:54:25,539 INFO (Dialect.java:145) - HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect 2016-05-17 10:54:25,569 INFO (LobCreatorBuilder.java:88) - HHH000422: Disabling contextual LOB creation as connection was null 2016-05-17 10:54:26,272 INFO (TransactionFactoryInitiator.java:62) - HHH000399: Using default transaction strategy (direct JDBC transactions) 2016-05-17 10:54:26,283 INFO (ASTQueryTranslatorFactory.java:47) - HHH000397: Using ASTQueryTranslatorFactory 2016-05-17 10:54:26,383 INFO (Version.java:56) - Hibernate Validator 4.1.0.Final 2016-05-17 10:54:26,397 INFO (DefaultTraversableResolver.java:81) - Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver. 2016-05-17 10:54:27,726 INFO (SchemaUpdate.java:207) - HHH000228: Running hbm2ddl schema update 2016-05-17 10:54:27,727 INFO (SchemaUpdate.java:218) - HHH000102: Fetching database metadata 2016-05-17 10:54:27,737 ERROR (SchemaUpdate.java:226) - HHH000319: Could not get database metadata

非典型SSH项目,启动服务器,出现如下错误,求大神支招

10:19:56.250 WARN org.hibernate.ejb.Ejb3Configuration[1132] - HHH000144: hibernate.connection.autocommit = false breaks the EJB3 specification 10:19:56.745 WARN o.h.e.jdbc.internal.JdbcServicesImpl[169] - HHH000342: Could not obtain connection to query metadata : Driver:net.sf.log4jdbc.DriverSpy@ef57f8 returned null for URL:jdbc:log4jdbc:mysql://localhost:3306/crmdb?useUnicode=true&characterEncoding=utf-8 10:19:56.760 ERROR o.s.web.context.ContextLoader[307] - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [D:\dev\tools\springsource\vfabric-tc-server-developer-2.8.2.RELEASE\base-instance\wtpwebapps\operation-crm\WEB-INF\classes\context\spring-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:734) ~[spring-context-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:457) ~[spring-context-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) ~[spring-web-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) ~[spring-web-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797) [catalina.jar:7.0.35.B] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291) [catalina.jar:7.0.35.B] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.35.B] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.35.B] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.35.B] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) [catalina.jar:7.0.35.B] at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657) [catalina.jar:7.0.35.B] at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637) [catalina.jar:7.0.35.B] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_32] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_32] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_32] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_32] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_32] at java.lang.Thread.run(Thread.java:662) [na:1.6.0_32] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [D:\dev\tools\springsource\vfabric-tc-server-developer-2.8.2.RELEASE\base-instance\wtpwebapps\operation-crm\WEB-INF\classes\context\spring-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:420) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:277) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79) ~[spring-tx-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70) ~[spring-tx-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103) ~[spring-tx-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] ... 24 common frames omitted Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) ~[hibernate-entitymanager-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) ~[hibernate-entitymanager-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) ~[hibernate-entitymanager-4.1.8.Final.jar:4.1.8.Final] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:287) ~[spring-orm-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310) ~[spring-orm-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE] ... 39 common frames omitted Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:97) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:67) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:170) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:77) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2283) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2279) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1748) ~[hibernate-core-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94) ~[hibernate-entitymanager-4.1.8.Final.jar:4.1.8.Final] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) ~[hibernate-entitymanager-4.1.8.Final.jar:4.1.8.Final] ... 45 common frames omitted 10:19:56.761 DEBUG l.s.c.w.l.ApplicationContextPostListener[35] - Invoke ApplicationContextPostListener contextInitialized

hibernate连接数据库报错

这是hibernate.cfg.xml配置文件,用户名和密码都用jdbc测试过可以连接上 ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.uesrname">root</property> <property name="hibernate.connection.password">liangqichan</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/cql1</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="hibernate.hbm2ddl.auto">update</property> <property name="hibernate.show_sql">true</property> <mapping resource="com/cql/crm/domain/SysUserGroup.hbm.xml"/> </session-factory> </hibernate-configuration> ``` 这是报错信息: 2016-6-30 11:56:43 org.hibernate.cfg.Environment <clinit> 信息: Hibernate 3.5.6-Final 2016-6-30 11:56:43 org.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2016-6-30 11:56:43 org.hibernate.cfg.Environment buildBytecodeProvider 信息: Bytecode provider name : javassist 2016-6-30 11:56:43 org.hibernate.cfg.Environment <clinit> 信息: using JDK 1.4 java.sql.Timestamp handling 2016-6-30 11:56:43 org.hibernate.cfg.Configuration configure 信息: configuring from resource: /hibernate.cfg.xml 2016-6-30 11:56:43 org.hibernate.cfg.Configuration getConfigurationInputStream 信息: Configuration resource: /hibernate.cfg.xml 2016-6-30 11:56:43 org.hibernate.cfg.Configuration addResource 信息: Reading mappings from resource : com/cql/crm/domain/SysUserGroup.hbm.xml 2016-6-30 11:56:43 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues 信息: Mapping class: com.cql.crm.domain.SysUserGroup -> sys_user_group 2016-6-30 11:56:43 org.hibernate.cfg.Configuration doConfigure 信息: Configured SessionFactory: null 2016-6-30 11:56:43 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: Using Hibernate built-in connection pool (not for production use!) 2016-6-30 11:56:43 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: Hibernate connection pool size: 20 2016-6-30 11:56:43 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: autocommit mode: false 2016-6-30 11:56:43 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/cql1 2016-6-30 11:56:43 org.hibernate.connection.DriverManagerConnectionProvider configure 信息: connection properties: {uesrname=root, password=****} 2016-6-30 11:56:43 org.hibernate.cfg.SettingsFactory buildSettings 警告: Could not obtain connection to query metadata java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES 补充: 这是我测试hibernate时的代码 package junit; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.junit.Test; import com.cql.crm.domain.SysUserGroup; public class TestHibernate { @Test public void testHibernateConf(){ Configuration config=new Configuration(); //config.configure("hibernate.cfg.xml"); config.configure(); SessionFactory sf=config.buildSessionFactory(); Session s=sf.openSession(); Transaction tx=s.beginTransaction(); SysUserGroup sysUserGroup=new SysUserGroup(); sysUserGroup.getName(); sysUserGroup.getPrincipal(); sysUserGroup.getIncumbent(); s.save(sysUserGroup); tx.commit(); s.close(); } } 这是我jdbc连接时的代码: public class jdbc { public static void main(String[] args) { String url="jdbc:mysql://localhost:3306/cql"; String user="root"; String password="liangqichan"; String sql="Select * from sys_user_group"; Connection conn=null; Statement st=null; ResultSet rs=null; try { conn=(Connection) DriverManager.getConnection(url, user, password); st=(Statement) conn.createStatement(); rs=st.executeQuery(sql); while(rs.next()){ System.out.println(rs.getString("id")); System.out.println(rs.getString("name")); System.out.println(rs.getString("remark")); } rs.close(); st.close(); conn.close(); } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } } }

hibernate项目运行一段时间后,JDBC报错

type Exception report message JDBC commit failed description The server encountered an internal error that prevented it from fulfilling this request. exception org.hibernate.TransactionException: JDBC commit failed org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:161) filter.TestFilter.doFilter(TestFilter.java:34) root cause com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during commit(). Transaction resolution unknown. sun.reflect.GeneratedConstructorAccessor21.newInstance(Unknown Source) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:526) com.mysql.jdbc.Util.handleNewInstance(Util.java:425) com.mysql.jdbc.Util.getInstance(Util.java:408) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1559) org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:170) org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:146) filter.TestFilter.doFilter(TestFilter.java:34) 项目使用的是hibernate+struts2+Mysql;项目不是跑起来就报错,是运行一段时间后就报错。服务器重启就可以了,但一段时间后又报错。mysql驱动用3.0的时候也是这个情况,不过抱错是No operations allowed after connection closed;现在换成最新的5.o就报这个个错误。求高手解决。。。 事务我直接用了个过滤器 public class TestFilter implements Filter { @Override public void destroy() { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest requ, ServletResponse respo, FilterChain chain) throws IOException, ServletException { HttpServletRequest request=(HttpServletRequest)requ; request.setCharacterEncoding("utf-8"); Session session=HibernateSessionFactory.getSession(); Transaction tr=session.beginTransaction(); chain.doFilter(request, respo); tr.commit();------报错在这行,34行 HibernateSessionFactory.closeSession(); } @Override public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub } }

软件测试入门、SQL、性能测试、测试管理工具

软件测试2小时入门,让您快速了解软件测试基本知识,有系统的了解; SQL一小时,让您快速理解和掌握SQL基本语法 jmeter性能测试 ,让您快速了解主流来源性能测试工具jmeter 测试管理工具-禅道,让您快速学会禅道的使用,学会测试项目、用例、缺陷的管理、

计算机组成原理实验教程

西北工业大学计算机组成原理实验课唐都仪器实验帮助,同实验指导书。分为运算器,存储器,控制器,模型计算机,输入输出系统5个章节

Java 最常见的 200+ 面试题:面试必备

这份面试清单是从我 2015 年做了 TeamLeader 之后开始收集的,一方面是给公司招聘用,另一方面是想用它来挖掘在 Java 技术栈中,还有那些知识点是我不知道的,我想找到这些技术盲点,然后修复它,以此来提高自己的技术水平。虽然我是从 2009 年就开始参加编程工作了,但我依旧觉得自己现在要学的东西很多,并且学习这些知识,让我很有成就感和满足感,那所以何乐而不为呢? 说回面试的事,这份面试...

winfrom中嵌套html,跟html的交互

winfrom中嵌套html,跟html的交互,源码就在里面一看就懂,很简单

玩转Python-Python3基础入门

总课时80+,提供源码和相关资料 本课程从Python零基础到纯Python项目实战。内容详细,案例丰富,覆盖了Python知识的方方面面,学完后不仅对Python知识有个系统化的了解,让你从Python小白变编程大牛! 课程包含: 1.python安装 2.变量、数据类型和运算符 3.选择结构 4.循环结构 5.函数和模块 6.文件读写 7.了解面向对象 8.异常处理

程序员的兼职技能课

获取讲师答疑方式: 在付费视频第一节(触摸命令_ALL)片头有二维码及加群流程介绍 限时福利 原价99元,今日仅需39元!购课添加小助手(微信号:csdn590)按提示还可领取价值800元的编程大礼包! 讲师介绍: 苏奕嘉&nbsp;前阿里UC项目工程师 脚本开发平台官方认证满级(六级)开发者。 我将如何教会你通过【定制脚本】赚到你人生的第一桶金? 零基础程序定制脚本开发课程,是完全针对零脚本开发经验的小白而设计,课程内容共分为3大阶段: ①前期将带你掌握Q开发语言和界面交互开发能力; ②中期通过实战来制作有具体需求的定制脚本; ③后期将解锁脚本的更高阶玩法,打通任督二脉; ④应用定制脚本合法赚取额外收入的完整经验分享,带你通过程序定制脚本开发这项副业,赚取到你的第一桶金!

HoloLens2开发入门教程

本课程为HoloLens2开发入门教程,讲解部署开发环境,安装VS2019,Unity版本,Windows SDK,创建Unity项目,讲解如何使用MRTK,编辑器模拟手势交互,打包VS工程并编译部署应用到HoloLens上等。

基于VHDL的16位ALU简易设计

基于VHDL的16位ALU简易设计,可完成基本的加减、带进位加减、或、与等运算。

MFC一站式终极全套课程包

该套餐共包含从C小白到C++到MFC的全部课程,整套学下来绝对成为一名C++大牛!!!

利用Verilog实现数字秒表(基本逻辑设计分频器练习)

设置复位开关。当按下复位开关时,秒表清零并做好计时准备。在任何情况下只要按下复位开关,秒表都要无条件地进行复位操作,即使是在计时过程中也要无条件地进行清零操作。 设置启/停开关。当按下启/停开关后,将

董付国老师Python全栈学习优惠套餐

购买套餐的朋友可以关注微信公众号“Python小屋”,上传付款截图,然后领取董老师任意图书1本。

Python可以这样学(第一季:Python内功修炼)

董付国系列教材《Python程序设计基础》、《Python程序设计(第2版)》、《Python可以这样学》配套视频,讲解Python 3.5.x和3.6.x语法、内置对象用法、选择与循环以及函数设计与使用、lambda表达式用法、字符串与正则表达式应用、面向对象编程、文本文件与二进制文件操作、目录操作与系统运维、异常处理结构。

计算机操作系统 第三版.pdf

计算机操作系统 第三版 本书全面介绍了计算机系统中的一个重要软件——操作系统(OS),本书是第三版,对2001年出版的修订版的各章内容均作了较多的修改,基本上能反映当前操作系统发展的现状,但章节名称基

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

微信公众平台开发入门

本套课程的设计完全是为初学者量身打造,课程内容由浅入深,课程讲解通俗易懂,代码实现简洁清晰。通过本课程的学习,学员能够入门微信公众平台开发,能够胜任企业级的订阅号、服务号、企业号的应用开发工作。 通过本课程的学习,学员能够对微信公众平台有一个清晰的、系统性的认识。例如,公众号是什么,它有什么特点,它能做什么,怎么开发公众号。 其次,通过本课程的学习,学员能够掌握微信公众平台开发的方法、技术和应用实现。例如,开发者文档怎么看,开发环境怎么搭建,基本的消息交互如何实现,常用的方法技巧有哪些,真实应用怎么开发。

150讲轻松搞定Python网络爬虫

【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑

SEIR课程设计源码与相关城市数据.rar

SEIR结合学报与之前博客结合所做的一些改进,选择其中三个城市进行拟合仿真SEIR结合学报与之前博客结合所做的一些改进,选择其中三个城市进行拟合仿真SEIR结合学报与之前博客结合所做的一些改进,选择其

Python数据挖掘简易入门

&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

Java面试题大全(2020版)

发现网上很多Java面试题都没有答案,所以花了很长时间搜集整理出来了这套Java面试题大全,希望对大家有帮助哈~ 本套Java面试题大全,全的不能再全,哈哈~ 一、Java 基础 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境。 JRE:Java Runtime Environ...

定量遥感中文版 梁顺林著 范闻捷译

这是梁顺林的定量遥感的中文版,由范闻捷等翻译的,是电子版PDF,解决了大家看英文费时费事的问题,希望大家下载看看,一定会有帮助的

GIS程序设计教程 基于ArcGIS Engine的C#开发实例

张丰,杜震洪,刘仁义编著.GIS程序设计教程 基于ArcGIS Engine的C#开发实例.浙江大学出版社,2012.05

人工智能-计算机视觉实战之路(必备算法+深度学习+项目实战)

系列课程主要分为3大阶段:(1)首先掌握计算机视觉必备算法原理,结合Opencv进行学习与练手,通过实际视项目进行案例应用展示。(2)进军当下最火的深度学习进行视觉任务实战,掌握深度学习中必备算法原理与网络模型架构。(3)结合经典深度学习框架与实战项目进行实战,基于真实数据集展开业务分析与建模实战。整体风格通俗易懂,项目驱动学习与就业面试。 建议同学们按照下列顺序来进行学习:1.Python入门视频课程 2.Opencv计算机视觉实战(Python版) 3.深度学习框架-PyTorch实战/人工智能框架实战精讲:Keras项目 4.Python-深度学习-物体检测实战 5.后续实战课程按照自己喜好选择就可以

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

微信小程序开发实战之番茄时钟开发

微信小程序番茄时钟视频教程,本课程将带着各位学员开发一个小程序初级实战类项目,针对只看过官方文档而又无从下手的开发者来说,可以作为一个较好的练手项目,对于有小程序开发经验的开发者而言,可以更好加深对小程序各类组件和API 的理解,为更深层次高难度的项目做铺垫。

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

去除异常值matlab程序

数据预处理中去除异常值的程序,matlab写成

用verilog HDL语言编写的秒表

在秒表设计中,分模块书写。用在七段数码管上显示。输入频率是1KHZ.可以显示百分秒,秒,分。如要显示小时,只需修改leds里的代码和主模块代码。改程序以通过硬件电路验证。完全正确。

[透视java——反编译、修补和逆向工程技术]源代码

源代码。

相关热词 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行 c# 循环给数组插入数据 c# 多线程死锁的例子 c# 钉钉读取员工排班 c# label 不显示 c#裁剪影像 c#工作进程更新ui
立即提问