简体   繁体   中英

Log4j disabling scan @webservices

We are trying to user log4j2 ( moving from log4j1 ) but have an issue probably related to the classpath but I couldN,t fix it after multiple tries

We are using a separate module (NbfgLogging) that use a java class to configure LOG4J. The configuration works without an issue but,for some reason, it disable the scan of the @webservice scan. Looking at the console of WAS, the services are not anymore registered COMMONS-LOGGING.PROPERTIES

priority=1
    org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
    #org.apache.commons.logging.Log=org.apache.logging.log4j.Logger
    org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
    #org.apache.commons.logging.Log=java.util.logging.Logger

DEPENDENCIES IN THE SEPARATE MODULE FILE ( NbfgLogging )

<dependencies>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-jcl</artifactId>
        <version>${log4j.version}</version>         
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>${log4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${log4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>${log4j.version}</version>
    </dependency>       
    <dependency>
        <groupId>org.owasp.encoder</groupId>
        <artifactId>encoder</artifactId>
        <version>1.2.3</version>
    </dependency>
</dependencies>

DEPENDENCIES IN THE WAR FILES ( that create the issue. No scan of the @webservices )

    <dependency>
        <groupId>com.nbfg.fw.foundation</groupId>
        <artifactId>NbfgLogging</artifactId>
        <version>3.0.0-SNAPSHOT</version>
    </dependency>
    

LOGS OF THE SERVER ( other lines

[12/14/21 13:13:50:512 EST] 00000177 AbstractInjec W CWNEN0070W: The javax.ws.rs.HeaderParam annotation class will not be recognized because it was loaded from the file:/C:/blp/IBM/WebSphere/wp_profile/installedApps/portail-devCell/PA_Xxxxx.ear/CP-3.4.4-SNAPSHOT.war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar location rather than from a product class loader. [12/14/21 13:13:50:513 EST] 00000177 AbstractInjec W CWNEN0070W: The javax.annotation.Resource annotation class will not be recognized because it was loaded from the file:/C:/blp/IBM/WebSphere/wp_profile/installedApps/portail-devCell/PA_Xxxxxx.ear/CP-3.4.4-SNAPSHOT.war/WEB-INF/lib/javax.annotation-api-1.2.jar location rather than from a product class loader.

I have tried the following that solve the issue of the scan of @webservice. But the looger is not working anymore. I have tried other exclusions... without any succes.

DEPENDENCIES IN THE WAR FILES ( with exclusion )

    <dependency>
        <groupId>com.nbfg.fw.foundation</groupId>
        <artifactId>NbfgLogging</artifactId>
        <version>3.0.0-SNAPSHOT</version>
        <exclusions>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
        

LOGS OF THE SERVER ( other lines are not included )

Caused by: org.apache.commons.logging.LogConfigurationException: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.

From the error message, it looks like the app located here: PA_Xxxxx.ear/CP-3.4.4-SNAPSHOT.war/ is packaging the JAX-RS 2.0 API here WEB-INF/lib/javax.ws.rs-api-2.0.1.jar the JAX-RS 2.0 API is provided by the WebSphere runtime, and this is causing a conflict. If your application contains JAX-RS code, then you can do one of two things: remove the JAX-RS dependencies from your application and rely on the WebSphere JAX-RS implementation, or if you'd like to use a third-party JAX-RS implementation then you can disable the JAX-RS runtime on Websphere following these directions: https://www.ibm.com/docs/en/was/8.5.5?topic=applications-disabling-jax-rs-runtime-environment

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