[Seasar-user:17350] トランザクション処理について
岩元 もぁーぃ
[E-MAIL ADDRESS DELETED]
2009年 4月 30日 (木) 22:18:13 JST
はじめまして。もぁーぃと申します。
現在S2+hibernate3+PostgreSQL8.3でトランザクション処理に困っています。
解決策がありましたらご教授お願いいたします。
環境は
- s2-extension-2.3.16.jar
- s2-framework-2.3.16.jar
- s2-hibernate-1.1.2.jar
- hibernate3.jar
- postgresql-8.3-603.jdbc3.jar
を使用しています。
上記環境にて、
Seasarのトランザクション(j2ee.requiredTx)をうまく適用できていない状態です。
1トランザクションの処理は以下の通りです。
1.あるテーブルのある項目の最大値(カウンタみたいなもの)を取得する。
2.取得した内容をインクリメントする。
3.2でインクリメントした項目をキーとして2つのテーブル(1のテーブルを含む)にInsertを行う。
4.3でInsertした内容を取得して、画面に表示する。
現在起きている現象は、処理3で実施したsave()が処理4のcreateQuery実行時に反映されているようで
エラーが発生しない間は問題ないのですが、一度エラーが発生すると処理1のcreateQuery実行時に
ERROR: duplicate key value violates unique constraint "aaaaa_bbbbb_pkey"が発生し、
それ以降の処理全てを実行することができない状態となっています。
最初に出力されるエラー内容は以下の通りです。
[ESSR0072]SQLで例外(SQL=[insert into *******_t_answer_history (answer_starttime, answer_endtime, get_total_score, right_per_answer, necessary_time, pass_ornot, add_user, update_user, user_id, lesson_id, answer_count) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], ErrorCode=0, SQLState=23505)が発生しました
ERROR: duplicate key value violates unique constraint "*******_t_answer_history_pkey"
[ESSR0072]SQLで例外(SQL=[insert into *******_t_answer_details (field_code, question_number, user_answer, right_ornot, add_user, update_user, user_id, lesson_id, answer_count, view_number) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], ErrorCode=0, SQLState=55000)が発生しました
This statement has been closed.
Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [com.*******.domain.*******TAnswerDetail]
大変恐縮ですが、以下のdiconファイルを基にトランザクション処理を確認したところ、
下記ログのようなエラーが発生しているのですが、その場合の修正方法をご教授願えませんでしょうか。
j2ee.dicon
-------------------------------------------------------------------------------
<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container//EN"
"http://www.seasar.org/dtd/components.dtd">
<components namespace="j2ee">
<component name="transactionManager"
class="org.seasar.extension.jta.TransactionManagerImpl"/>
<component name="requiredTx"
class="org.seasar.extension.tx.RequiredInterceptor"/>
<component name="requiresNewTx"
class="org.seasar.extension.tx.RequiresNewInterceptor"/>
<component name="mandatoryTx"
class="org.seasar.extension.tx.MandatoryInterceptor"/>
<component name="notSupportedTx"
class="org.seasar.extension.tx.NotSupportedInterceptor"/>
<component class="org.seasar.extension.jdbc.impl.BasicResultSetFactory"/>
<component class="org.seasar.extension.jdbc.impl.BasicStatementFactory"/>
<!--
<component class="org.seasar.extension.jdbc.impl.OracleResultSetFactory"/>
<component class="org.seasar.extension.jdbc.impl.BooleanToIntStatementFactory"/>
-->
<component name="xaDataSource"
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
<property name="driverClassName">
"org.postgresql.Driver"
</property>
<property name="URL">
"jdbc:postgresql://localhost:5432/e_assess"
</property>
<property name="user">"*******"</property>
<property name="password">"*******"</property>
</component>
<component name="connectionPool"
class="org.seasar.extension.dbcp.impl.ConnectionPoolImpl">
<property name="timeout">600</property>
<property name="maxPoolSize">30</property>
<property name="allowLocalTx">false</property>
<destroyMethod name="close"/>
</component>
<component name="dataSource"
class="org.seasar.extension.dbcp.impl.DataSourceImpl"/>
</components>
Result.dicon
-------------------------------------------------------------------------------
<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container//EN"
"http://www.seasar.org/dtd/components.dtd">
<components>
<include path="j2ee.dicon"/>
<component class="org.seasar.hibernate3.impl.S2SessionFactoryImpl"/>
<component class="com.*******.trial.dao.ResultDaoImpl">
</component>
<component class="com.*******.trial.service.ResultServiceImpl">
<aspect>j2ee.requiredTx</aspect>
</component>
</components>
<property name="allowLocalTx">false</property>時のTomcat起動時ログ
-------------------------------------------------------------------------------
致命的: StandardWrapper.Throwable
org.seasar.framework.exception.InvocationTargetRuntimeException: [ESSR0043]com.*******.signup.service.ConfirmServiceImpl$$EnhancedByS2AOP$$47b232が呼び出した対象が不正です。理由はorg.seasar.framework.exception.SIllegalStateException: [ESSR0311]トランザクションが開始されていません
at org.seasar.framework.util.ConstructorUtil.newInstance(ConstructorUtil.java:47)
at org.seasar.framework.container.assembler.AutoConstructorAssembler.doAssemble(AutoConstructorAssembler.java:43)
at org.seasar.framework.container.assembler.AbstractConstructorAssembler.assemble(AbstractConstructorAssembler.java:50)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.assemble(SingletonComponentDeployer.java:67)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.deploy(SingletonComponentDeployer.java:51)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.init(SingletonComponentDeployer.java:97)
at org.seasar.framework.container.impl.ComponentDefImpl.init(ComponentDefImpl.java:284)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:399)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:396)
at org.seasar.framework.container.factory.SingletonS2ContainerFactory.init(SingletonS2ContainerFactory.java:54)
at org.seasar.framework.container.servlet.S2ContainerServlet.init(S2ContainerServlet.java:84)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3099)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:404)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1309)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.seasar.framework.exception.SIllegalStateException: [ESSR0311]トランザクションが開始されていません
at org.seasar.extension.dbcp.impl.ConnectionPoolImpl.checkOut(ConnectionPoolImpl.java:146)
at org.seasar.extension.dbcp.impl.DataSourceImpl.getConnection(DataSourceImpl.java:46)
at org.seasar.extension.jdbc.util.DataSourceUtil.getConnection(DataSourceUtil.java:36)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getConnection(S2SessionFactoryImpl.java:105)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.createSession(S2SessionFactoryImpl.java:101)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getSession(S2SessionFactoryImpl.java:87)
at com.*******.signup.service.ConfirmServiceImpl.<init>(ConfirmServiceImpl.java:35)
at com.*******.signup.service.ConfirmServiceImpl$$EnhancedByS2AOP$$47b232.<init>(ConfirmServiceImpl$$EnhancedByS2AOP$$47b232.java)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.seasar.framework.util.ConstructorUtil.newInstance(ConstructorUtil.java:39)
... 23 more
2009/04/30 22:02:56 org.apache.catalina.core.StandardContext loadOnStartup
致命的: サーブレット /******** がload()例外を投げました
org.seasar.framework.exception.SIllegalStateException: [ESSR0311]トランザクションが開始されていません
at org.seasar.extension.dbcp.impl.ConnectionPoolImpl.checkOut(ConnectionPoolImpl.java:146)
at org.seasar.extension.dbcp.impl.DataSourceImpl.getConnection(DataSourceImpl.java:46)
at org.seasar.extension.jdbc.util.DataSourceUtil.getConnection(DataSourceUtil.java:36)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getConnection(S2SessionFactoryImpl.java:105)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.createSession(S2SessionFactoryImpl.java:101)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getSession(S2SessionFactoryImpl.java:87)
at com.*******.signup.service.ConfirmServiceImpl.<init>(ConfirmServiceImpl.java:35)
at com.*******.signup.service.ConfirmServiceImpl$$EnhancedByS2AOP$$47b232.<init>(ConfirmServiceImpl$$EnhancedByS2AOP$$47b232.java)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.seasar.framework.util.ConstructorUtil.newInstance(ConstructorUtil.java:39)
at org.seasar.framework.container.assembler.AutoConstructorAssembler.doAssemble(AutoConstructorAssembler.java:43)
at org.seasar.framework.container.assembler.AbstractConstructorAssembler.assemble(AbstractConstructorAssembler.java:50)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.assemble(SingletonComponentDeployer.java:67)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.deploy(SingletonComponentDeployer.java:51)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.init(SingletonComponentDeployer.java:97)
at org.seasar.framework.container.impl.ComponentDefImpl.init(ComponentDefImpl.java:284)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:399)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:396)
at org.seasar.framework.container.factory.SingletonS2ContainerFactory.init(SingletonS2ContainerFactory.java:54)
at org.seasar.framework.container.servlet.S2ContainerServlet.init(S2ContainerServlet.java:84)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3099)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:404)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1309)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
Loading validation rules file from '/WEB-INF/validator-rules.xml'
Loading validation rules file from '/WEB-INF/validation.xml'
2009/04/30 22:03:37 org.apache.catalina.core.StandardContext reload
情報: このコンテキストの再ロードを開始しました
No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/********/workspace/********/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
2009/04/30 22:03:42 org.apache.catalina.core.ApplicationContext log
致命的: StandardWrapper.Throwable
org.seasar.framework.exception.InvocationTargetRuntimeException: [ESSR0043]com.*******.signup.service.ConfirmServiceImpl$$EnhancedByS2AOP$$1e59715が呼び出した対象が不正です。理由はorg.seasar.framework.exception.SIllegalStateException: [ESSR0311]トランザクションが開始されていません
at org.seasar.framework.util.ConstructorUtil.newInstance(ConstructorUtil.java:47)
at org.seasar.framework.container.assembler.AutoConstructorAssembler.doAssemble(AutoConstructorAssembler.java:43)
at org.seasar.framework.container.assembler.AbstractConstructorAssembler.assemble(AbstractConstructorAssembler.java:50)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.assemble(SingletonComponentDeployer.java:67)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.deploy(SingletonComponentDeployer.java:51)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.init(SingletonComponentDeployer.java:97)
at org.seasar.framework.container.impl.ComponentDefImpl.init(ComponentDefImpl.java:284)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:399)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:396)
at org.seasar.framework.container.factory.SingletonS2ContainerFactory.init(SingletonS2ContainerFactory.java:54)
at org.seasar.framework.container.servlet.S2ContainerServlet.init(S2ContainerServlet.java:84)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3099)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:404)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1309)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.seasar.framework.exception.SIllegalStateException: [ESSR0311]トランザクションが開始されていません
at org.seasar.extension.dbcp.impl.ConnectionPoolImpl.checkOut(ConnectionPoolImpl.java:146)
at org.seasar.extension.dbcp.impl.DataSourceImpl.getConnection(DataSourceImpl.java:46)
at org.seasar.extension.jdbc.util.DataSourceUtil.getConnection(DataSourceUtil.java:36)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getConnection(S2SessionFactoryImpl.java:105)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.createSession(S2SessionFactoryImpl.java:101)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getSession(S2SessionFactoryImpl.java:87)
at com.*******.signup.service.ConfirmServiceImpl.<init>(ConfirmServiceImpl.java:35)
at com.*******.signup.service.ConfirmServiceImpl$$EnhancedByS2AOP$$1e59715.<init>(ConfirmServiceImpl$$EnhancedByS2AOP$$1e59715.java)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.seasar.framework.util.ConstructorUtil.newInstance(ConstructorUtil.java:39)
... 23 more
2009/04/30 22:03:42 org.apache.catalina.core.StandardContext loadOnStartup
致命的: サーブレット /******** がload()例外を投げました
org.seasar.framework.exception.SIllegalStateException: [ESSR0311]トランザクションが開始されていません
at org.seasar.extension.dbcp.impl.ConnectionPoolImpl.checkOut(ConnectionPoolImpl.java:146)
at org.seasar.extension.dbcp.impl.DataSourceImpl.getConnection(DataSourceImpl.java:46)
at org.seasar.extension.jdbc.util.DataSourceUtil.getConnection(DataSourceUtil.java:36)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getConnection(S2SessionFactoryImpl.java:105)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.createSession(S2SessionFactoryImpl.java:101)
at org.seasar.hibernate3.impl.S2SessionFactoryImpl.getSession(S2SessionFactoryImpl.java:87)
at com.*******.signup.service.ConfirmServiceImpl.<init>(ConfirmServiceImpl.java:35)
at com.*******.signup.service.ConfirmServiceImpl$$EnhancedByS2AOP$$1e59715.<init>(ConfirmServiceImpl$$EnhancedByS2AOP$$1e59715.java)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.seasar.framework.util.ConstructorUtil.newInstance(ConstructorUtil.java:39)
at org.seasar.framework.container.assembler.AutoConstructorAssembler.doAssemble(AutoConstructorAssembler.java:43)
at org.seasar.framework.container.assembler.AbstractConstructorAssembler.assemble(AbstractConstructorAssembler.java:50)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.assemble(SingletonComponentDeployer.java:67)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.deploy(SingletonComponentDeployer.java:51)
at org.seasar.framework.container.deployer.SingletonComponentDeployer.init(SingletonComponentDeployer.java:97)
at org.seasar.framework.container.impl.ComponentDefImpl.init(ComponentDefImpl.java:284)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:399)
at org.seasar.framework.container.impl.S2ContainerImpl.init(S2ContainerImpl.java:396)
at org.seasar.framework.container.factory.SingletonS2ContainerFactory.init(SingletonS2ContainerFactory.java:54)
at org.seasar.framework.container.servlet.S2ContainerServlet.init(S2ContainerServlet.java:84)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3099)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:404)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1309)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
-------------------------------------------------------------------------------
必要なソース・設定ファイルがありましたら適宜送付させて頂きたいと思っております。
何卒よろしくお願い致します。
_________________________________________________________________
携帯電話用 Web サービスに簡単にアクセス
http://windowslive.jp.msn.com/mobile.htm
-------------- next part --------------
HTMLの添付ファイルを保管しました...
URL: <http://ml.seasar.org/archives/seasar-user/attachments/20090430/ee4223b0/attachment.html>
Seasar-user メーリングリストの案内