java.lang.IllegalStateException: Active Spring transaction synchronization or active JTA transaction with specified [javax.transaction.TransactionManager] required

错误信息:

 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

java.lang.IllegalStateException: Active Spring transaction synchronization or active JTA transaction with specified [javax.transaction.TransactionManager] required的相关文章

分布式配置中心config-client配置报错:java.lang.IllegalStateException: duplicate key: spring

今天练习分布式配置中心,写config-client配置文件,使用bootstrap.properties配置,运行没有问题. bootstrap.properties: spring.application.name=config-client spring.cloud.config.label=master spring.cloud.config.profile=dev spring.cloud.config.uri= http://localhost:8888/ server.port=8

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.templateEngine

2018-12-25 22:58:28.023 DEBUG 2204 --- [ restartedMain] c.c.c.a.CrawlerAutohomeApplication : Running with Spring Boot v2.1.1.RELEASE, Spring v5.1.3.RELEASE 2018-12-25 22:58:28.039 INFO 2204 --- [ restartedMain] c.c.c.a.CrawlerAutohomeApplication : No

java.lang.IllegalStateException: Service id not legal hostname (leyou_item_service)

. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.2.1.RELEASE)

java.lang.IllegalStateException: Failed to load ApplicationContext

1.错误描述 INFO:2015-02-05 22:14:21[main] - Loading XML bean definitions from class path resource [applicationContext.xml] INFO:2015-02-05 22:14:22[main] - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning INFO:2015-02-05

java.lang.IllegalStateException: No typehandler found for mapping XXX

前言:今天遇到了这个问题,刚开始觉得很容易解决的,毕竟能定位到出问题的文件和对应的字段,根据以往的经验也可以判断出是字段映射类型不匹配的问题,后来找了半天还是没找到问题的根源,从网上百度,也没看到令人满意的分析以及和我情况类似的描述.于是,下定决心,先深呼吸,然后冷静下来好好玩一下. 如下是我的分析过程,这里以提供分析的思路为主,希望以后在遇到类似的问题能一下子定位到,解决掉. 1:异常信息的一部分,如下所示,和以往一样,先仔细瞧瞧,根据异常的提示基本能定位到问题出在那个文件,那个字段或者某个小

lob类型数据处理 java.lang.IllegalStateException: No LobHandler found for configuration

1 .MySQL处理数据库中lob类型数据,如longblob类型: 2.实体类定义: private byte[] clientFile; 3.映射文件定义: <property name="clientFile" type="org.springframework.orm.hibernate3.support.BlobByteArrayType">      <column name="client_file"/> &

Fragment java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

首先描述下所要实现的功能点: MainActivity使用Fragment实现底部菜单,底部共有四个菜单按钮,分别对应:AFragment,BFragment,CFragment,DFragment.其中AFragment是默认显示. 点击CFragment中的一个button后跳转到第二个Activity界面:SecondActivity. SecondActivity返回键有两个:button01.button02.其中button01返回的是CFragment:button02返回的是AF

java.lang.IllegalStateException: BeanFactory not initialized or already closed - call &#39;refresh&#39; before accessing beans via the ApplicationContext

spring的项目中有时候会报错:java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext 原因:spring初始化bean对象出错:1)xml的bean的id 有重复: 2)如果是注解配置:可能是注解的名称有重复: 只需要将重复的bean 的id和重复的注解改了就

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

1. 场景: 在开发过程中遇到这么一个需要,在主页点击按钮进入另一个Activity(ReadActivity),在该ReadActivity中点击一个按钮再返回主页并指定主页选中特定的Tab.主页是用FragmentTabHost + Fragment 实现.思路是通过startActivityForResult以及setResult() 以及requestCode作为标志位,是ReadActivity返回,因为还有其他的requestCode.再通过 FragmentTabHost的setC