ssh中异常总结

来源:互联网 发布:淘宝运费险如何使用 编辑:程序博客网 时间:2024/06/07 19:03

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>






原创粉丝点击