错误信息:
1 java.lang.IllegalStateException: Active Spring transaction synchronization or active JTA transaction with specified [javax.transaction.TransactionManager] required 2 at org.springframework.jdbc.support.lob.LobCreatorUtils.registerTransactionSynchronization(LobCreatorUtils.java:79) 3 at org.springframework.orm.hibernate3.support.AbstractLobType.nullSafeSet(AbstractLobType.java:185) 4 at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:140) 5 at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2166) 6 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2412) 7 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2856) 8 at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79) 9 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) 10 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) 11 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184) 12 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) 13 at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) 14 at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) 15 at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390) 16 at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:407) 17 at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) 18 at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683) 19 at com.tera.sys.dao.BaseDao.save(BaseDao.java:198) 20 at com.tera.erule.regression.testCases.service.TestCasesService.add(TestCasesService.java:50) 21 at com.tera.erule.regression.testCases.service.TestCasesService.testCaseSave(TestCasesService.java:316) 22 at com.tera.erule.regression.testCases.service.TestCasesService$$FastClassByCGLIB$$e7e6db19.invoke(<generated>) 23 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) 24 at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:617) 25 at com.tera.erule.regression.testCases.service.TestCasesService$$EnhancerByCGLIB$$97f26dc3.testCaseSave(<generated>) 26 at com.tera.erule.regression.testCases.controller.TestCasesController.testCaseSave(TestCasesController.java:159) 27 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 28 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 29 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 30 at java.lang.reflect.Method.invoke(Method.java:497) 31 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 32 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) 33 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) 34 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) 35 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) 36 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) 37 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) 38 at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) 39 at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 40 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) 41 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 42 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 43 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 44 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 45 at com.tera.sys.filter.AccessFilter.doFilter(AccessFilter.java:80) 46 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 47 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 48 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 49 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 50 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 51 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 52 at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) 53 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 54 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 55 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 56 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) 57 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94) 58 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) 59 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) 60 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 61 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) 62 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) 63 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502) 64 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132) 65 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) 66 at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2527) 67 at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2516) 68 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 69 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 70 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 71 at java.lang.Thread.run(Thread.java:745)
<property name="remark" type="org.springframework.orm.hibernate3.support.ClobStringType"> <column name="remark"> <comment>备注</comment> </column></property>
错误分析:保存含有大字段的对象报错
错误原因:对象含有大字段(CLOB),在操作大字段时一定要在事物下执行,否则会报错
解决办法:
1.加@Transactional
2.还有一种处理方式是不加事物,操作配置文件。
原文地址:https://www.cnblogs.com/Y-zhiwei/p/10107150.html
时间: 2024-10-14 08:55:22