Log4j2, IBM WAS spring project. Not able to see the logs on the console - spring

While migrating from log 1.x to log2.17.1. I am facing issue in printing of the logs over the console.
I changed my web app version from 2.4 to 3.0 and remove all the other config for log4j 1.x. I kept only the new config:-
<context-param>
<param-name>log4jContextName</param-name>
<param-value>myApplication</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>/WEB-INF/config/log4j2.xml</param-value>
</context-param>
in the web.xml
I am using slf4j methods and classes in the code. I kept all the necessary jars related to the the slf4j and log4j in pom.xml.
Application started with below messages while initialisation of the log. But after that no logs from the application in console.
Application startup logs:-
[1/3/22 9:53:22:314 MST] 000000ec SystemOut O WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
[1/3/22 9:53:22:315 MST] 000000ec SystemOut O WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.
[1/3/22 9:53:23:581 MST] 000000ec CompositionUn A WSVR0193I: Composition unit WebSphere:cuname=my-application in BLA WebSphere:blaname=my-application stopped.
[1/3/22 9:53:25:277 MST] 000000ec AdminHelper A ADMN1008I: An attempt is made to start the my-application application. (User ID = defaultWIMFileBasedRealm/server:server1212Cell_server1212Node_server1212sbs1Server)
[1/3/22 9:53:25:291 MST] 000000ec CompositionUn A WSVR0190I: Starting composition unit WebSphere:cuname=my-application in BLA WebSphere:blaname=my-application.
[1/3/22 9:53:25:318 MST] 000000ec ApplicationMg A WSVR0200I: Starting application: my-application
[1/3/22 9:53:25:318 MST] 000000ec ApplicationMg A WSVR0204I: Application: my-application Application build level: Unknown
[1/3/22 9:53:28:830 MST] 000000ec webapp I com.ibm.ws.webcontainer.webapp.WebGroupImpl WebGroup SRVE0169I: Loading Web Module: vr-cornerstone.
[1/3/22 9:53:28:893 MST] 000000ec WASSessionCor I SessionContextRegistry getSessionContext SESN0176I: Will create a new session context for application key vhost_sbs1/voice/cornerstone
[1/3/22 9:53:28:894 MST] 000000ec WASSession I MTMStore setDRSMode SESN0188I: Memory To Memory mode for application vhost_sbs1/voice/cornerstone is BOTH
[1/3/22 9:53:28:894 MST] 000000ec WASSession I MTMStore setDRSMode SESN0188I: Memory To Memory mode for application vhost_sbs1my-application is BOTH
[1/3/22 9:53:31:001 MST] 000000ec SystemOut O 2022-01-03 09:53:31,000 Default : 2 DEBUG Starting LoggerContext[name=myApplication] from configuration at file:/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml
[1/3/22 9:53:31:002 MST] 000000ec SystemOut O 2022-01-03 09:53:31,002 Default : 2 DEBUG Starting LoggerContext[name=myApplication, org.apache.logging.log4j.core.LoggerContext#10e67293] with configuration XmlConfiguration[location=/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml]...
[1/3/22 9:53:31:003 MST] 000000ec SystemOut O 2022-01-03 09:53:31,003 Default : 2 DEBUG Shutdown hook enabled. Registering a new one.
[1/3/22 9:53:31:005 MST] 000000ec SystemOut O 2022-01-03 09:53:31,005 Default : 2 DEBUG Apache Log4j Core 2.17.1 initializing configuration XmlConfiguration[location=/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml]
[1/3/22 9:53:31:243 MST] 000000ec SystemOut O 2022-01-03 09:53:31,243 Default : 2 DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
[1/3/22 9:53:31:251 MST] 000000ec SystemOut O 2022-01-03 09:53:31,251 Default : 2 DEBUG PluginManager 'TypeConverter' found 26 plugins
[1/3/22 9:53:31:259 MST] 000000ec SystemOut O 2022-01-03 09:53:31,259 Default : 2 DEBUG PatternLayout$Builder(pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n", PatternSelector=null, Configuration(/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
[1/3/22 9:53:31:260 MST] 000000ec SystemOut O 2022-01-03 09:53:31,260 Default : 2 DEBUG PluginManager 'Converter' found 45 plugins
[1/3/22 9:53:31:261 MST] 000000ec SystemOut O 2022-01-03 09:53:31,261 Default : 2 DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
[1/3/22 9:53:31:269 MST] 000000ec SystemOut O 2022-01-03 09:53:31,269 Default : 2 DEBUG ConsoleAppender$Builder(target="SYSTEM_OUT", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n), name="Console", Configuration(/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml), Filter=null, ={})
[1/3/22 9:53:31:272 MST] 000000ec SystemOut O 2022-01-03 09:53:31,272 Default : 2 DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false
[1/3/22 9:53:31:272 MST] 000000ec SystemOut O 2022-01-03 09:53:31,272 Default : 2 DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
[1/3/22 9:53:31:273 MST] 000000ec SystemOut O 2022-01-03 09:53:31,273 Default : 2 DEBUG createAppenders(={Console})
[1/3/22 9:53:31:273 MST] 000000ec SystemOut O 2022-01-03 09:53:31,273 Default : 2 DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
[1/3/22 9:53:31:276 MST] 000000ec SystemOut O 2022-01-03 09:53:31,276 Default : 2 DEBUG createAppenderRef(ref="Console", level="null", Filter=null)
[1/3/22 9:53:31:276 MST] 000000ec SystemOut O 2022-01-03 09:53:31,276 Default : 2 DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
[1/3/22 9:53:31:277 MST] 000000ec SystemOut O 2022-01-03 09:53:31,277 Default : 2 DEBUG createLogger(additivity="null", level="DEBUG", includeLocation="null", ={Console}, ={}, Configuration(/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml), Filter=null)
[1/3/22 9:53:31:280 MST] 000000ec SystemOut O 2022-01-03 09:53:31,280 Default : 2 DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
[1/3/22 9:53:31:281 MST] 000000ec SystemOut O 2022-01-03 09:53:31,281 Default : 2 DEBUG createLoggers(={root})
[1/3/22 9:53:31:282 MST] 000000ec SystemOut O 2022-01-03 09:53:31,282 Default : 2 DEBUG Configuration XmlConfiguration[location=/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml] initialized
[1/3/22 9:53:31:282 MST] 000000ec SystemOut O 2022-01-03 09:53:31,282 Default : 2 DEBUG Starting configuration XmlConfiguration[location=/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml]
[1/3/22 9:53:31:283 MST] 000000ec SystemOut O 2022-01-03 09:53:31,283 Default : 2 DEBUG Started configuration XmlConfiguration[location=/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml] OK.
[1/3/22 9:53:31:283 MST] 000000ec SystemOut O 2022-01-03 09:53:31,283 Default : 2 DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
[1/3/22 9:53:31:284 MST] 000000ec SystemOut O 2022-01-03 09:53:31,284 Default : 2 DEBUG OutputStream closed
[1/3/22 9:53:31:284 MST] 000000ec SystemOut O 2022-01-03 09:53:31,284 Default : 2 DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
[1/3/22 9:53:31:285 MST] 000000ec SystemOut O 2022-01-03 09:53:31,284 Default : 2 DEBUG Appender DefaultConsole-1 stopped with status true
[1/3/22 9:53:31:285 MST] 000000ec SystemOut O 2022-01-03 09:53:31,285 Default : 2 DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration#14d1de6e OK
[1/3/22 9:53:31:288 MST] 000000ec SystemOut O 2022-01-03 09:53:31,288 Default : 2 DEBUG Registering MBean org.apache.logging.log4j2:type=myApplication
[1/3/22 9:53:31:291 MST] 000000ec SystemOut O 2022-01-03 09:53:31,291 Default : 2 DEBUG Registering MBean org.apache.logging.log4j2:type=myApplication,component=StatusLogger
[1/3/22 9:53:31:292 MST] 000000ec SystemOut O 2022-01-03 09:53:31,292 Default : 2 DEBUG Registering MBean org.apache.logging.log4j2:type=myApplication,component=ContextSelector
[1/3/22 9:53:31:294 MST] 000000ec SystemOut O 2022-01-03 09:53:31,294 Default : 2 DEBUG Registering MBean org.apache.logging.log4j2:type=myApplication,component=Loggers,name=
[1/3/22 9:53:31:296 MST] 000000ec SystemOut O 2022-01-03 09:53:31,296 Default : 2 DEBUG Registering MBean org.apache.logging.log4j2:type=myApplication,component=Appenders,name=Console
[1/3/22 9:53:31:299 MST] 000000ec SystemOut O 2022-01-03 09:53:31,299 Default : 2 DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
[1/3/22 9:53:31:300 MST] 000000ec SystemOut O 2022-01-03 09:53:31,300 Default : 2 DEBUG LoggerContext[name=myApplication, org.apache.logging.log4j.core.LoggerContext#10e67293] started OK with configuration XmlConfiguration[location=/my-application.ear/my-application-service.war/WEB-INF/config/log4j2.xml].
[1/3/22 9:53:31:301 MST] 000000ec webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [my-application#my-application-service.war]:.No Spring WebApplicationInitializer types detected on classpath
[1/3/22 9:53:31:308 MST] 000000ec SystemOut O 2022-01-03 09:53:31,308 Default : 2 DEBUG Log4jServletContextListener ensuring that Log4j starts up properly.
[1/3/22 9:53:31:316 MST] 000000ec webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [my-application#my-application-service.war]:.Initializing Spring root WebApplicationContext
[1/3/22 9:53:32:011 MST] 000000ec webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [my-application#my-application-service.war]:.Initializing Spring FrameworkServlet 'rest'
[1/3/22 9:53:33:235 MST] 000000ec ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [my-application] [/voice/cornerstone] [rest]: Initialization successful.
[1/3/22 9:53:33:261 MST] 000000ec ApplicationMg A WSVR0221I: Application started: my-application
[1/3/22 9:53:33:261 MST] 000000ec CompositionUn A WSVR0191I: Composition unit WebSphere:cuname=my-application in BLA WebSphere:blaname=my-application started.
[1/3/22 9:53:45:967 MST] 000001d9 SystemOut O 2022-01-03 09:53:45,967 WebContainer : 2 DEBUG Log4jServletFilter initialized.
Log4j2.xml file:-
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="com.myapp" level="debug">
<AppenderRef ref="Console"/>
</Logger>
<Root level="debug">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
Please let me what I am doing wrong here.
Pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version> </dependency> <dependency> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> -->
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-web -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>

Related

Spring Session JDBC Problem adding in my project

currently I have a project with Spring MVC which already interact with Database(MariaDB) and I would like to try the spring-session-jdbc. I found the documentation in this spring-session , I do what the documentation is says but the app don't start when I deploy it in the Tomcat. And the log in the Tomcat is not very helpful. Here is my code:
#Configuration
#PropertySource("classpath:application.properties")
#EnableTransactionManagement
#EnableJdbcHttpSession
#ComponentScans(value = {#ComponentScan("com.havistudio.web.testapp.dao"), #ComponentScan("com.havistudio.web.testapp.service")})
public class AppConfig {
#Autowired
private Environment environment;
#Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setPackagesToScan(new String[] { "com.havistudio.web.testapp.model" });
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}
#Bean
public DataSource dataSource() {
HikariDataSource dataSource = new HikariDataSource();
dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
dataSource.setJdbcUrl(environment.getRequiredProperty("jdbc.url"));
dataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
dataSource.setConnectionTimeout(Long.parseLong(environment.getRequiredProperty("spring.datasource.hikari.connection-timeout")));
dataSource.setMinimumIdle(Integer.parseInt(environment.getRequiredProperty("spring.datasource.hikari.minimum-idle")));
dataSource.setMaximumPoolSize(Integer.parseInt(environment.getRequiredProperty("spring.datasource.hikari.maximum-pool-size")));
dataSource.setIdleTimeout(Long.parseLong(environment.getRequiredProperty("spring.datasource.hikari.idle-timeout")));
dataSource.setMaxLifetime(Long.parseLong(environment.getRequiredProperty("spring.datasource.hikari.max-lifetime")));
dataSource.setAutoCommit(Boolean.parseBoolean(environment.getRequiredProperty("spring.datasource.hikari.auto-commit")));
return dataSource;
}
private Properties hibernateProperties() {
Properties properties = new Properties();
properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
return properties;
}
#Bean
#Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(s);
return txManager;
}
#Bean
public JavaMailSender getMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
//Using gmail
mailSender.setHost("mail.test.com");
mailSender.setPort(587);
mailSender.setUsername("info#test.com");
mailSender.setPassword("dsffsdfsdfsd");
Properties javaMailProperties = new Properties();
javaMailProperties.put("mail.smtp.auth", "true");
javaMailProperties.put("mail.smtp.starttls.enable", "true");
javaMailProperties.put("mail.smtp.ssl.trust", "mail.test.com");
//javaMailProperties.put("mail.debug", "true");//Prints out everything on screen
mailSender.setJavaMailProperties(javaMailProperties);
return mailSender;
}
}
My initializer:
public class MyInitializer extends AbstractHttpSessionApplicationInitializer {
public MyInitializer() {
super(AppConfig.class);
}
}
My application.properties
spring.session.store-type=jdbc
pom.xml
<!-- Spring Session JDBC -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
<version>2.5.1</version>
</dependency>
My log:
21-Aug-2021 18:23:45.336 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/TzokerStatisticsApp]
21-Aug-2021 18:23:45.694 INFO [localhost-startStop-3] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp.war]
2021-08-21 18:23:50,242 localhost-startStop-3 DEBUG Apache Log4j Core 2.14.1 initializing configuration XmlConfiguration[location=C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml]
2021-08-21 18:23:50,246 localhost-startStop-3 DEBUG Installed 1 script engine
Warning: Nashorn engine is planned to be removed from a future JDK release
2021-08-21 18:23:50,252 localhost-startStop-3 DEBUG Oracle Nashorn version: 11.0.11, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory
2021-08-21 18:23:50,253 localhost-startStop-3 DEBUG PluginManager 'Core' found 122 plugins
2021-08-21 18:23:50,253 localhost-startStop-3 DEBUG PluginManager 'Level' found 0 plugins
2021-08-21 18:23:50,257 localhost-startStop-3 DEBUG PluginManager 'Lookup' found 16 plugins
2021-08-21 18:23:50,260 localhost-startStop-3 DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2021-08-21 18:23:50,273 localhost-startStop-3 DEBUG PluginManager 'TypeConverter' found 26 plugins
2021-08-21 18:23:50,282 localhost-startStop-3 DEBUG PatternLayout$Builder(pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n", PatternSelector=null, Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2021-08-21 18:23:50,283 localhost-startStop-3 DEBUG PluginManager 'Converter' found 44 plugins
2021-08-21 18:23:50,284 localhost-startStop-3 DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
2021-08-21 18:23:50,294 localhost-startStop-3 DEBUG ConsoleAppender$Builder(target="SYSTEM_OUT", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n), name="LogToConsole", Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml), Filter=null, ={})
2021-08-21 18:23:50,296 localhost-startStop-3 DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false
2021-08-21 18:23:50,296 localhost-startStop-3 DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2021-08-21 18:23:50,297 localhost-startStop-3 DEBUG PatternLayout$Builder(pattern="%d %p %c{1.} [%t] %m%n", PatternSelector=null, Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2021-08-21 18:23:50,323 localhost-startStop-3 DEBUG Building Plugin[name=TimeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy].
2021-08-21 18:23:50,327 localhost-startStop-3 DEBUG TimeBasedTriggeringPolicy$Builder(interval="null", modulate="null", maxRandomDelay="null")
2021-08-21 18:23:50,327 localhost-startStop-3 DEBUG Building Plugin[name=SizeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy].
2021-08-21 18:23:50,333 localhost-startStop-3 DEBUG createPolicy(size="1 MB")
2021-08-21 18:23:50,335 localhost-startStop-3 DEBUG Building Plugin[name=Policies, class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy].
2021-08-21 18:23:50,336 localhost-startStop-3 DEBUG createPolicy(={TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=1048576)})
2021-08-21 18:23:50,336 localhost-startStop-3 DEBUG Building Plugin[name=DefaultRolloverStrategy, class=org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy].
2021-08-21 18:23:50,339 localhost-startStop-3 DEBUG DefaultRolloverStrategy$Builder(max="10", min="null", fileIndex="null", compressionLevel="null", ={}, stopCustomActionsOnError="null", tempCompressedFilePattern="null", Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml))
2021-08-21 18:23:50,341 localhost-startStop-3 DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender].
2021-08-21 18:23:50,344 localhost-startStop-3 DEBUG RollingRandomAccessFileAppender$Builder(fileName="logs/TzokerStatisticsApp/app.log", filePattern="logs/TzokerStatisticsApp/${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz", append="null", Policies(CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=1048576)])), DefaultRolloverStrategy(DefaultRolloverStrategy(min=1, max=10, useMax=true)), advertise="null", advertiseURI="null", filePermissions="null", fileOwner="null", fileGroup="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d %p %c{1.} [%t] %m%n), name="LogToRollingRandomAccessFile", Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml), Filter=null, ={})
2021-08-21 18:23:50,354 localhost-startStop-3 DEBUG Starting RollingRandomAccessFileManager logs/TzokerStatisticsApp/app.log
2021-08-21 18:23:50,357 localhost-startStop-3 DEBUG PluginManager 'FileConverter' found 2 plugins
2021-08-21 18:23:50,365 localhost-startStop-3 DEBUG Setting prev file time to 2021-08-16T19:38:00.766+0300
2021-08-21 18:23:50,365 localhost-startStop-3 DEBUG Initializing triggering policy CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=1048576)])
2021-08-21 18:23:50,366 localhost-startStop-3 DEBUG Initializing triggering policy TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false)
2021-08-21 18:23:50,367 localhost-startStop-3 DEBUG Initializing triggering policy SizeBasedTriggeringPolicy(size=1048576)
2021-08-21 18:23:50,367 localhost-startStop-3 DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2021-08-21 18:23:50,368 localhost-startStop-3 DEBUG createAppenderRef(ref="LogToRollingRandomAccessFile", level="null", Filter=null)
2021-08-21 18:23:50,368 localhost-startStop-3 DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.AsyncAppender].
2021-08-21 18:23:50,370 localhost-startStop-3 DEBUG AsyncAppender$Builder(={LogToRollingRandomAccessFile}, errorRef="null", blocking="null", shutdownTimeout="null", bufferSize="null", name="Async", includeLocation="null", Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml), ignoreExceptions="null", BlockingQueueFactory=null, Filter=null, ={})
2021-08-21 18:23:50,371 localhost-startStop-3 DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2021-08-21 18:23:50,372 localhost-startStop-3 DEBUG createAppenders(={LogToConsole, LogToRollingRandomAccessFile, Async})
2021-08-21 18:23:50,373 localhost-startStop-3 DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2021-08-21 18:23:50,373 localhost-startStop-3 DEBUG createAppenderRef(ref="Async", level="null", Filter=null)
2021-08-21 18:23:50,373 localhost-startStop-3 DEBUG Building Plugin[name=logger, class=org.apache.logging.log4j.core.config.LoggerConfig].
2021-08-21 18:23:50,376 localhost-startStop-3 DEBUG createLogger(additivity="false", level="DEBUG", name="com.havistudio.web.testapp", includeLocation="null", ={Async}, ={}, Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml), Filter=null)
2021-08-21 18:23:50,382 localhost-startStop-3 DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2021-08-21 18:23:50,382 localhost-startStop-3 DEBUG createAppenderRef(ref="LogToConsole", level="null", Filter=null)
2021-08-21 18:23:50,383 localhost-startStop-3 DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2021-08-21 18:23:50,384 localhost-startStop-3 DEBUG createLogger(additivity="null", level="ERROR", includeLocation="null", ={LogToConsole}, ={}, Configuration(C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml), Filter=null)
2021-08-21 18:23:50,385 localhost-startStop-3 DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2021-08-21 18:23:50,386 localhost-startStop-3 DEBUG createLoggers(={com.havistudio.web.testapp.root})
2021-08-21 18:23:50,388 localhost-startStop-3 DEBUG Configuration XmlConfiguration[location=C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml] initialized
2021-08-21 18:23:50,388 localhost-startStop-3 DEBUG Starting configuration XmlConfiguration[location=C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml]
2021-08-21 18:23:50,395 localhost-startStop-3 DEBUG org.apache.logging.log4j.core.util.SystemClock supports precise timestamps.
2021-08-21 18:23:50,399 localhost-startStop-3 DEBUG Started configuration XmlConfiguration[location=C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml] OK.
2021-08-21 18:23:50,399 localhost-startStop-3 DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
2021-08-21 18:23:50,400 localhost-startStop-3 DEBUG OutputStream closed
2021-08-21 18:23:50,400 localhost-startStop-3 DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
2021-08-21 18:23:50,400 localhost-startStop-3 DEBUG Appender DefaultConsole-1 stopped with status true
2021-08-21 18:23:50,401 localhost-startStop-3 DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration#39d9ebd0 OK
2021-08-21 18:23:50,407 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b
2021-08-21 18:23:50,410 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b,component=StatusLogger
2021-08-21 18:23:50,412 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b,component=ContextSelector
2021-08-21 18:23:50,415 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b,component=Loggers,name=
2021-08-21 18:23:50,415 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b,component=Loggers,name=com.havistudio.web.testapp
2021-08-21 18:23:50,417 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b,component=Appenders,name=LogToRollingRandomAccessFile
2021-08-21 18:23:50,418 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b,component=Appenders,name=LogToConsole
2021-08-21 18:23:50,420 localhost-startStop-3 DEBUG Registering MBean org.apache.logging.log4j2:type=5a383f6b,component=AsyncAppenders,name=Async
2021-08-21 18:23:50,421 localhost-startStop-3 DEBUG Reconfiguration complete for context[name=5a383f6b] at URI C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp\WEB-INF\classes\log4j2.xml (org.apache.logging.log4j.core.LoggerContext#73aa23c5) with optional ClassLoader: null
2021-08-21 18:23:50,423 localhost-startStop-3 DEBUG Shutdown hook enabled. Registering a new one.
2021-08-21 18:23:50,425 localhost-startStop-3 DEBUG LoggerContext[name=5a383f6b, org.apache.logging.log4j.core.LoggerContext#73aa23c5] started OK.
21-Aug-2021 18:23:50.606 INFO [localhost-startStop-3] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[localhost-startStop-3] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Starting...
[localhost-startStop-3] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Start completed.
21-Aug-2021 18:23:51.592 SEVERE [localhost-startStop-3] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
21-Aug-2021 18:23:51.593 SEVERE [localhost-startStop-3] org.apache.catalina.core.StandardContext.startInternal Context [/TzokerStatisticsApp] startup failed due to previous errors
[localhost-startStop-3] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Shutdown initiated...
[localhost-startStop-3] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Shutdown completed.
21-Aug-2021 18:23:51.624 WARNING [localhost-startStop-3] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [TzokerStatisticsApp] registered the JDBC driver [org.mariadb.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
21-Aug-2021 18:23:51.624 WARNING [localhost-startStop-3] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [TzokerStatisticsApp] appears to have started a thread named [Log4j2-AsyncAppenderEventDispatcher-1-Async] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base#11.0.11/jdk.internal.misc.Unsafe.park(Native Method)
java.base#11.0.11/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
java.base#11.0.11/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
java.base#11.0.11/java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:417)
org.apache.logging.log4j.core.appender.AsyncAppenderEventDispatcher.dispatchAll(AsyncAppenderEventDispatcher.java:70)
org.apache.logging.log4j.core.appender.AsyncAppenderEventDispatcher.run(AsyncAppenderEventDispatcher.java:62)
21-Aug-2021 18:23:51.627 INFO [localhost-startStop-3] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [C:\Users\kostas\apache-tomcat-8.5.41\webapps\TzokerStatisticsApp.war] has finished in [5,933] ms
I am sure I am missing something here, but I don't know what is it.
Finally, I found what was wrong! I took a deeper look in the logs file and specifically in the localhost*.log file and I found this:
3 Spring WebApplicationInitializers detected on classpath
22-Aug-2021 11:15:52.337 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
22-Aug-2021 11:15:53.251 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:263)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4768)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:744)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:980)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1851)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Then I modify my MyInitializer class to this:
public class MyInitializer extends AbstractHttpSessionApplicationInitializer {
}
And immediately it worked like a charm!

