jeudi 21 décembre 2017

Spring logback Document root element must match DOCTYPE root

I'm trying to use logback with a web application, but I have the following error displayed by spring at startup :

ERROR : Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; 
nested exception is java.util.InvalidPropertiesFormatException: 
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 52; 
Document root element "configuration", must match DOCTYPE root "null".

It is a spring application and here is some parts of the configuration.

In my application context, I define this :

<bean id="logbackConfigFile" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/config/logbackConfigFile"/>
</bean>

<bean id="propertiesConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            ...
            <ref bean="logbackConfigFile"/>
        </list>
    </property>
</bean>

The linked config descriptor looks like :

<?xml version="1.0" encoding="UTF-8"?>
<Context unpackWAR  = "false">
    ...
    <Environment name="config/logbackConfigFile" type="java.lang.String"
     value="http://file:/C:\somedirectory\logback.xml" />
</Context>

And the logback.xml looks like :

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">

    <property name="LOG_HOME" value=".\\logs"/>

    <appender name="someRollingFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_HOME}/msg.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>5MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <maxHistory>15</maxHistory>
        </rollingPolicy>

        <encoder>
            <charset>UTF-8</charset>
            <pattern>%d %-5level %-15logger{15} - %msg - %class{1}.%method %line%n</pattern>
        </encoder>
    </appender>

    ...

    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>OFF</level>
        </filter>

        <encoder>
            <charset>UTF-8</charset>
            <pattern>%d %-5level %-15logger{15} - %msg - %class{1}.%method %line%n</pattern>
        </encoder>
    </appender>

   ...

    <logger name="something" level="info">
        <appender-ref ref="someRollingFileAppender"/>
        <appender-ref ref="aggregatedRollingFileAppender"/>
    </logger>

    <root level="off">
        <appender-ref ref="stdout"/>
    </root>
</configuration>

Everything seems fine, I already use such configuration in another web app without any problem, and I therefore doesn't understand at all what my problem is (I understand that it wants a dtd, but I don't understand why).

Has anyone an idea to help me ?

Thank you,

Seb




Aucun commentaire:

Enregistrer un commentaire