SSH整合错误三连

访问Action错误

ognl.MethodFailedException: Method "add" failed for object com.test3.action.UserAction@557d9144 [java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;]

at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1305)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:108)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1369)
at ognl.ASTMethod.getValueBody(ASTMethod.java:90)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.Ognl.getValue(Ognl.java:494)
at ognl.Ognl.getValue(Ognl.java:458)

...省略

1、这是版本问题,参见此问题的Answer

https://www.e-learn.cn/content/wangluowenzhang/287437

版本符合后,又出现error

 

org.springframework.orm.hibernate4.HibernateSystemException: getFlushMode is not valid without active transaction; nested exception is org.hibernate.HibernateException: getFlushMode is not valid without active transaction org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:218) org.springframework.orm.hibernate4.HibernateTemplate.doExecute(HibernateTemplate.java:344) org.springframework.orm.hibernate4.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:309) org.springframework.orm.hibernate4.HibernateTemplate.save(HibernateTemplate.java:618) com.test3.dao.impl.UserDaoImpl.save(UserDaoImpl.java:13) com.test3.service.impl.UserServiceImpl.save(UserServiceImpl.java:17) com.test3.action.UserAction.add(UserAction.java:25) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:870)

2、参考该链接第二种方法

https://blog.csdn.net/maoyuanming0806/article/details/61417995

若此时无error最好不过了,现实很残酷

又一error

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.

3、检查spring的配置文件,查看事务启动

使用注解的情况

<tx:annotation-driven transaction-manager="transactionManager"/>

参考https://blog.csdn.net/yu0_zhang0/article/details/77938009

没有使用注解

检查配置切入点路径是否正确

个人是因为路径写错,修改后无错误。

记录一次error三连。

 

posted @ 2019-04-22 11:04  Star灬木子李  阅读(359)  评论(0编辑  收藏  举报