问题
I use oracle 11.x, Spring boot 2.x , maven, weblogic – as external server.
- The entry point
@SpringBootConfiguration
@SpringBootApplication
public class WebSpringBootJarApplication
extends SpringBootServletInitializer
implements WebApplicationInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger( WebSpringBootJarApplication.class );
public static void main(String[] args) {
SpringApplication.run(WebSpringBootJarApplication.class, args);
LOGGER.info("Start an application...");
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
LOGGER.info("There is building the web application!");
return builder.sources(WebSpringBootJarApplication.class);
}
}
application.properties
spring.main.banner-mode=off
####################################################
# Oracle 11x
####################################################
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
logging.config=classpath:logger/logback-spring.xml
logging.file.dir=logs
logging.file.name.var=log.log
logging.file.archive.format.name=program_.%d{dd-MM-yyyy}.log
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true" scanPeriod="10 seconds" >
<include resource="logger/settingslogger/defaults-spring.xml"/>
<springProfile name="default">
<include resource="logger/consolelogger/console-appender-spring.xml"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
<springProfile name="production">
<include resource="logger/productionappenderlogger/logback-appender-production-spring.xml"/>
<logger name="org.springframework.web" level="DEBUG">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.data" level="DEBUG">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="weblogic.war.spring.boot" level="ERROR">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="weblogic.war.spring.boot" level="INFO">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="weblogic.war.spring.boot" level="INFO">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="weblogic.war.spring.boot" level="INFO">
<appender-ref ref="FILE-ROLLING"/>
</logger>
</springProfile>
</configuration>
When the postman is sending a request, that I have the response:
{ "timestamp": "2020-03-05T13:47:37.128+0000", "status": 500, "error": "Internal Server Error", "message": "JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is weblogic.transaction.RollbackException: setRollbackOnly called on transaction", "path": "/sat/api/save/differentTypes" }
And the console I see this:
05-03-2020 16:47:37.095 DEBUG 10500 [ (self-tuning)'] m.m.a.RequestResponseBodyMethodProcessor : Read "application/json;charset=UTF-8" to [weblogic.war.spring.boot.service.dto.differenttypes.DifferentTypesDtoEightProduce@f8bde55f Different (truncated)...] 05-03-2020 16:47:37.124 DEBUG 10500 [ (self-tuning)'] o.s.web.servlet.DispatcherServlet : Failed to complete request: org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is weblogic.transaction.RollbackException: setRollbackOnly called on transaction
Update
I tried to add follows tthe settings into logback-spring.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true" scanPeriod="10 seconds">
<include resource="logger/default/defaults-spring.xml"/>
<springProfile name="default">
<include resource="logger/console/console-appender-spring.xml"/>
<root level="TRACE">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
<springProfile name="dev">
<include resource="logger/console/console-appender-spring.xml"/>
<include resource="logger/production/logback-appender-production-spring.xml"/>
<!-- <root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>-->
<logger name="ch.qos.logback" level="DEBUG" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.web" level="DEBUG" additivity="true" >
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.data" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.data.jpa" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.hibernate" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.hibernate.validator" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.hibernate.sql" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.hibernate.type.descriptor.sql" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.jdbc.core.PreparedStatementCreator" level="TRACE" additivity="true">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="com.dao" level="INFO">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="com.service" level="INFO">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="com.web" level="INFO">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="ch.qos.logback" level="DEBUG">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.springframework.web" level="DEBUG" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.springframework.data" level="DEBUG" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.springframework.data.jpa" level="DEBUG" additivity="false" >
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.hibernate" level="DEBUG" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.hibernate.validator" level="WARN">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.hibernate.sql" level="DEBUG" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.hibernate.type.descriptor.sql" level="TRACE" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="org.springframework.jdbc.core.PreparedStatementCreator" level="TRACE" additivity="false">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="com.dao" level="INFO">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="com.service" level="INFO">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<logger name="com.web" level="INFO">
<appender-ref ref="FILE-ROLLING"/>
</logger>
<!-- http://logback.qos.ch/manual/configuration.html-->
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
</springProfile>
</configuration>
spring.profiles.active=dev
logging.config=classpath:logger/logback-spring.xml
logging.file.dir=logs_gov
logging.file.name.var=gov_new.log
logging.file.archive.format.name=gov_new.%d{dd-MM-yyyy}.log
- weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
https://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
https://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
<wls:context-root>sun</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>ch.qos.logback.*</wls:package-name>
<wls:package-name>org.slf4j.*</wls:package-name>
</wls:prefer-application-packages>
<!-- <wls:prefer-application-resources>
<wls:resource-name>ch/qos/logback/core/ConsoleAppender.class</wls:resource-name>
<wls:resource-name>ch/qos/logback/core/rolling/RollingFileAppender.class</wls:resource-name>
<wls:resource-name>ch/qos/logback/classic/encoder/PatternLayoutEncoder.class</wls:resource-name>
<wls:resource-name>ch/qos/logback/core/rolling/TimeBasedRollingPolicy.class</wls:resource-name>
</wls:prefer-application-resources>-->
</wls:container-descriptor>
</wls:weblogic-web-app>
I don't see errors in console when occur an transaction rollback.
12-03-2020 14:21:25.756 INFO 7216 c.w.r.s.d.DifferentTypesSaveRest : Writed object : DifferentTypesDtoEightProduce{status=OPEN} DifferentTypesDtoFour{year=2020, car=true} com.service.dto.differenttypes.DifferentTypesDtoEightProduce@64e50443 DifferentTypesDtoTwo{id=135, name='fan5'} DifferentTypesDtoSix{cost=10.0, character=W} 12-03-2020 14:21:25.759 DEBUG 7216 m.m.a.RequestResponseBodyMethodProcessor : Using 'application/json', given [/] and supported [application/json] 12-03-2020 14:21:25.774 DEBUG 7216
m.m.a.RequestResponseBodyMethodProcessor : Writing [DifferentTypesDtoEightProduce{status=OPEN} DifferentTypesDtoFour{year=2020, car=true} com.service.dt (truncated)...] 12-03-2020 14:21:25.781 DEBUG 7216
o.s.web.servlet.DispatcherServlet : Completed 200 OK 12-03-2020 14:23:13.766 DEBUG 7216 o.s.web.servlet.DispatcherServlet : POST "/sun/api/save/differentTypes", parameters={} 12-03-2020 14:23:13.766 DEBUG 7216 s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.web.rest.save.differentTypes.DifferentTypesSaveRest#setDifferentTypes(DifferentTypesDtoEightProduce) 12-03-2020 14:23:13.767 DEBUG 7216
m.m.a.RequestResponseBodyMethodProcessor : Read "application/json;charset=UTF-8" to [DifferentTypesDtoEightProduce{status=OPEN} DifferentTypesDtoFour{year=2020, car=true} com.service.dt (truncated)...] 12-03-2020 14:23:13.804 DEBUG 7216
o.s.web.servlet.DispatcherServlet : Failed to complete request: org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is weblogic.transaction.RollbackException: setRollbackOnly called on transaction 12-03-2020 14:23:13.811 DEBUG 7216
o.s.web.servlet.DispatcherServlet : "FORWARD" dispatch for POST "/sun/error", parameters={} 12-03-2020 14:23:13.812 DEBUG 7216
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest) 12-03-2020 14:23:13.820 DEBUG 7216
o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [/] and supported [application/json, application/+json, application/json, application/+json] 12-03-2020 14:23:13.820 DEBUG 7216 o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [{timestamp=Thu Mar 12 14:23:13 MSK 2020, status=500, error=Internal Server Error, message=JTA transa (truncated)...] 12-03-2020 14:23:13.824 DEBUG 7216 o.s.web.servlet.DispatcherServlet : Exiting from "FORWARD" dispatch, status 500
How can I configure detailed error output into a console and a file, when the errors appears during work Hibernate, when Hibernate is throwing exceptions with database…
How can also I configure when values that should be written to the database are already inserted in instance PreparedStatement