javax.ejb.EJBTransactionRolledbackException - 获取原始的stacktrace

时间:2014-05-27 00:38:20

标签: java jpa transactions openjpa openejb

在我的网络应用程序中,我使用OpenJPA。有时当我进行数据库操作时,我得到了这个例外:

javax.servlet.ServletException: javax.el.ELException: javax.ejb.EJBTransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization

以root为例:

org.apache.geronimo.transaction.manager.SetRollbackOnlyException: setRollbackOnly() called.  See stacktrace for origin

问题是:如何获取在事务中引发的异常的堆栈跟踪?

我看这里

但我不明白。

我想每当我尝试将大文件(超过2MB)保存到数据库中的表时,我都会收到此异常。

1 个答案:

答案 0 :(得分:0)

我建议您在properties

中设置此persistece.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="laudoweb_pu">
        <jta-data-source>jdbc/integracaolaudoweb</jta-data-source>
        <class>com.xxx.xxxEntity</class>
        <properties>
            <property name="openjpa.jdbc.DBDictionary" value="oracle" />
            <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
            <property name="openjpa.AutoDetach" value="close" />
            <property name="openjpa.DetachState" value="loaded" />
            <property name="openjpa.DataCache" value="false" />
            <property name="openjpa.Optimistic" value="true" />
            <property name="openjpa.Multithreaded" value="true" />
            <property name="openjpa.TransactionMode" value="managed" />
            <property name="openjpa.ConnectionFactoryMode" value="managed" />
            <property name="openjpa.NontransactionalRead" value="true" />
            <property name="openjpa.RestoreState" value="all" />
            <property name="openjpa.ManagedRuntime" value="auto" />
        </properties>
    </persistence-unit>
</persistence>

此处为openjpa和其他logs的{​​{1}}文档。

http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_logging_openjpa.html

主要是此行对于日志跟踪非常重要:

properties