{"id":449,"date":"2018-06-04T11:30:05","date_gmt":"2018-06-04T03:30:05","guid":{"rendered":"http:\/\/pony.hk\/?p=449"},"modified":"2018-06-04T11:33:41","modified_gmt":"2018-06-04T03:33:41","slug":"mysql-wait_timeout-java%e6%8a%a5%e9%94%99%ef%bc%9acould-not-open-jpa-entitymanager-for-transaction","status":"publish","type":"post","link":"https:\/\/lnmp.ivan.xin\/?p=449","title":{"rendered":"mysql, wait_timeout, java\u62a5\u9519\uff1aCould not open JPA EntityManager for transaction"},"content":{"rendered":"<p>\u5751\u7239\u7684\u963f\u91cc\u4e91mysql\u6570\u636e\u5e93\uff0c\u8bbe\u7f6e\u7684wait_timeout\u53ea\u670990\u79d2\uff0c\u5bfc\u81f4tomcat java\u8fde\u63a5\u6570\u636e\u5e93\u9891\u7e41\u62a5\u9519\uff1a<\/p>\n<blockquote><p>java.lang.RuntimeException: org.apache.jasper.JasperException: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.IllegalStateException: Transaction already active<\/p><\/blockquote>\n<p>\u6b65\u9aa4\uff1a<br \/>\n1\u3001\u68c0\u67e5\uff0c\u5728mysql\u4e2d\u6267\u884c\uff1ashow global variables like \"%timeout%\";<br \/>\n\u5f97\u5230\u7ed3\u679c<\/p>\n<blockquote><p>1 connect_timeout 15<br \/>\n2 delayed_insert_timeout 300<br \/>\n3 innodb_lock_wait_timeout 50<br \/>\n4 innodb_rollback_on_timeout OFF<br \/>\n5 interactive_timeout 28800<br \/>\n6 net_read_timeout 30<br \/>\n7 net_write_timeout 60<br \/>\n8 slave_net_timeout 3600<br \/>\n9 table_lock_wait_timeout 50<br \/>\n10 wait_timeout 90<\/p><\/blockquote>\n<p>2\u3001\u5728\u5e94\u7528\u7684\u914d\u7f6e\u6587\u4ef6applicationContext.xml\u4e2d\u4fee\u6539\u4ee5\u4e0b\u914d\u7f6e\uff0c\u628a<\/p>\n<blockquote><p>&lt;property name=\"timeBetweenEvictionRunsMillis\" value=\"1200000\" \/&gt;<br \/>\n&lt;property name=\"minEvictableIdleTimeMillis\" value=\"1200000\" \/&gt;<br \/>\n&lt;property name=\"testWhileIdle\" value=\"true\" \/&gt;<br \/>\n&lt;property name=\"validationQuery\" value=\"select 1\" \/&gt;<\/p><\/blockquote>\n<p>\u4fee\u6539\u4e3a<\/p>\n<blockquote><p>&lt;property name=\"timeBetweenEvictionRunsMillis\" value=\"89000\" \/&gt;<br \/>\n&lt;property name=\"minEvictableIdleTimeMillis\" value=\"89000\" \/&gt;<br \/>\n&lt;property name=\"testWhileIdle\" value=\"true\" \/&gt;<br \/>\n&lt;property name=\"validationQuery\" value=\"select 1\" \/&gt;<br \/>\n&lt;property name=\"testOnBorrow\" value=\"true\" \/&gt;<\/p><\/blockquote>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<br \/>\n<a href=\"https:\/\/stackoverflow.com\/questions\/20556172\/could-not-roll-back-jpa-transaction-javax-persistence-persistenceexception-une\" target=\"_blank\" rel=\"noopener\">https:\/\/stackoverflow.com\/questions\/20556172\/could-not-roll-back-jpa-transaction-javax-persistence-persistenceexception-une<\/a><br \/>\n<a href=\"https:\/\/blog.csdn.net\/wangfayinn\/article\/details\/24623575\" target=\"_blank\" rel=\"noopener\">https:\/\/blog.csdn.net\/wangfayinn\/article\/details\/24623575<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5751\u7239\u7684\u963f\u91cc\u4e91mysql\u6570\u636e\u5e93\uff0c\u8bbe\u7f6e\u7684wait_timeout\u53ea\u670990\u79d2\uff0c\u5bfc\u81f4tomcat java\u8fde\u63a5\u6570\u636e\u5e93\u9891...<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22781],"tags":[],"class_list":["post-449","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=449"}],"version-history":[{"count":0,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/449\/revisions"}],"wp:attachment":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}