我正在尝试使用DataSource在WebSphere Liberty Profile中的Java EE应用程序中使用log4j2 JDBCAppender。我想知道,如果我有配置错误,因为我在日志中看到以下错误:
Caused by: java.sql.SQLException: DSRA9350E: Operation Connection.commit is not allowed during a global transaction.
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:778)
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:139)
... 84 more
2014-11-20 20:23:33,663 ERROR An exception occurred processing Appender OneViewPrimaryLogDatabase org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to commit transaction logging event or flushing buffer.
这是我的log4j配置数据:
<JDBC name="OneViewPrimaryLogDatabase" tableName="IONEVIEW.LOG">
<DataSource jndiName="jdbc/OneViewPrimaryLogDataSource" />
<Column name="LOGDATE" isEventTimestamp="true" />
<Column name="LOGGER" pattern="%logger" isUnicode="false" />
<Column name="LOGLEVEL" pattern="%level" isUnicode="false" />
<Column name="MESSAGE" pattern="%message" isUnicode="false" />
</JDBC>
这是来自WLP的我的DataSource配置:
<jdbcDriver id="Db2V105JdbcDriver">
<library id="Db2V105JdbcDriverJars">
<fileset dir="C:/IBM/DB2V105/java" includes="db2jcc4.jar db2jcc_license_cisuz.jar"/>
</library>
</jdbcDriver>
<dataSource id="OneViewPrimaryLogDataSource" jdbcDriverRef="Db2V105JdbcDriver" jndiName="jdbc/OneViewPrimaryLogDataSource" type="javax.sql.ConnectionPoolDataSource">
<properties.db2.jcc databaseName="OVHALOGP" password="XXXX" portNumber="60008" user="myuser" serverName="myserver"/>
</dataSource>
有人看到我在这里做错了吗?
答案 0 :(得分:2)
Remko's hint可能是正确的,因为Liberty可以将transactional="false"
添加到server.xml
中的数据源定义:
<dataSource transactional="false" ...>
答案 1 :(得分:0)
有人通过在WAS中选中“非交易数据源”解决了这个问题:
你可以尝试一下吗?