java EJB 事务回滚异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14314713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 15:51:00  来源:igfitidea点击:

EJB transaction rolled back exception

javajakarta-eeejbweblogicrollback

提问by sindhu

I am using ejb-2 I get the following exception. Can someone tell me what does it mean, and what can be the possible solution for this:

我正在使用 ejb-2 我得到以下异常。有人可以告诉我这是什么意思,以及可能的解决方案是什么:

Error (fatal): EJB Exception: ; nested exception is:
javax.ejb.TransactionRolledbackLocalException: Error committing transaction:; nested exception is:
weblogic.transaction.internal.AppSetRollbackOnlyException

错误(致命):EJB 异常:;嵌套异常是:
javax.ejb.TransactionRolledbackLocalException:提交事务时出错:;嵌套异常是:
weblogic.transaction.internal.AppSetRollbackOnlyException

回答by Donato Szilagyi

Try to find out what the real exception is. To do this, transform your ejb to use bean managed transaction. Then you can commit manually and can catch the exception the commit throws.

试着找出真正的例外是什么。为此,请将您的 ejb 转换为使用 bean 管理的事务。然后您可以手动提交并捕获提交抛出的异常。

WebLogic likes to hide exceptions thrown in commit phase when using container managed transaction. Usually the reason is a database constraint what is not known by the EJB tier, eg. a function-based unique index in Oracle.

WebLogic 在使用容器管理事务时喜欢隐藏提交阶段抛出的异常。通常原因是 EJB 层不知道的数据库约束,例如。Oracle 中基于函数的唯一索引。

回答by ayortanli

You should flush the changes to the database then ejb will probably show you the real exception. If not works, put flush to the points that seem to be possible cause of the exception. By this way you can guaranteed to find real position and also real cause of the exception.

您应该将更改刷新到数据库,然后 ejb 可能会向您显示真正的异常。如果不起作用,请刷新似乎可能导致异常的点。通过这种方式,您可以保证找到真正的位置以及异常的真正原因。

回答by A_proud_indian

I was also facing the same problem. I just want to share my experience with you all. It is right that the actual exception is not mentioned in this aforesaid exception. To reveal that exception I have used wlspy.jartool. Using this tool I got the inner sql activity in configured log file. Due to which I got the hidded sql constraint exception. Steps to Configure: 1) Add wlspy.jar in your weblogic server classpath. 2) Add configurations related to wlspy in database source.

我也面临同样的问题。我只是想和大家分享我的经验。在上述例外中没有提到实际例外是正确的。为了揭示该异常,我使用了wlspy.jar工具。使用此工具,我在配置的日志文件中获得了内部 sql 活动。因此,我得到了隐藏的 sql 约束异常。配置步骤: 1) 在您的 weblogic 服务器类路径中添加 wlspy.jar。2)在数据库源中添加wlspy相关的配置。

For example:

例如:

jdbc:bea:DB2://db2host:50000;spyAttributes=(log=(file)/opt/bea/logs/mySpy.log;timestamp=yes)

jdbc:bea:DB2://db2host:50000;spyAttributes=(log=(file)/opt/bea/logs/mySpy.log;timestamp=yes)

After that restart your weblogic server and do the activity. You will get database related logs in mySoy.log file. In my case I got the actual constraint exception.

之后重新启动您的 weblogic 服务器并执行活动。您将在 mySoy.log 文件中获得与数据库相关的日志。就我而言,我得到了实际的约束异常。

Go through this link: http://docs.oracle.com/cd/E21764_01/web.1111/e13753/spy.htm#JDBCD469

通过此链接:http: //docs.oracle.com/cd/E21764_01/web.1111/e13753/spy.htm#JDBCD469