WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  LOG4J DISABLING SCAN @WEBSERVICES

    Posted Tue December 14, 2021 02:26 PM
    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.

    ------------------------------
    Daniel JANS
    CogitoSum
    Laval
    (514) 236-3699
    ------------------------------


  • 2.  RE: LOG4J DISABLING SCAN @WEBSERVICES

    Posted Wed December 15, 2021 02:54 PM
    Edited by Yee-Kang Chang Wed December 15, 2021 02:54 PM
    Hi Daniel,

    As Tom noted here, consider removing the JAX-RS dependency from your application and use the one provided by WebSphere.

    Alternately, to use (or bring) your own custom JAX-RS implementation, disable what WebSphere provides by following the instruction at https://www.ibm.com/docs/en/was/8.5.5?topic=applications-disabling-jax-rs-runtime-environment.

    Thanks.

    ------------------------------
    Yee-Kang Chang
    IBM
    ------------------------------