简体   繁体   中英

Spring boot application deployment fails with JNDI warnings when custom logback-spring.xml included

Spring boot application deployment fails with JNDI debub messages when custom logback settings file (logback-spring.xml) included. This happens only in linux environment and in windows environment application runs without any issue even though same debug message are shown.

Few of long list of debug messages

15:33:22.537 [https-jsse-nio-8443-exec-70] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/logging.exception-conversion-word]
15:33:22.540 [https-jsse-nio-8443-exec-70] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/logging.exception-conversion-word] not found - trying original name [logging.exception-conversion-word]. javax.naming.NameNotFoundException: Name [logging.exception-conversion-word] is not bound in this Context. Unable to find [logging.exception-conversion-word].
15:33:22.540 [https-jsse-nio-8443-exec-70] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [logging.exception-conversion-word]
15:33:22.540 [https-jsse-nio-8443-exec-70] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [logging.exception-conversion-word] threw NamingException with message: Name [logging.exception-conversion-word] is not bound in this Context. Unable to find [logging.exception-conversion-word].. Returning null.

POM file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

<artifactId>licenserequestsimulator</artifactId>
<packaging>war</packaging>
<name>License Request Simulator</name>
<description>License Request Simulator</description>
<url>https://pronto.net/</url>
<version>1.0</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.3.RELEASE</version>
</parent>

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-freemarker</artifactId>            
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>com.ibm.informix</groupId>
        <artifactId>jdbc</artifactId>
        <version>4.10.7.20160517</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.42</version>
    </dependency>

    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.7</version>
    </dependency>   
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

logback-spring.xml

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>

<include resource="org/springframework/boot/logging/logback/base.xml"/>
<property name="DEV_HOME" value="/logs/prontolicensing/" />
<property resource="application.properties" />

<!-- Datasource connection example -->
<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
    <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
        <dataSource class="org.apache.tomcat.jdbc.pool.DataSource">
            <driverClassName>${spring.datasource.driver-class-name}</driverClassName>
            <url>${spring.datasource.url}</url>
            <username>${spring.datasource.username}</username>
            <password>${spring.datasource.password}</password>
        </dataSource>
    </connectionSource>
</appender>
<!-- Datasource connection example ends-->

<!--File appender-->
<appender name="fileAppender"
          class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/pronto-licensing-file.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} - %msg%n
        </Pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        rollover daily 
        <fileNamePattern>
            ${DEV_HOME}/archived/pronto-licensing-file.%d{yyyy-MM-dd}.%i.log
        </fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>10MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>
</appender>

<logger name="fileLogger" level="INFO" additivity="false">
    <appender-ref ref="fileAppender" />
</logger>
<!--File appender ends-->

<root level="ERROR">
    <appender-ref ref="DB" />
</root>

What should I do to overcome this?

Try just change logback-spring.xml to logback.xml .

In that case Spring Boot don't configure logback with its templates ( like mentioned here ).

All messages about JNDI names should just gone - like logback autoconfiguraton features in Spring Boot.

I had the same problem and if you change logback-spring.xml to logback.xml this traces will dissapear from the console, BUT they will be written in the ".log" file. I dont know exactly how to delete them from both console and log file, but at least you can choose

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM