Link to home
Start Free TrialLog in
Avatar of MehtaJasmin
MehtaJasminFlag for United States of America

asked on

Enablin org.apache.commons.logging for Weblogic 10.3.6

In our enterprise, we're encountered the requirement to move out J2EE applications to Weblogic 10.3.6. Unfortunately, these applications are using several public libraries and tools that all use Apache Commons Logging (org.apach.commons.logging.*) in order to write their output to log files. Since deploying the applications to Weblogic, the libraries that use this logging are no longer outputting information. We've tried adding the jar file to the claspath, but that didn't work. I've read that the Apache commons logging is not included by default with the Weblogic server release, but that it can be enabled. The only question is, how?

How do we enable the use of Appache commons logging (org.apache.commons.logging.*) for use in Weblogic 10.3.6?

Thanks in advance.
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Hi Mehta,

This can be because of many different reasons, are you seeing any errors in the weblogic console logs? Verify that first.

You should follow the guidelines from this link: http://docs.oracle.com/cd/E11036_01/wlevs20/config_server/logging.html you can override logfactory to ensure the logging the logging is working.

-Dorg.apache.commons.logging.LogFactory= weblogic.logging.commons.LogFactoryImpl
Avatar of MehtaJasmin

ASKER

I'd seen a similar piece of documentation, that was structured a bit differently. The ones I'd seen before made it seem like in addition to setting the property above, you also had to set it in all your code, which wasn't an option because we're using a lot of public libraries as well that aren't customized in our application. However, this document makes it sound like setting it in a server-wide property works as well.

The followup question, since I'm not as knowledgable when it comes to the server setup is, where do you set the '-Dorg.apache.commons.logging.LogFactory= weblogic.logging.commons.LogFactoryImpl' property? Is it in the weblogic startup script? Or is it in some other xml or properties file?
Is it in the weblogic startup script?

Yes it's a Java argument you can set it JAVA_OPTIONS:

In startweblogic.cmd (on Windows system) or startweblogic.sh, JAVA_OPTIONS was set like that:
SET JAVA_OPTIONS=-Dorg.apache.commons.logging.LogFactory= weblogic.logging.commons.LogFactoryImpl

You will find already some of such options in that script. Thanks.
The DBA's tried adding it to the export JAVA_OPTIONS set in the startup script, and they got the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: weblogic.logging.commons.LogFactoryImpl
Caused by: java.lang.ClassNotFoundException: weblogic.logging.commons.LogFactoryImpl
        at java.net.URLClassLoader.findClass(URLClassLoader.java:457)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:676)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:642)
Could not find the main class: weblogic.logging.commons.LogFactoryImpl.  Program will exit.
The previous exception resolved by adding the "com.bea.core.weblogic.commons.logging_1.3.0.0.jar" file in classpath. Now our start script has lines:

export CLASSPATH=$CLASSPATH/u2/app/oracle/product/OFM11g/oracle_common/modules/org.apache.commons.logging_1.0.4.jar:/u2/app/oracle/product/OFM11g/modules/com.bea.core.weblogic.commons.logging_1.3.0.0.jar

export JAVA_OPTIONS="-Dweblogic.security.SSL.protocolVersion=TLS1 -Dorg.apache.commons.logging.LogFactory=weblogic.logging.commons.LogFactoryImpl"

Open in new window


But that give errors:

<Mar 22, 2017 12:20:48 PM EDT> <Error> <HTTP> <BEA-101216> <Servlet: "ResourceServlet" failed to preload on startup in Web application: "console".
java.lang.ExceptionInInitializerError
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:221)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:166)
      at java.lang.J9VMInternals.newInstanceImpl(Native Method)
      at java.lang.Class.newInstance(Class.java:1688)
      at weblogic.servlet.internal.WebComponentContributor.getNewInstance(WebComponentContributor.java:225)
      Truncated. see log file for complete stacktrace
Caused By: org.apache.commons.logging.LogConfigurationException: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: weblogic.logging.commons.LogFactoryImpl incompatible with org.apache.commons.logging.LogFactory)
      at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:574)
      at java.security.AccessController.doPrivileged(AccessController.java:359)
      at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:517)
      at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:254)
      at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
      Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassCastException: weblogic.logging.commons.LogFactoryImpl incompatible with org.apache.commons.logging.LogFactory
      at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:569)
      at java.security.AccessController.doPrivileged(AccessController.java:359)
      at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:517)
      at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:254)
      at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
      Truncated. see log file for complete stacktrace

Can you please advise?

Thanks
Can someone please provide help for my question? Thanks
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.