Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-461

(Android) ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0-beta9, 2.0-rc1
    • Fix Version/s: None
    • Component/s: log4j 1.2 emulation
    • Labels:
    • Environment:

      Android

      Description

      ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger

      Code:
      Logger LOG = LogManager.getLogger(MainActivity.class);
      LOG.error("Test Log4j2");

      <?xml version="1.0" encoding="UTF-8"?> 
      <Configuration> 
        <Appenders> 
          <Console name="STDOUT" target="SYSTEM_OUT"> 
            <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> 
          </Console> 
        </Appenders> 
        <Loggers> 
          <Logger name="hello" level="info"/> 
          <Root level="trace"> 
            <AppenderRef ref="STDOUT"/> 
          </Root> 
        </Loggers> 
      </Configuration>
      

        Issue Links

          Activity

          Hide
          remkop@yahoo.com Remko Popma added a comment -

          Have you tried configuring with log4j internal logging switched on?

          <Configuration status="debug">
          ...
          </Configuration>
          

          This will print any problems that log4j encounters during initialization to the console. Can you post the output of that here?

          Show
          remkop@yahoo.com Remko Popma added a comment - Have you tried configuring with log4j internal logging switched on? <Configuration status= "debug" > ... </Configuration> This will print any problems that log4j encounters during initialization to the console. Can you post the output of that here?
          Hide
          garydgregory Gary Gregory added a comment -

          Also, what is on your classpath?

          Show
          garydgregory Gary Gregory added a comment - Also, what is on your classpath?
          Hide
          gauravk Gaurav Kapoor added a comment -

          Gary Gregory log4j-api-2.0-beta9.jar & log4j-core-2.0-beta9.jar is there in the Build path as I'm creating an Android App.

          Show
          gauravk Gaurav Kapoor added a comment - Gary Gregory log4j-api-2.0-beta9.jar & log4j-core-2.0-beta9.jar is there in the Build path as I'm creating an Android App.
          Hide
          gauravk Gaurav Kapoor added a comment -

          Remko Popma 12-05 14:49:55.832: W/System.err(11650): ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger
          12-05 14:49:55.832: W/System.err(11650): ERROR MainActivity Test Log4j2

          Show
          gauravk Gaurav Kapoor added a comment - Remko Popma 12-05 14:49:55.832: W/System.err(11650): ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger 12-05 14:49:55.832: W/System.err(11650): ERROR MainActivity Test Log4j2
          Hide
          remkop@yahoo.com Remko Popma added a comment -

          Gaurav, the only way this error can occur is if the log4j-core-2.0-beta9.jar is not found in the classpath when your application executes.

          You mention that this jar is in your Build path. Do you mean your IDE's Build path?
          How do you run your Android App? Do you use an emulator? Can you print the value of system property "java.class.path" to the console when you start your app to ensure that it contains log4j-core-2.0-beta9.jar ?

          Show
          remkop@yahoo.com Remko Popma added a comment - Gaurav, the only way this error can occur is if the log4j-core-2.0-beta9.jar is not found in the classpath when your application executes. You mention that this jar is in your Build path. Do you mean your IDE's Build path? How do you run your Android App? Do you use an emulator? Can you print the value of system property "java.class.path" to the console when you start your app to ensure that it contains log4j-core-2.0-beta9.jar ?
          Hide
          gauravk Gaurav Kapoor added a comment -

          Remko Popma I guess Its not able to initialize the log4j2 properties. Can you please tell me how can i initialize it through code? I'm running the android app on android device. If you want android source code i have build i can share that with you. If its the class path then it will through you an exception that Class not found.

          Show
          gauravk Gaurav Kapoor added a comment - Remko Popma I guess Its not able to initialize the log4j2 properties. Can you please tell me how can i initialize it through code? I'm running the android app on android device. If you want android source code i have build i can share that with you. If its the class path then it will through you an exception that Class not found.
          Hide
          remkop@yahoo.com Remko Popma added a comment - - edited

          (I'm copying my last comment from LOG4J2-460 here. I will mark LOG4J2-460 as a duplicate as I think it is the same underlying issue.)

          This looks like a classpath issue. If both the core and the api jars are on the classpath, the LogManager class (which lives in the api jar) will load implementation classes from the core jar.
          If the LogManager returns a org.apache.logging.log4j.simple.SimpleLoggerContext instance it means that it has been unable to find the core implementation on the classpath.

          Specifically, it has been unable to find the /META-INF/log4j-provider.properties file that is in the core jar.

          Can you print the value of system property java.class.path to the console from your application to verify that the core jar is on the classpath?

          Show
          remkop@yahoo.com Remko Popma added a comment - - edited (I'm copying my last comment from LOG4J2-460 here. I will mark LOG4J2-460 as a duplicate as I think it is the same underlying issue.) This looks like a classpath issue. If both the core and the api jars are on the classpath, the LogManager class (which lives in the api jar) will load implementation classes from the core jar. If the LogManager returns a org.apache.logging.log4j.simple.SimpleLoggerContext instance it means that it has been unable to find the core implementation on the classpath. Specifically, it has been unable to find the /META-INF/log4j-provider.properties file that is in the core jar. Can you print the value of system property java.class.path to the console from your application to verify that the core jar is on the classpath?
          Hide
          remkop@yahoo.com Remko Popma added a comment -

          Hi Gaurav,
          Has this issue been resolved, or do you still need help with this?

          Show
          remkop@yahoo.com Remko Popma added a comment - Hi Gaurav, Has this issue been resolved, or do you still need help with this?
          Hide
          jvz Matt Sicker added a comment -

          This might be a class loader issue if Android does weird things like OSGi does. I'll take a look into the issue if that turns out to be the case.

          Show
          jvz Matt Sicker added a comment - This might be a class loader issue if Android does weird things like OSGi does. I'll take a look into the issue if that turns out to be the case.
          Hide
          ronko Ronko added a comment -

          Hi guys,
          I have been just tripping over this and the error in LOG4J2-460. I tried to use log4j2 in a project last year, was hoping would be more stable by now, but been at it hours, and cannot get log4j2 to work.

          I am using 2.0-rc1.

          Maven builds (while executing plugins) are failing with these mentioned errors. I really think this is still a significant issue. When trying to executing mvn command line to build a jar, these errors occur.

          >mvn clean package
          [INFO] Scanning for projects...
          [INFO]
          [INFO] ------------------------------------------------------------------------
          [INFO] Building Service Client 1.0-SNAPSHOT
          [INFO] ------------------------------------------------------------------------
          [INFO]
          [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ service-client —
          [INFO] Deleting /git/common/common/service-client/target
          [INFO]
          [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ service-client —
          [INFO] Using 'UTF-8' encoding to copy filtered resources.
          [INFO] Copying 3 resources
          [INFO]
          [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ service-client —
          [INFO] Changes detected - recompiling the module!
          [INFO] Compiling 15 source files to /git/common/common/service-client/target/classes
          ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger
          [INFO] ------------------------------------------------------------------------
          [INFO] BUILD FAILURE
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 1.305s
          [INFO] Finished at: Mon Mar 17 23:05:17 EDT 2014
          [INFO] Final Memory: 21M/310M
          [INFO] ------------------------------------------------------------------------
          [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project
          service-client: Fatal error compiling: java.lang.ExceptionInInitializerError:
          org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext -> [Help 1]
          [ERROR]
          [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
          [ERROR] Re-run Maven using the -X switch to enable full debug logging.
          [ERROR]
          [ERROR] For more information about the errors and possible solutions, please read the following articles:
          [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

          As you can see, it fails during the maven-compiler-plugin. I have tried adding the dependencies to the plugin, but no change.

          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.1</version>
          <configuration>
          <source>1.7</source>
          <target>1.7</target>
          </configuration>

          <dependencies>
          <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-api</artifactId>
          <version>2.0-rc1</version>
          </dependency>
          <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-1.2-api</artifactId>
          <version>2.0-rc1</version>
          </dependency>
          <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-core</artifactId>
          <version>2.0-rc1</version>
          </dependency>

          </dependencies>

          </plugin>

          Using java 1.7.0_51, OSX 10.9.2, Maven 3.1.1.

          Show
          ronko Ronko added a comment - Hi guys, I have been just tripping over this and the error in LOG4J2-460 . I tried to use log4j2 in a project last year, was hoping would be more stable by now, but been at it hours, and cannot get log4j2 to work. I am using 2.0-rc1. Maven builds (while executing plugins) are failing with these mentioned errors. I really think this is still a significant issue. When trying to executing mvn command line to build a jar, these errors occur. >mvn clean package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Service Client 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ service-client — [INFO] Deleting /git/common/common/service-client/target [INFO] [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ service-client — [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 3 resources [INFO] [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ service-client — [INFO] Changes detected - recompiling the module! [INFO] Compiling 15 source files to /git/common/common/service-client/target/classes ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.305s [INFO] Finished at: Mon Mar 17 23:05:17 EDT 2014 [INFO] Final Memory: 21M/310M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project service-client: Fatal error compiling: java.lang.ExceptionInInitializerError: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException As you can see, it fails during the maven-compiler-plugin. I have tried adding the dependencies to the plugin, but no change. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.0-rc1</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-1.2-api</artifactId> <version>2.0-rc1</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.0-rc1</version> </dependency> </dependencies> </plugin> Using java 1.7.0_51, OSX 10.9.2, Maven 3.1.1.
          Hide
          ronko Ronko added a comment -

          Hi guys, ok, have studied this immensely and the log4j2 source code, and believe I have found the issue with log4j2. LOG4J2-460 is directly related but I do not believe they are same issue. One causes the other.

          We are trying to use AWS SWF FLow Framework. SWF flow runs annotation processor, which uses Freemarker, which is coded to log4j 1.x API. With the log4j1.2 api from log4j2, that should theoretically be fine, but read on.

          TWO PROBLEMS
          1) Log 4j2 CORE (only, apis are fine) will not load under some circumstances (such as from maven plugin reactor).

          2) There are class cast code bugs in log4j2 code that are trying to cast wrong incompatible types. Details follow.

          First, on 1)...

          First issue: log4j2 core (ONLY) cannot be found or loaded under some circumstances. Log4j2 api and log4j1.2 api load fine under all circumstances I have found. I have gone through direct coding against core, forcing it via classpath, maven dependency, plugin dependency, (including system dependency), i have even written my own instance of org.apache.logging.log4j.spi.LoggerContextFactory, passed it in via system properly via properties-maven-plugin:set-system-properties:

          <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>properties-maven-plugin</artifactId>
          <version>1.0-alpha-2</version>
          <executions>
          <execution>
          <phase>initialize</phase>
          <goals>
          <goal>set-system-properties</goal>
          </goals>
          <configuration>
          <properties>
          <property>
          <name>log4j2.loggerContextFactory</name>
          <value>com.myco.common.commons.log.HackLogContextFactory</value>
          </property>
          </properties>
          </configuration>
          </execution>
          </executions>
          </plugin>

          Then I run maven-compiler-plugin (or maven processor plugin, both fail identically) WITH annotation processing. maven-compiler-plugin:compile then runs with proc jvm arg enabled. The APT annotation processor code in the AWS SKJ jar is found, and runs. It uses freemarker for templating.
          Log4j2-1.2 api IS found, tries to load. It cannot find core, both are right beside each other in dependencies. No power I have found can cause it to find it.

          There must be a class loader conflict or class loading issue. So the following outputs:

          >ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger

          NOW is bug #2! SimpleLogger, LoggerContext, and SimpleLoggerContext, possibly others are coded across packages to cast the wrong types, it seems. When log4j2-1.2 API tries to load logging, it itself throws a class cast at org.apache.log4j.Logger.getLogger(Logger.java:39):

          Caused by: java.lang.ExceptionInInitializerError
          at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
          at freemarker.template.ObjectWrapper.<clinit>(ObjectWrapper.java:81)
          at freemarker.core.Configurable.<init>(Configurable.java:161)
          at freemarker.template.Configuration.<init>(Configuration.java:195)
          at freemarker.template.Configuration.<clinit>(Configuration.java:172)
          at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.getConfiguration(ActivitiesCodeGenerator.java:49)
          at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.generate(ActivitiesCodeGenerator.java:97)
          at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.generateActivitiesClientInterface(ActivitiesCodeGenerator.java:85)
          at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.generateCode(ActivitiesCodeGenerator.java:79)
          at com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor.processActivities(AsynchronyDeciderAnnotationProcessor.java:120)
          at com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor.process(AsynchronyDeciderAnnotationProcessor.java:64)
          at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
          at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
          at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
          at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
          at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
          at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
          at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
          at com.sun.tools.javac.main.Main.compile(Main.java:439)
          ... 26 more
          Caused by: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
          at org.apache.log4j.Logger.getLogger(Logger.java:39)
          at freemarker.log._Log4JLoggerFactory.getLogger(_Log4JLoggerFactory.java:67)
          at freemarker.log.Logger.getLogger(Logger.java:284)
          at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:66)

          Here is why: SimpleLoggerContext (being run because CORE could not be found), extends:
          org.apache.logging.log4j.spi.LoggerContext
          But LOOK!
          The class that Logger.java:39 tries to cast it to is of type:
          org.apache.logging.log4j.core.LoggerContext

          !!!Unable to render embedded object: File (DIFFERENT) not found.!!
          Note the "spi" versus "core" in the package.

          This causes the stack dump above.

          THis same problem can be found elsewhere. When implemented my own HackLogContextFactory and passed it in via system prop, I got this:

          ERROR StatusLogger org.apache.logging.log4j.core.impl.Log4jContextFactory does not implement org.apache.logging.log4j.spi.LoggerContextFactory

          Again, types being cast to the wrong types.

          Show
          ronko Ronko added a comment - Hi guys, ok, have studied this immensely and the log4j2 source code, and believe I have found the issue with log4j2. LOG4J2-460 is directly related but I do not believe they are same issue. One causes the other. We are trying to use AWS SWF FLow Framework. SWF flow runs annotation processor, which uses Freemarker, which is coded to log4j 1.x API. With the log4j1.2 api from log4j2, that should theoretically be fine, but read on. TWO PROBLEMS 1) Log 4j2 CORE (only, apis are fine) will not load under some circumstances (such as from maven plugin reactor). 2) There are class cast code bugs in log4j2 code that are trying to cast wrong incompatible types. Details follow. First, on 1)... First issue: log4j2 core (ONLY) cannot be found or loaded under some circumstances. Log4j2 api and log4j1.2 api load fine under all circumstances I have found. I have gone through direct coding against core, forcing it via classpath, maven dependency, plugin dependency, (including system dependency), i have even written my own instance of org.apache.logging.log4j.spi.LoggerContextFactory, passed it in via system properly via properties-maven-plugin:set-system-properties: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <executions> <execution> <phase>initialize</phase> <goals> <goal>set-system-properties</goal> </goals> <configuration> <properties> <property> <name>log4j2.loggerContextFactory</name> <value>com.myco.common.commons.log.HackLogContextFactory</value> </property> </properties> </configuration> </execution> </executions> </plugin> Then I run maven-compiler-plugin (or maven processor plugin, both fail identically) WITH annotation processing. maven-compiler-plugin:compile then runs with proc jvm arg enabled. The APT annotation processor code in the AWS SKJ jar is found, and runs. It uses freemarker for templating. Log4j2-1.2 api IS found, tries to load. It cannot find core, both are right beside each other in dependencies. No power I have found can cause it to find it. There must be a class loader conflict or class loading issue. So the following outputs: >ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger NOW is bug #2! SimpleLogger, LoggerContext, and SimpleLoggerContext, possibly others are coded across packages to cast the wrong types, it seems. When log4j2-1.2 API tries to load logging, it itself throws a class cast at org.apache.log4j.Logger.getLogger(Logger.java:39): Caused by: java.lang.ExceptionInInitializerError at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147) at freemarker.template.ObjectWrapper.<clinit>(ObjectWrapper.java:81) at freemarker.core.Configurable.<init>(Configurable.java:161) at freemarker.template.Configuration.<init>(Configuration.java:195) at freemarker.template.Configuration.<clinit>(Configuration.java:172) at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.getConfiguration(ActivitiesCodeGenerator.java:49) at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.generate(ActivitiesCodeGenerator.java:97) at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.generateActivitiesClientInterface(ActivitiesCodeGenerator.java:85) at com.amazonaws.eclipse.simpleworkflow.asynchrony.freemarker.ActivitiesCodeGenerator.generateCode(ActivitiesCodeGenerator.java:79) at com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor.processActivities(AsynchronyDeciderAnnotationProcessor.java:120) at com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor.process(AsynchronyDeciderAnnotationProcessor.java:64) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722) at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824) at com.sun.tools.javac.main.Main.compile(Main.java:439) ... 26 more Caused by: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext at org.apache.log4j.Logger.getLogger(Logger.java:39) at freemarker.log._Log4JLoggerFactory.getLogger(_Log4JLoggerFactory.java:67) at freemarker.log.Logger.getLogger(Logger.java:284) at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:66) Here is why: SimpleLoggerContext (being run because CORE could not be found), extends: org.apache.logging.log4j.spi.LoggerContext But LOOK! The class that Logger.java:39 tries to cast it to is of type: org.apache.logging.log4j.core.LoggerContext !!! Unable to render embedded object: File (DIFFERENT) not found. !! Note the "spi" versus "core" in the package. This causes the stack dump above. THis same problem can be found elsewhere. When implemented my own HackLogContextFactory and passed it in via system prop, I got this: ERROR StatusLogger org.apache.logging.log4j.core.impl.Log4jContextFactory does not implement org.apache.logging.log4j.spi.LoggerContextFactory Again, types being cast to the wrong types.
          Hide
          pirabid Abid added a comment - - edited

          Hi,

          I am also hitting the same ClassCastException issue while trying to run the log4j2 in WebLogic application server. Here is what I have done:

          • if I put the api and core jars into DOMAIN_HOME/lib (equivalent to adding the jars into server classpath) things run okay.
          • if I put the api and core jars into WL_HOME/server/lib/mbeantypes/3rdpartyjars, then this classcast exception is thrown:

          java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext
          at com.qnb.itd.wls.sec.providers.MyAuditProviderImpl.initialize(MyAuditProviderImpl.java:108)
          at com.bea.common.security.internal.legacy.service.SecurityProviderImpl.init(SecurityProviderImpl.java:65)
          at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:363)
          at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315)
          at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257)
          at com.bea.common.engine.internal.ServicesImpl.getService(ServicesImpl.java:72)
          at weblogic.security.service.internal.WLSIdentityServiceImpl.initialize(Unknown Source)
          at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(Unknown Source)
          at weblogic.security.service.CSSWLSDelegateImpl.initialize(Unknown Source)
          at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.InitializeServiceEngine(Unknown Source)
          at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealm(Unknown Source)
          at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.loadRealm(Unknown Source)
          at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealms(Unknown Source)
          at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initialize(Unknown Source)
          at weblogic.security.service.SecurityServiceManager.initialize(Unknown Source)
          at weblogic.security.SecurityService.start(SecurityService.java:141)
          at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
          at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
          at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
          >

          With code snippet:

          MyAuditProviderImpl.java
          import org.apache.logging.log4j.core.LoggerContext;
          import org.apache.logging.log4j.LogManager;
          ...
          ...
          
          public final class MyAuditProviderImpl implements AuditProvider, AuditChannel{
          ...
          ...
          
          
          public void initialize(ProviderMBean mbean, SecurityServices services){
                  ...
                  ...
          	LoggerContext ctx = null;
          	Configuration config =  null;
          	Map mp = null;
          	
          	ctx = (LoggerContext) LogManager.getContext(false);
          	mp = config.getAppenders();
          	System.out.println("***<MyAudit Provider o/p follows> Before logger re-configuration:");
          	System.out.println("\tAppenders:" + mp.keySet());
                  ...
                  ...
              }
          }
          
          
          • with least hope to solve this issue, I also merged the two jars carefully (making sure MANIFEST.MF has all the entries) into single one but still same issue.

          Hope this helps in someway to identify what is going wrong.

          I am ready to test to collect any additional data for debugging.

          Thanks

          Show
          pirabid Abid added a comment - - edited Hi, I am also hitting the same ClassCastException issue while trying to run the log4j2 in WebLogic application server. Here is what I have done: if I put the api and core jars into DOMAIN_HOME/lib (equivalent to adding the jars into server classpath) things run okay. if I put the api and core jars into WL_HOME/server/lib/mbeantypes/3rdpartyjars, then this classcast exception is thrown: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext at com.qnb.itd.wls.sec.providers.MyAuditProviderImpl.initialize(MyAuditProviderImpl.java:108) at com.bea.common.security.internal.legacy.service.SecurityProviderImpl.init(SecurityProviderImpl.java:65) at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:363) at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315) at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257) at com.bea.common.engine.internal.ServicesImpl.getService(ServicesImpl.java:72) at weblogic.security.service.internal.WLSIdentityServiceImpl.initialize(Unknown Source) at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(Unknown Source) at weblogic.security.service.CSSWLSDelegateImpl.initialize(Unknown Source) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.InitializeServiceEngine(Unknown Source) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealm(Unknown Source) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.loadRealm(Unknown Source) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealms(Unknown Source) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initialize(Unknown Source) at weblogic.security.service.SecurityServiceManager.initialize(Unknown Source) at weblogic.security.SecurityService.start(SecurityService.java:141) at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) > With code snippet: MyAuditProviderImpl.java import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.LogManager; ... ... public final class MyAuditProviderImpl implements AuditProvider, AuditChannel{ ... ... public void initialize(ProviderMBean mbean, SecurityServices services){ ... ... LoggerContext ctx = null ; Configuration config = null ; Map mp = null ; ctx = (LoggerContext) LogManager.getContext( false ); mp = config.getAppenders(); System .out.println( "***<MyAudit Provider o/p follows> Before logger re-configuration:" ); System .out.println( "\tAppenders:" + mp.keySet()); ... ... } } with least hope to solve this issue, I also merged the two jars carefully (making sure MANIFEST.MF has all the entries) into single one but still same issue. Hope this helps in someway to identify what is going wrong. I am ready to test to collect any additional data for debugging. Thanks
          Hide
          jvz Matt Sicker added a comment -

          I've made a bunch of updates to the OSGi handling. Could you try this again with the latest trunk? I noticed you're using WebLogic which uses OSGi internally from what I recall (depending on the version of WL that is). You should still get an error at startup about using SimpleLoggerContextFactory, but log4j-core will override that when it's started as a bundle.

          Show
          jvz Matt Sicker added a comment - I've made a bunch of updates to the OSGi handling. Could you try this again with the latest trunk? I noticed you're using WebLogic which uses OSGi internally from what I recall (depending on the version of WL that is). You should still get an error at startup about using SimpleLoggerContextFactory, but log4j-core will override that when it's started as a bundle.
          Hide
          ralph.goers@dslextreme.com Ralph Goers added a comment -

          This is a duplicate of LOG4J2-146. The Log4j 1.2 bridge requires that the Log4j 2 core be available for it to work properly. I am not sure that that dependency can be removed.

          Show
          ralph.goers@dslextreme.com Ralph Goers added a comment - This is a duplicate of LOG4J2-146 . The Log4j 1.2 bridge requires that the Log4j 2 core be available for it to work properly. I am not sure that that dependency can be removed.
          Hide
          ralph.goers@dslextreme.com Ralph Goers added a comment -

          Abid, are you getting any messages routed to wherever weblogic routes system.err?

          Show
          ralph.goers@dslextreme.com Ralph Goers added a comment - Abid, are you getting any messages routed to wherever weblogic routes system.err?
          Hide
          pirabid Abid added a comment -

          Sorry for the delay Ralph...was on vacation... I will test it soon and let you know the results.

          Show
          pirabid Abid added a comment - Sorry for the delay Ralph...was on vacation... I will test it soon and let you know the results.
          Hide
          pirabid Abid added a comment - - edited

          Tried with the latest trunk however still same classcast error when I place the jars inside subdirectory of WL_HOME/server/lib/mbeantypes.

          std.out/error
          <Jun 8, 2014 8:38:33 AM AST> <Notice> <Log Management> <BEA-170019> <The server
          log file D:\tqa0666\oracle\wls1036\user_projects\domains\TestDomain1\servers\Adm
          inServer\logs\AdminServer.log is opened. All server side log events will be writ
          ten to this file.>
          QNBAuditProviderImpl.initialize
                  activeHandlerEntries.length=1
                  handlerEnabled=true
          ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger
          
          <Jun 8, 2014 8:38:34 AM AST> <Error> <Security> <BEA-090870> <The realm "myrealm
          " failed to be loaded: weblogic.security.service.SecurityServiceException: com.bea.common.engine.ServiceInitializationException: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.
          logging.log4j.core.LoggerContext.weblogic.security.service.SecurityServiceException: com.bea.common.engine.ServiceInitializationException: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
                  at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(CSSWLSDelegateImpl.java:341)
                  at weblogic.security.service.CSSWLSDelegateImpl.initialize(CSSWLSDelegateImpl.java:220)
                  at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.InitializeServiceEngine(CommonSecurityServiceManagerDelegateImpl.java:1789)
                  at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealm(CommonSecurityServiceManagerDelegateImpl.java:443)
                  at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.loadRealm(CommonSecurityServiceManagerDelegateImpl.java:841)
                  Truncated. see log file for complete stacktrace
          Caused By: com.bea.common.engine.ServiceInitializationException: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
                  at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:365)
                  at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315)
                  at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257)
                  at com.bea.common.engine.internal.ServicesImpl.getService(ServicesImpl.java:72)
                  at weblogic.security.service.internal.WLSIdentityServiceImpl.initialize(WLSIdentityServiceImpl.java:43)
                  Truncated. see log file for complete stacktrace
          Caused By: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
                  at com.qnb.itd.wls.sec.providers.QNBAuditProviderImpl.initialize(QNBAuditProviderImpl.java:108)
                  at com.bea.common.security.internal.legacy.service.SecurityProviderImpl.init(SecurityProviderImpl.java:60)
                  at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:363)
                  at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315)
                  at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257)
                  Truncated. see log file for complete stacktrace
          >
          <Jun 8, 2014 8:38:35 AM AST> <Notice> <Security> <BEA-090082> <Security initiali
          zing using security realm myrealm.>
          <Jun 8, 2014 8:38:35 AM AST> <Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason:
          
          There are 1 nested errors:
          
          weblogic.security.service.SecurityServiceRuntimeException: [Security:090399]Security Services Unavailable
                  at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.doBootAuthorization(CommonSecurityServiceManagerDelegateImpl.java:917)
                  at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initialize(CommonSecurityServiceManagerDelegateImpl.java:1054)
                  at weblogic.security.service.SecurityServiceManager.initialize(SecurityServiceManager.java:873)
                  at weblogic.security.SecurityService.start(SecurityService.java:141)
                  at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
                  at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
                  at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
          
          >
          <Jun 8, 2014 8:38:35 AM AST> <Notice> <WebLogicServer> <BEA-000365> <Server stat
          e changed to FAILED>
          <Jun 8, 2014 8:38:35 AM AST> <Error> <WebLogicServer> <BEA-000383> <A critical s
          ervice failed. The server will shut itself down>
          <Jun 8, 2014 8:38:35 AM AST> <Notice> <WebLogicServer> <BEA-000365> <Server stat
          e changed to FORCE_SHUTTING_DOWN>
          
          
          Show
          pirabid Abid added a comment - - edited Tried with the latest trunk however still same classcast error when I place the jars inside subdirectory of WL_HOME/server/lib/mbeantypes. std.out/error <Jun 8, 2014 8:38:33 AM AST> <Notice> <Log Management> <BEA-170019> <The server log file D:\tqa0666\oracle\wls1036\user_projects\domains\TestDomain1\servers\Adm inServer\logs\AdminServer.log is opened. All server side log events will be writ ten to this file.> QNBAuditProviderImpl.initialize activeHandlerEntries.length=1 handlerEnabled= true ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger <Jun 8, 2014 8:38:34 AM AST> <Error> <Security> <BEA-090870> <The realm "myrealm " failed to be loaded: weblogic.security.service.SecurityServiceException: com.bea.common.engine.ServiceInitializationException: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache. logging.log4j.core.LoggerContext.weblogic.security.service.SecurityServiceException: com.bea.common.engine.ServiceInitializationException: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(CSSWLSDelegateImpl.java:341) at weblogic.security.service.CSSWLSDelegateImpl.initialize(CSSWLSDelegateImpl.java:220) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.InitializeServiceEngine(CommonSecurityServiceManagerDelegateImpl.java:1789) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initializeRealm(CommonSecurityServiceManagerDelegateImpl.java:443) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.loadRealm(CommonSecurityServiceManagerDelegateImpl.java:841) Truncated. see log file for complete stacktrace Caused By: com.bea.common.engine.ServiceInitializationException: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:365) at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315) at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257) at com.bea.common.engine.internal.ServicesImpl.getService(ServicesImpl.java:72) at weblogic.security.service.internal.WLSIdentityServiceImpl.initialize(WLSIdentityServiceImpl.java:43) Truncated. see log file for complete stacktrace Caused By: java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext at com.qnb.itd.wls.sec.providers.QNBAuditProviderImpl.initialize(QNBAuditProviderImpl.java:108) at com.bea.common.security.internal.legacy.service.SecurityProviderImpl.init(SecurityProviderImpl.java:60) at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:363) at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315) at com.bea.common.engine.internal.ServiceEngineImpl.lookupService(ServiceEngineImpl.java:257) Truncated. see log file for complete stacktrace > <Jun 8, 2014 8:38:35 AM AST> <Notice> <Security> <BEA-090082> <Security initiali zing using security realm myrealm.> <Jun 8, 2014 8:38:35 AM AST> <Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason: There are 1 nested errors: weblogic.security.service.SecurityServiceRuntimeException: [Security:090399]Security Services Unavailable at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.doBootAuthorization(CommonSecurityServiceManagerDelegateImpl.java:917) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initialize(CommonSecurityServiceManagerDelegateImpl.java:1054) at weblogic.security.service.SecurityServiceManager.initialize(SecurityServiceManager.java:873) at weblogic.security.SecurityService.start(SecurityService.java:141) at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) > <Jun 8, 2014 8:38:35 AM AST> <Notice> <WebLogicServer> <BEA-000365> <Server stat e changed to FAILED> <Jun 8, 2014 8:38:35 AM AST> <Error> <WebLogicServer> <BEA-000383> <A critical s ervice failed. The server will shut itself down> <Jun 8, 2014 8:38:35 AM AST> <Notice> <WebLogicServer> <BEA-000365> <Server stat e changed to FORCE_SHUTTING_DOWN>
          Hide
          pirabid Abid added a comment - - edited

          Adding of jars into subdirectory of "WL_HOME/server/lib/mbeantypes" was suggested by Oracle Support with whom I have an SR open to track this issue. But I think this suggestion was not correct because I suspect that WLS loads each jar inside the subdirectory inside a separate classloader and hence this visibility issue between API and core jars. So I dropped this option floated as a half-hearted solution by Oracle. And they have not been able to suggest anything new so far.

          Given your pointers on weblogic use of OSGi, I packaged the core and api jars with my custom security provider jar (which is generated by WLS tools), I modified "MANIFEST.MF" to have entries:

          MANIFEST.MF
          ...
          ..
          Name: log4j-core-2.0-rc2-SNAPSHOT.jar
          Name: log4j-api-2.0-rc2-SNAPSHOT.jar
          Bundle-ClassPath: log4j-api-2.0-rc2-SNAPSHOT.jar,log4j-core-2.0-rc2-SNAPSHOT.jar,disruptor-3.2.0.jar,log4j2.xml,.
          

          But nothing progressive; now WLS starts to throw NoClassDefFoundError:

          std.out/error
          <Jun 8, 2014 9:08:27 AM AST> <Error> <Security> <BEA-090870> <The realm "myrealm" failed to be loaded: weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger.
          weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger
                  at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(CSSWLSDelegateImpl.java:341)
                  at weblogic.security.service.CSSWLSDelegateImpl.initialize(CSSWLSDelegateImpl.java:220)
          ...
          ...
          Caused By: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger
                  at java.lang.Class.forName0(Native Method)
                  at java.lang.Class.forName(Class.java:249)
                  at com.bea.common.security.internal.legacy.service.SecurityProviderImpl.init(SecurityProviderImpl.java:46)
                  at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:363)
                  at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315)
                  Truncated. see log file for complete stacktrace
          Caused By: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger
                  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
                  Truncated. see log file for complete stacktrace
          >
          <Jun 8, 2014 9:08:28 AM AST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
          ...
          ...
          

          Thanks,
          Abid

          Show
          pirabid Abid added a comment - - edited Adding of jars into subdirectory of "WL_HOME/server/lib/mbeantypes" was suggested by Oracle Support with whom I have an SR open to track this issue. But I think this suggestion was not correct because I suspect that WLS loads each jar inside the subdirectory inside a separate classloader and hence this visibility issue between API and core jars. So I dropped this option floated as a half-hearted solution by Oracle. And they have not been able to suggest anything new so far. Given your pointers on weblogic use of OSGi, I packaged the core and api jars with my custom security provider jar (which is generated by WLS tools), I modified "MANIFEST.MF" to have entries: MANIFEST.MF ... .. Name: log4j-core-2.0-rc2-SNAPSHOT.jar Name: log4j-api-2.0-rc2-SNAPSHOT.jar Bundle-ClassPath: log4j-api-2.0-rc2-SNAPSHOT.jar,log4j-core-2.0-rc2-SNAPSHOT.jar,disruptor-3.2.0.jar,log4j2.xml,. But nothing progressive; now WLS starts to throw NoClassDefFoundError: std.out/error <Jun 8, 2014 9:08:27 AM AST> <Error> <Security> <BEA-090870> <The realm "myrealm" failed to be loaded: weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger. weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(CSSWLSDelegateImpl.java:341) at weblogic.security.service.CSSWLSDelegateImpl.initialize(CSSWLSDelegateImpl.java:220) ... ... Caused By: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger at java.lang. Class .forName0(Native Method) at java.lang. Class .forName( Class .java:249) at com.bea.common.security.internal.legacy.service.SecurityProviderImpl.init(SecurityProviderImpl.java:46) at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:363) at com.bea.common.engine.internal.ServiceEngineImpl.findOrStartService(ServiceEngineImpl.java:315) Truncated. see log file for complete stacktrace Caused By: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang. ClassLoader .loadClass( ClassLoader .java:306) at java.lang. ClassLoader .loadClass( ClassLoader .java:247) Truncated. see log file for complete stacktrace > <Jun 8, 2014 9:08:28 AM AST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.> ... ... Thanks, Abid
          Hide
          pirabid Abid added a comment -

          I have managed to reproduce the issue without log4j api and core jars. I created dummy ClassA (whose object I instantiate in custom security provider implementation class) and ClassB (object instantiated in ClassA) in jars A.jar and B.jar respectively, bundled these with the WLS custom security provider and modified the manifest file bundle-classpath - am getting same "NoClassDefFoundError"

          <Jun 8, 2014 1:16:01 PM AST> <Error> <Security> <BEA-090870> <The realm "myrealm" failed to be loaded: weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: examples/pack1/A.
          weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: examples/pack1/A
                  at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(CSSWLSDelegateImpl.java:341)
                  at weblogic.security.service.CSSWLSDelegateImpl.initialize(CSSWLSDelegateImpl.java:220)
          ...
          ...
          

          Will check with Oracle Support on this.

          Thanks,
          Abid

          Show
          pirabid Abid added a comment - I have managed to reproduce the issue without log4j api and core jars. I created dummy ClassA (whose object I instantiate in custom security provider implementation class) and ClassB (object instantiated in ClassA) in jars A.jar and B.jar respectively, bundled these with the WLS custom security provider and modified the manifest file bundle-classpath - am getting same "NoClassDefFoundError" <Jun 8, 2014 1:16:01 PM AST> <Error> <Security> <BEA-090870> <The realm "myrealm" failed to be loaded: weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: examples/pack1/A. weblogic.security.service.SecurityServiceException: java.lang.NoClassDefFoundError: examples/pack1/A at weblogic.security.service.CSSWLSDelegateImpl.initializeServiceEngine(CSSWLSDelegateImpl.java:341) at weblogic.security.service.CSSWLSDelegateImpl.initialize(CSSWLSDelegateImpl.java:220) ... ... Will check with Oracle Support on this. Thanks, Abid
          Hide
          remkop@yahoo.com Remko Popma added a comment -

          Nice detective work, Abid!
          Glad to hear you have a workaround by putting api and core jars into DOMAIN_HOME/lib, but I'd be interested in Oracle Weblogic support team's response to your inquiry.

          Show
          remkop@yahoo.com Remko Popma added a comment - Nice detective work, Abid! Glad to hear you have a workaround by putting api and core jars into DOMAIN_HOME/lib, but I'd be interested in Oracle Weblogic support team's response to your inquiry.
          Hide
          pirabid Abid added a comment -

          Got an update from Oracle which essentially means that packaging of library jars with the security provider is not supported; library jars for security provider have to go into server classpath in one way or the other.

          For me this would mean taking risk of exposing those jars at global level to whole bunch of multi-vendor applications (deployed into weblogic environment) who use their own different versions of log4j libraries.

          Oracle raised an Enhancement Request of low severity in this regard

          Show
          pirabid Abid added a comment - Got an update from Oracle which essentially means that packaging of library jars with the security provider is not supported; library jars for security provider have to go into server classpath in one way or the other. For me this would mean taking risk of exposing those jars at global level to whole bunch of multi-vendor applications (deployed into weblogic environment) who use their own different versions of log4j libraries. Oracle raised an Enhancement Request of low severity in this regard
          Hide
          ralph.goers@dslextreme.com Ralph Goers added a comment -

          Is there a link to the enhancement request that you can add here for completeness?

          Show
          ralph.goers@dslextreme.com Ralph Goers added a comment - Is there a link to the enhancement request that you can add here for completeness?
          Hide
          pirabid Abid added a comment -

          It can be looked up in Oracle Support site as:

          Bug 18998060 : CUSTOM SECURITY PROVIDER IMPLEMENTATION WITH LOG4J2+DISRUPTER

          Show
          pirabid Abid added a comment - It can be looked up in Oracle Support site as: Bug 18998060 : CUSTOM SECURITY PROVIDER IMPLEMENTATION WITH LOG4J2+DISRUPTER
          Hide
          remkop@yahoo.com Remko Popma added a comment -

          Changed priority from "Blocking" to "Major" since a workaround exists (put the api and core jars into DOMAIN_HOME/lib ).

          Also it appears that this is a WebLogic problem rather than a log4j2 problem. Should we still keep this issue open?

          Show
          remkop@yahoo.com Remko Popma added a comment - Changed priority from "Blocking" to "Major" since a workaround exists (put the api and core jars into DOMAIN_HOME/lib ). Also it appears that this is a WebLogic problem rather than a log4j2 problem. Should we still keep this issue open?
          Hide
          DaLN Nelson MELINA added a comment -

          Gaurav Kapoor Did you manage to make Log4J 2 work on Android ?

          Show
          DaLN Nelson MELINA added a comment - Gaurav Kapoor Did you manage to make Log4J 2 work on Android ?
          Hide
          ssethia Snehadeep Sethia added a comment -

          I'm get the following message on an OSGi project. "ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...", I'm using log4j-api v2.0.2 and log4j-core v2.0.2; The logger works very well on a stand alone java project but fails on an eclipse project. Any pointers?

          Show
          ssethia Snehadeep Sethia added a comment - I'm get the following message on an OSGi project. "ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...", I'm using log4j-api v2.0.2 and log4j-core v2.0.2; The logger works very well on a stand alone java project but fails on an eclipse project. Any pointers?
          Hide
          alvarolucas Alvaro de Lucas added a comment -

          Maybe this can help...
          (Log4j2 working on Android providing the xml content directly into a String...)
          http://stackoverflow.com/questions/28235021/log4j2-on-android

          Show
          alvarolucas Alvaro de Lucas added a comment - Maybe this can help... (Log4j2 working on Android providing the xml content directly into a String...) http://stackoverflow.com/questions/28235021/log4j2-on-android

            People

            • Assignee:
              Unassigned
              Reporter:
              gauravk Gaurav Kapoor
            • Votes:
              2 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:

                Development