您的位置:首页 > 其它

ssh中异常总结

2017-07-27 09:29 786 查看

09:29:14,596 ERROR DefaultDispatcherErrorHandler:42 - Exception occurred during processing request: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove
'readOnly' marker from transaction definition.

org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

原因:ssh中使用注解开发,将hibernate交给spring容器,但是忘记在service中使用事务注解@Transactional,加上即可。

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerService' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'txAdvice': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager'
defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]

原因:ssh开发时,全部使用配置文件方式,在applicationContext.xml中使用的是c3p0连接池,而hibernate.cfg.xml中没有配置连接池,将连接池添加上去即可。

 <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>





内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  异常