Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log4J JDBC appender org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.class provides no rollback if there is an sqlException #3185

Open
arpithav620 opened this issue Nov 7, 2024 · 0 comments
Labels
appenders:JDBC Issue concerning the JDBC appender waiting-for-maintainer

Comments

@arpithav620
Copy link

arpithav620 commented Nov 7, 2024

Description

Hi,
I am using log4J to log all errors in my application to database . I have configured exact column mappings in log4j.xml and whenever logger.error() is invoked it will log the errors to DB. I am using connection factory class which returns datasource to establish the connection and insert the errors to DB. Whenever there is an exception while inserting to DB my next log events are not logged and I see below exception in the sysout file.

Version: [Log4j 2.17.2]

JDK: [JDK 1.8]

Websphere application server 8.5.5.18

postgresql-9.4-1202.jdbc41.jar

Below is my XML configuration

log4J xml configuration.txt
LogsStoreConnectionFactory.txt
log4J commitAndClose()

Logs

J2CA0081E: Method cleanup failed while trying to execute method cleanup on ManagedConnection WSRdbManagedConnectionImpl@46a686c2 from resource jdbc/logspgSQL. Caught exception: com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data Store Adapter. See original exception message: Cannot call 'cleanup' on a ManagedConnection while it is still in a transaction..
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.(DataStoreAdapterException.java:256)
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.(DataStoreAdapterException.java:205)
at com.ibm.ws.rsadapter.AdapterUtil.createDataStoreAdapterException(AdapterUtil.java:442)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions(WSRdbManagedConnectionImpl.java:4743)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanup(WSRdbManagedConnectionImpl.java:4176)
at com.ibm.ejs.j2c.MCWrapper.cleanup(MCWrapper.java:1846)
at com.ibm.ejs.j2c.FreePool.returnToFreePool(FreePool.java:554)
at com.ibm.ejs.j2c.PoolManager.release(PoolManager.java:2928)
at com.ibm.ejs.j2c.MCWrapper.releaseToPoolManager(MCWrapper.java:2639)
at com.ibm.ejs.j2c.ConnectionEventListener.connectionClosed(ConnectionEventListener.java:395)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processConnectionClosedEvent(WSRdbManagedConnectionImpl.java:2010)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.closeWrapper(WSJdbcConnection.java:983)
at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:242)
at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:195)
at org.apache.logging.log4j.core.util.Closer.close(Closer.java:43)
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.closeResources(JdbcDatabaseManager.java:535)
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:566)
at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.flush(AbstractDatabaseManager.java:192)
at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.buffer(AbstractDatabaseManager.java:159)
at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.write(AbstractDatabaseManager.java:296)
at org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender.append(AbstractDatabaseAppender.java:110)
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:161)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:134)
at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:125)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:89)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:675)
at org.apache.logging.log4j.core.async.AsyncLoggerConfig.callAppenders(AsyncLoggerConfig.java:144)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:633)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:616)
at org.apache.logging.log4j.core.async.AsyncLoggerConfig.log(AsyncLoggerConfig.java:138)
at org.apache.logging.log4j.core.async.AsyncLoggerConfig.logToAsyncLoggerConfigsOnCurrentThread(AsyncLoggerConfig.java:186)
at org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor$Log4jEventWrapperHandler.onEvent(AsyncLoggerConfigDisruptor.java:112)
at org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor$Log4jEventWrapperHandler.onEvent(AsyncLoggerConfigDisruptor.java:98)
at com.lmax.disruptor.BatchEventProcessor.processEvents(BatchEventProcessor.java:168)
at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:125)
at java.lang.Thread.run(Thread.java:825)

@ppkarwasz ppkarwasz added the appenders:JDBC Issue concerning the JDBC appender label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appenders:JDBC Issue concerning the JDBC appender waiting-for-maintainer
Projects
None yet
Development

No branches or pull requests

2 participants