SRVE0278E: Error while adding servlet mapping --> /*

I am trying to deploy my application on a local Websphere Application Server (Version "8.5.5.9") with Java 8
I always get this error:
[1/16/19 14:40:21:530 GMT] 000000c3 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [adminART_war#adminART.war]:.Initializing Spring FrameworkServlet 'adr'
[1/16/19 14:40:21:783 GMT] 000000c3 SystemOut O INFO SecurityNamespaceHandler -- -- --Spring Security 'config' module version is 4.0.1.RELEASE
[1/16/19 14:40:30:424 GMT] 000000c3 SystemOut O INFO GlobalMethodSecurityBeanDefinitionParser -- -- --Expressions were enabled for method security but no SecurityExpressionHandler was configured. All hasPermision() expressions will evaluate to false.
[1/16/19 14:41:42:690 GMT] 000000c3 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [adminART_war] [/ArtOSAdmin] [adr]: Initialization successful.
[1/16/19 14:41:42:691 GMT] 000000c3 webapp W com.ibm.ws.webcontainer.webapp.WebApp initializeStaticFileHandler SRVE0278E: Error while adding servlet mapping --> /*.
[1/16/19 14:41:42:697 GMT] 000000c3 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [adminART_war#adminART.war]:.Destroying Spring FrameworkServlet 'adr'
[1/16/19 14:41:42:721 GMT] 000000c3 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper doDestroy SRVE0253I: [adminART_war] [/ArtOSAdmin] [adr]: Destroy successful.
[1/16/19 14:41:42:724 GMT] 000000c3 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [adminART_war#adminART.war]:.Closing Spring root WebApplicationContext
[1/16/19 14:42:02:997 GMT] 000000c3 SystemOut O INFO EhCacheManagerFactoryBean -- -- --Shutting down EhCache CacheManager
[1/16/19 14:42:03:060 GMT] 000000c3 SystemOut O INFO LocalContainerEntityManagerFactoryBean -- -- --Closing JPA EntityManagerFactory for persistence unit 'default'
[1/16/19 14:42:03:066 GMT] 000000c3 webapp E com.ibm.ws.webcontainer.webapp.WebGroupImpl WebGroup SRVE0015E: Failure to initialize Web application adr Banque
[1/16/19 14:42:03:071 GMT] 000000c3 DeployedAppli W WSVR0206E: Module, adminART.war, of application, adminART_war.ear/deployments/adminART_war, failed to start
I've configured the file ibm-web-ext.xml under WEB-INF as described on some supports like that:
<!-- language: lang-xml -->
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<default-error-page uri="error.jsp"/>
<jsp-attribute name="useThreadTagPool" value="true" />
<jsp-attribute name="verbose" value="false" />
<jsp-attribute name="deprecation" value="false" />
<jsp-attribute name="reloadEnabled" value="true" />
<jsp-attribute name="reloadInterval" value="5" />
<jsp-attribute name="keepgenerated" value="true" />
<jsp-attribute name="trackDependencies" value="true" />
<reload-interval value="9"/>
<auto-encode-requests value="true"/>
<auto-encode-responses value="false"/>
<enable-directory-browsing value="false"/>
<enable-file-serving value="false"/>
<pre-compile-jsps value="false"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="true"/>
</web-ext>
This the mapping on my web.xml:
<!-- language: lang-xml -->
<!-- Spring MVC -->
<servlet>
<servlet-name>adr</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>adr</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Any help is highly appreciated.
Looking at this error, and at the corresponding code in WebApp, can you look see if there was an FFDC log produced at the same time as this warning? If I've found the correct code, there should be an FFDC which was also produced, and that would have additional details as to the exact error which occurred.
[1/16/19 14:41:42:691 GMT] 000000c3 webapp W
com.ibm.ws.webcontainer.webapp.WebApp initializeStaticFileHandler
SRVE0278E: Error while adding servlet mapping --> /*.
By default WebSphere will install a DefaultApplication EAR that will use the / context root. If you want to use this context root, you will next to remove the DefaultApplication from the server or change the context root for this application to something else.

spring boot 2 + log4j2 over slf4j not writing logs to file

In my application, I'm using spring boot 2.0.3 and have slf4j with log4j2 configured for logging.
However, I'm not able to get the setup write the logs to the file. I tried many ways but could not make it work. I don't understand what I'm missing here :/
My pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${spring.boot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring.boot.version}</version>
</dependency>
My log4j2.properties file
status = debug
name= properties_configuration
# Give directory path where log files should get stored
property.basePath = /A/B/c-web
# ConsoleAppender will print logs on console
appender.console.type = Console
appender.console.name = consoleLogger
appender.console.target = SYSTEM_OUT
appender.console.layout.type = PatternLayout
# Specify the pattern of the logs
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n
# RollingFileAppender will print logs in file which can be rotated based on time or size
appender.rolling.type = RollingFile
appender.rolling.name = fileLogger
appender.rolling.fileName= ${basePath}/c-web.log
appender.rolling.filePattern= ${basePath}/archive/c-web_%d{yyyyMMdd}.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n
appender.rolling.policies.type = Policies
# Rotate log file each day and keep 30 days worth
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.delete.type = Delete
appender.rolling.strategy.delete.basePath = ${basePath}/archive
appender.rolling.strategy.delete.maxDepth = 1
appender.rolling.strategy.delete.ifLastModified.type = IfLastModified
# Delete files older than 30 days
appender.rolling.strategy.delete.ifLastModified.age = 30d
# Mention package name here in place of example. Classes in this package or subpackages will use ConsoleAppender and RollingFileAppender for logging
logger.rolling.name = com.x
logger.rolling.level = debug
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = fileLogger
logger.rolling.appenderRef.console.ref = consoleLogger
# Configure root logger for logging error logs in classes which are in package other than above specified package
rootLogger.level = info
rootLogger.additivity = false
rootLogger.appenderRef.rolling.ref = fileLogger
rootLogger.appenderRef.console.ref = consoleLogger
Application log during bootup
2018-10-28 20:14:50,463 main DEBUG PluginManager 'Core' found 116 plugins
2018-10-28 20:14:50,463 main DEBUG PluginManager 'Level' found 0 plugins
2018-10-28 20:14:50,468 main DEBUG Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
2018-10-28 20:14:50,483 main DEBUG PluginManager 'TypeConverter' found 26 plugins
2018-10-28 20:14:50,493 main DEBUG createProperty(name="basePath", value="/A/B/c-web")
2018-10-28 20:14:50,493 main DEBUG Building Plugin[name=properties, class=org.apache.logging.log4j.core.config.PropertiesPlugin].
2018-10-28 20:14:50,498 main DEBUG configureSubstitutor(={basePath=/A/B/c-web}, Configuration(properties_configuration))
2018-10-28 20:14:50,499 main DEBUG PluginManager 'Lookup' found 13 plugins
2018-10-28 20:14:50,499 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2018-10-28 20:14:50,499 main DEBUG createAppenderRef(ref="consoleLogger", level="null", Filter=null)
2018-10-28 20:14:50,500 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2018-10-28 20:14:50,500 main DEBUG createAppenderRef(ref="fileLogger", level="null", Filter=null)
2018-10-28 20:14:50,500 main DEBUG Building Plugin[name=logger, class=org.apache.logging.log4j.core.config.LoggerConfig].
2018-10-28 20:14:50,504 main DEBUG createLogger(additivity="false", level="DEBUG", name="com.x", includeLocation="null", ={consoleLogger, fileLogger}, ={}, Configuration(properties_configuration), Filter=null)
2018-10-28 20:14:50,506 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2018-10-28 20:14:50,507 main DEBUG createAppenderRef(ref="consoleLogger", level="null", Filter=null)
2018-10-28 20:14:50,507 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2018-10-28 20:14:50,507 main DEBUG createAppenderRef(ref="fileLogger", level="null", Filter=null)
2018-10-28 20:14:50,508 main DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2018-10-28 20:14:50,509 main DEBUG createLogger(additivity="null", level="INFO", includeLocation="null", ={consoleLogger, fileLogger}, ={}, Configuration(properties_configuration), Filter=null)
2018-10-28 20:14:50,509 main DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2018-10-28 20:14:50,510 main DEBUG createLoggers(={com.x, root})
2018-10-28 20:14:50,510 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2018-10-28 20:14:50,515 main DEBUG PatternLayout$Builder(pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n", PatternSelector=null, Configuration(properties_configuration), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2018-10-28 20:14:50,515 main DEBUG PluginManager 'Converter' found 47 plugins
2018-10-28 20:14:50,528 main DEBUG Building Plugin[name=IfLastModified, class=org.apache.logging.log4j.core.appender.rolling.action.IfLastModified].
2018-10-28 20:14:50,529 main DEBUG createAgeCondition(age="P30D", ={})
2018-10-28 20:14:50,530 main DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
2018-10-28 20:14:50,531 main DEBUG Building Plugin[name=Delete, class=org.apache.logging.log4j.core.appender.rolling.action.DeleteAction].
2018-10-28 20:14:50,532 main DEBUG createDeleteAction(basePath="/A/B/c-web/archive", followLinks="false", maxDepth="1", testMode="false", PathSorter=null, ={IfLastModified(age=P30D)}, ScriptCondition=null, Configuration(properties_configuration))
2018-10-28 20:14:50,532 main DEBUG Building Plugin[name=DefaultRolloverStrategy, class=org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy].
2018-10-28 20:14:50,542 main DEBUG DefaultRolloverStrategy$Builder(max="null", min="null", fileIndex="null", compressionLevel="null", ={DeleteAction[basePath=/A/B/c-web/archive, options=[], maxDepth=1, conditions=[IfLastModified(age=P30D)]]}, stopCustomActionsOnError="null", tempCompressedFilePattern="null", Configuration(properties_configuration))
2018-10-28 20:14:50,542 main DEBUG Building Plugin[name=TimeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy].
2018-10-28 20:14:50,544 main DEBUG TimeBasedTriggeringPolicy$Builder(interval="1", modulate="true", maxRandomDelay="null")
2018-10-28 20:14:50,544 main DEBUG Building Plugin[name=Policies, class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy].
2018-10-28 20:14:50,545 main DEBUG createPolicy(={TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)})
2018-10-28 20:14:50,545 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.RollingFileAppender].
2018-10-28 20:14:50,549 main DEBUG RollingFileAppender$Builder(fileName="/A/B/c-web/c-web.log", filePattern="/A/B/c-web/archive/c-web_%d{yyyyMMdd}.log.gz", append="null", locking="null", Policies(CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)])), DefaultRolloverStrategy(DefaultRolloverStrategy(min=1, max=7, useMax=true)), advertise="null", advertiseUri="null", createOnDemand="null", filePermissions="null", fileOwner="null", fileGroup="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n), name="fileLogger", Configuration(properties_configuration), Filter=null)
2018-10-28 20:14:50,554 main DEBUG Starting RollingFileManager /A/B/c-web/c-web.log
2018-10-28 20:14:50,556 main DEBUG PluginManager 'FileConverter' found 2 plugins
2018-10-28 20:14:50,557 main DEBUG Setting prev file time to 2018-10-28T19:16:05.000+0530
2018-10-28 20:14:50,559 main DEBUG Initializing triggering policy CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)])
2018-10-28 20:14:50,560 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2018-10-28 20:14:50,561 main DEBUG PatternLayout$Builder(pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n", PatternSelector=null, Configuration(properties_configuration), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
2018-10-28 20:14:50,561 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
2018-10-28 20:14:50,563 main DEBUG ConsoleAppender$Builder(target="SYSTEM_OUT", follow="null", direct="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout(%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n), name="consoleLogger", Configuration(properties_configuration), Filter=null)
2018-10-28 20:14:50,564 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false
2018-10-28 20:14:50,565 main DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2018-10-28 20:14:50,565 main DEBUG createAppenders(={fileLogger, consoleLogger})
2018-10-28 20:14:50,566 main DEBUG Configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#23cd925 initialized
2018-10-28 20:14:50,566 main DEBUG Starting configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#23cd925
2018-10-28 20:14:50,567 main DEBUG Started configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration#23cd925 OK.
2018-10-28 20:14:50,567 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
2018-10-28 20:14:50,568 main DEBUG Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
2018-10-28 20:14:50,568 main DEBUG Appender DefaultConsole-1 stopped with status true
2018-10-28 20:14:50,568 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration#699259d8 OK
2018-10-28 20:14:50,611 main DEBUG Registering MBean org.apache.logging.log4j2:type=6be184cd
2018-10-28 20:14:50,613 main DEBUG Registering MBean org.apache.logging.log4j2:type=6be184cd,component=StatusLogger
2018-10-28 20:14:50,615 main DEBUG Registering MBean org.apache.logging.log4j2:type=6be184cd,component=ContextSelector
2018-10-28 20:14:50,618 main DEBUG Registering MBean org.apache.logging.log4j2:type=6be184cd,component=Loggers,name=
2018-10-28 20:14:50,619 main DEBUG Registering MBean org.apache.logging.log4j2:type=6be184cd,component=Loggers,name=com.x
2018-10-28 20:14:50,620 main DEBUG Registering MBean org.apache.logging.log4j2:type=6be184cd,component=Appenders,name=fileLogger
2018-10-28 20:14:50,621 main DEBUG Registering MBean org.apache.logging.log4j2:type=6be184cd,component=Appenders,name=consoleLogger
2018-10-28 20:14:50,623 main DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
2018-10-28 20:14:50,623 main DEBUG Reconfiguration complete for context[name=6be184cd] at URI <project-path>/target/classes/log4j2.properties (org.apache.logging.log4j.core.LoggerContext#ac76de5) with optional ClassLoader: null
2018-10-28 20:14:50,623 main DEBUG Shutdown hook enabled. Registering a new one.
2018-10-28 20:14:50,624 main DEBUG LoggerContext[name=6be184cd, org.apache.logging.log4j.core.LoggerContext#ac76de5] started OK.
2018-10-28 20:14:50,971 main DEBUG Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory#7ae5dec6
2018-10-28 20:14:50,974 main INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.
Please let me know if you need any other information.
appreciate your help. Thanks in advance.
It turned out to be pretty simple.Spring boot was not loading the log4j2 configuration file properly during the Application starup.I just had to explicitly mention it.
I was able to get it working by adding
logging.config=src/main/resources/log4j2.properties
to my application.properties file.

batch admin console - DispatcherServlet using InternalResourceViewResolver instead of FreeMarkerViewResolver

I have an issue with integrating the spring batch admin console into my application.
The good news is that when i go to http://mymachine.com:8080/ReportingManager/batch/configuration I can get to the admin console.
But when I go to http://mymachine.com:8080/ReportingManager/batch/job-configuration i get a 404 and an error saying that /batch/jobs can't be found.
I've just gone through the exercise of comparing the difference in output of org.springframework.web logs between my application logs and the spring-batch-admin-sample application which I know is working.
After looking at the logs it looks like the URL mappings can be found for the spring batch admin console but the DispatcherServlet is trying to use InternalResourceViewResolver instead of the FreeMarkerViewResolver
My application logs below show the wrong ViewResolver is being used for /ReportingManager/batch/jobs...
2014-05-27 20:16:22,770 DEBUG [DispatcherServlet] - DispatcherServlet with name 'Batch Servlet' processing GET request for [/ReportingManager/batch/jobs]
2014-05-27 20:16:22,770 DEBUG [RequestMappingHandlerMapping] - Looking up handler method for path /jobs
2014-05-27 20:16:22,770 DEBUG [RequestMappingHandlerMapping] - Returning handler method [public void org.springframework.batch.admin.web.JobController.jobs(org.springframework.ui.ModelMap,int,int)]
2014-05-27 20:16:22,770 DEBUG [DispatcherServlet] - Last-Modified value for [/ReportingManager/batch/jobs] is: -1
2014-05-27 20:16:23,598 DEBUG [DispatcherServlet] - Rendering view [org.springframework.web.servlet.view.JstlView: name 'jobs'; URL [/WEB-INF/pages/jobs.jsp]] in DispatcherServlet with name 'Batch Servlet'
2014-05-27 20:16:23,598 DEBUG [JstlView] - Added model object 'endJob' of type [java.lang.Integer] to request in view with name 'jobs'
2014-05-27 20:16:23,598 DEBUG [JstlView] - Added model object 'jobs' of type [java.util.ArrayList] to request in view with name 'jobs'
2014-05-27 20:16:23,598 DEBUG [JstlView] - Added model object 'startJob' of type [java.lang.Integer] to request in view with name 'jobs'
2014-05-27 20:16:23,598 DEBUG [JstlView] - Added model object 'totalJobs' of type [java.lang.Integer] to request in view with name 'jobs'
2014-05-27 20:16:23,598 DEBUG [JstlView] - Added model object 'jobName' of type [java.lang.String] to request in view with name 'jobs'
2014-05-27 20:16:23,598 DEBUG [JstlView] - Forwarding to resource [/WEB-INF/pages/jobs.jsp] in InternalResourceView 'jobs'
2014-05-27 20:16:23,598 DEBUG [DispatcherServlet] - Successfully completed request
Whereas when I look at the longs for the spring-batch-admin-sample I can see that /spring_admin_console/jobs is using AjaxFreeMarkerView...
[5/27/14 19:57:13:962 EST] 00000023 SystemOut O 19:57:13,950 DEBUG WebContainer : 0 servlet.DispatcherServlet:693 - DispatcherServlet with name 'Batch Servlet' processing GET request for [/s
pring_admin_console/jobs]
[5/27/14 19:57:13:978 EST] 00000023 SystemOut O 19:57:13,965 DEBUG WebContainer : 0 annotation.DefaultAnnotationHandlerMapping:221 - Mapping [/jobs] to HandlerExecutionChain with handler [or
g.springframework.batch.admin.web.JobController#52e052e0] and 3 interceptors
[5/27/14 19:57:14:000 EST] 00000023 SystemOut O 19:57:13,988 DEBUG WebContainer : 0 servlet.DispatcherServlet:769 - Last-Modified value for [/spring_admin_console/jobs] is: -1
[5/27/14 19:57:14:045 EST] 00000023 SystemOut O 19:57:14,031 DEBUG WebContainer : 0 support.HandlerMethodInvoker:155 - Invoking model attribute method: public java.lang.String org.spring
framework.batch.admin.web.JobController.getJobName(javax.servlet.http.HttpServletRequest)
[5/27/14 19:57:14:091 EST] 00000023 SystemOut O 19:57:14,078 DEBUG WebContainer : 0 support.HandlerMethodInvoker:173 - Invoking request handler method: public void org.springframework.batch.admin.web.JobController.jobs(org.springframework.ui.ModelMap,int,int)
[5/27/14 19:57:14:125 EST] 00000023 SystemOut O 19:57:14,113 DEBUG WebContainer : 0 servlet.DispatcherServlet:1045 - Rendering view org.springframework.batch.admin.web.freemarker.AjaxFreeMarkerView: name 'jobs'; URL [/layouts/html/standard.ftl]] in DispatcherServlet with name 'Batch Servlet'
[5/27/14 19:57:14:144 EST] 00000023 SystemOut O 19:57:14,130 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'springMacroRequestContext' of type [org.springframework.web.servlet.support.RequestContext] to request in view with name 'jobs'
[5/27/14 19:57:14:158 EST] 00000023 SystemOut O 19:57:14,144 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'startJob' of type [java.lang.Integer] to request i
n view with name 'jobs'
[5/27/14 19:57:14:172 EST] 00000023 SystemOut O 19:57:14,159 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'totalJobs' of type [java.lang.Integer] to request
in view with name 'jobs'
[5/27/14 19:57:14:186 EST] 00000023 SystemOut O 19:57:14,172 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'servletPath' of type [java.lang.String] to request
in view with name 'jobs'
[5/27/14 19:57:14:200 EST] 00000023 SystemOut O 19:57:14,186 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'jobName' of type [java.lang.String] to request in
view with name 'jobs'
[5/27/14 19:57:14:214 EST] 00000023 SystemOut O 19:57:14,200 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'jobs' of type [java.util.ArrayList] to request in
view with name 'jobs'
[5/27/14 19:57:14:228 EST] 00000023 SystemOut O 19:57:14,214 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'titleText' of type [java.lang.String] to request i
n view with name 'jobs'
[5/27/14 19:57:14:242 EST] 00000023 SystemOut O 19:57:14,228 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'titleCode' of type [java.lang.String] to request i
n view with name 'jobs'
[5/27/14 19:57:14:255 EST] 00000023 SystemOut O 19:57:14,242 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'endJob' of type [java.lang.Integer] to request in
view with name 'jobs'
[5/27/14 19:57:14:269 EST] 00000023 SystemOut O 19:57:14,256 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:328 - Added model object 'body' of type [java.lang.String] to request in vie
w with name 'jobs'
[5/27/14 19:57:14:287 EST] 00000023 SystemOut O 19:57:14,274 DEBUG WebContainer : 0 freemarker.AjaxFreeMarkerView:279 - Rendering FreeMarker template [/layouts/html/standard.ftl] in FreeMark
erView 'jobs'
[5/27/14 19:57:14:909 EST] 00000023 SystemOut O 19:57:14,895 DEBUG WebContainer : 0 servlet.DispatcherServlet:674 - Successfully completed request
I've spent a while trying to find out what is happening and am not sure. I suspect maybe I am doing something wrong in my web.xml. Maybe relating to the order of the servlets.
I am going to post an excerpt from my web.xml in the hopes that someone will see something I am doing wrong.
Thanks in advance for having a look at this for me.
I've put my web.xml here.
http://pastebin.com/eBkHMe8g
In your web project make sure you have this folder structure: WEB-INF\classes\META-INF\spring\batch\override. And under this folder create a new .xml file. Name it whatever name you want. The content of the file should be something like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch" />
</bean>
</beans>
The value for the servletPath needs to match your servlet-mapping in your web.xml. I used /batch because this is what you have in yours.
More about this here. Also, it does help to have a look at the Spring Batch Admin source code. In that resources-context.xml you can see that a certain SPeL expression is used for various servletPath resources: <prop key="servletPath">#{resourceService.servletPath}</prop>. You need to search for the bean called resourceService, have a look at its source code and from there you can establish what property to change for DefaultResourceService in your custom .xml file.
LATER EDIT: As a general suggestion, your mvc-dispatcher DispatcherServlet is picking up automatically and by default the file located at /WEB-INF/mvc-dispatcher-servlet.xml. You'll have the beans under mvc-dispatcher-servlet.xml being picked up and loaded twice in two different app contexts because you have this file specified as one of the contextConfigLocation values. There is a hierarchy of contexts there, root one (defined by contextConfigLocation) being the parent. The idea is to place beans that are non-web (or that are to be used by web) in the root context and the web to be able to "use" these beans. Other way around doesn't quite make sense, because a DAO or Service class doesn't need access to web.

MyBatis-Spring setup not using transactions

I have a web application set up with MyBatis and Spring, but it doesn't seem to be using any transactions. Here's the configuration:
applicationContext.xml:
<tx:annotation-driven />
<!-- <tx:jta-transaction-manager /> --> <!-- using WebSphere 7 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/my_datasource" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="WEB-INF/mybatis-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="testDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.lmig.TestDAO" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
Sample bean method with transaction definition:
#Transactional(propagation = Propagation.REQUIRED)
public void testDelete() {
testDAO.firstDelete(); //always successful
testDAO.secondDelete(); //always throws SQLServerException
}
TestDAO:
public interface TestDAO {
public void firstDelete();
public void secondDelete();
}
Server debug log:
[11/17/11 16:42:07:998 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Creating SqlSession with JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection#34ba34ba]
[11/17/11 16:42:07:999 PST] 0000002b SystemOut O DEBUG [java.sql.Connection] ooo Connection Opened
[11/17/11 16:42:08:001 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection#34ba34ba] will be managed by Spring
[11/17/11 16:42:08:005 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession#74247424]
[11/17/11 16:42:08:025 PST] 0000002b SystemOut O DEBUG [java.sql.PreparedStatement] ==> Executing: delete from test1
[11/17/11 16:42:08:025 PST] 0000002b SystemOut O DEBUG [java.sql.PreparedStatement] ==> Parameters:
[11/17/11 16:42:08:097 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession#74247424]
[11/17/11 16:42:08:099 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession#74247424]
[11/17/11 16:42:08:123 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession#74247424]
[11/17/11 16:42:08:136 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Creating SqlSession with JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection#17351735]
[11/17/11 16:42:08:137 PST] 0000002b SystemOut O DEBUG [java.sql.Connection] ooo Connection Opened
[11/17/11 16:42:08:138 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection#17351735] will be managed by Spring
[11/17/11 16:42:08:139 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession#1d871d87]
[11/17/11 16:42:08:145 PST] 0000002b SystemOut O DEBUG [java.sql.PreparedStatement] ==> Executing: delete from test2
[11/17/11 16:42:08:146 PST] 0000002b SystemOut O DEBUG [java.sql.PreparedStatement] ==> Parameters:
[11/17/11 16:42:08:490 PST] 0000002b XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
[11/17/11 16:42:08:554 PST] 0000002b SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFactory <init> SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
[11/17/11 16:42:08:560 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession#1d871d87]
[11/17/11 16:42:08:597 PST] 0000002b SystemOut O DEBUG [org.mybatis.spring.SqlSessionUtils] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession#1d871d87]
...SQLServerException follows...
Since secondDelete() throws an exception, the entire transaction would be expected to roll back. However, this isn't the case, and the firstDelete() is still committed. I've tried all combinations of the transaction manager config (Spring-managed, app server-managed, both) but I keep getting the same results. Any idea what I'm doing wrong?
I'm using Mybatis 3, Spring 3 on WebSphere 7 with SQL Server 2005 as the DB.
I figured this out: my testDelete() method wasn't a Spring-managed bean, so it wasn't participating in Spring-managed transactions. I changed my configuration to this, and now it's working.

Resources