You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Karl Pauls (JIRA)" <ji...@apache.org> on 2010/02/22 23:06:28 UTC

[jira] Resolved: (FELIX-2108) The log4j from felix launcher is messing up felix osgi container

     [ https://issues.apache.org/jira/browse/FELIX-2108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls resolved FELIX-2108.
-------------------------------

    Resolution: Invalid

Well, it is a context classloader problem after all. The context classloader is set to the system classloader by default -- hence, log4j is picking it up and does see the classes on the outside. 

There are two ways to fix this in your case:

1) Set the context classloader to 
1.1) null in your launcher before you start felix (notice, this might cause problems with other libraries which are known to expect it to be set to something other than null)
1.2) your own classloader which doesn't see classes you don't want to "leak" into the framework (mainly to avoid the null issue of 1.1)

2) "tell" log4j to ignore the context classloader by setting -Dlog4j.ignoreTCL=true

I used 2) and it worked without any issues. 

I'll resolve with invalid - please close if you are satisfied or reopen if you see room for improvement.

> The log4j from felix launcher is messing up felix osgi container 
> -----------------------------------------------------------------
>
>                 Key: FELIX-2108
>                 URL: https://issues.apache.org/jira/browse/FELIX-2108
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.4.1
>            Reporter: Shrini Joshi
>            Assignee: Karl Pauls
>         Attachments: felix-launcher.zip, log4jconfig_1.0.0.jar, osgi-simple-service.zip
>
>
> **** This issue is not type question rather than a bug ****
> I have created a launcher programme which is responsible for laoding the config values and instantiating the felix container (1.4.1). 
> Everything is working fine except for one small glitch.  Please take a look for following error message thrown by the log4j bundle. 
> The launcher programme is using log4j for logging. But when it starts the felix container, log4j bundle is installed since it is used by the application itself. 
> I have listed deployed bundles further below. 
> My view is, the log4j library loaded by launcher is visible to felix container and hence log4j bundle fails to start cleanly. This is going to be a big problem for dpeloyment. 
> I am using felix 1.4.1, is that too old to be good? 
> Is there any setting that I need to pass to instruct the felix to create comepletly new classloader as system-classloader? Being a OSGI container I expected it to create new class-loader as system-classloader but now I feel it does not.  
> Can someome please help me understand? 
> Shrini
> ===
> log4j: reset attribute= "false".
> log4j: Threshold ="null".
> log4j: Level value for root is  [DEBUG].
> log4j: root level set to DEBUG
> log4j: Class name: [org.apache.log4j.RollingFileAppender]
> log4j: Setting property [file] to [**************/launcher.log].
> log4j: Setting property [append] to [true].
> log4j: Setting property [maxFileSize] to [10MB].
> log4j: Setting property [maxBackupIndex] to [15].
> log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
> log4j: Setting property [conversionPattern] to [%d{dd MMM yyyy HH:mm:ss,SSS} %t %-5p %c{2} - %m%n].
> log4j: setFile called: **************/launcher.log, true
> log4j: setFile ended
> log4j: Adding appender named [FILE] to category [root].
> -> log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.
> log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by
> log4j:ERROR [6.0] whereas object of type
> log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [sun.misc.Launcher$AppClassLoader@17182c1].
> log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].
> log4j:WARN No appenders could be found for logger (org.springframework.osgi.extender.internal.activator.ContextLoaderListener).
> log4j:WARN Please initialize the log4j system properly.
> =====
> [   0] [Active     ] [    0] System Bundle (2.0.1)
> [   1] [Active     ] [    5] AOP Alliance API (1.0.0)
> [   2] [Active     ] [    5] Apache Commons Collections (3.2.0)
> [   3] [Active     ] [    5] Apache Commons Lang (2.4.0)
> [   4] [Active     ] [    5] Apache Commons Logging (1.1.1)
> [   5] [Active     ] [    5] Apache Commons Pool (1.3.0)
> [   6] [Active     ] [    5] Apache Log4J (1.2.15)
> [   7] [Active     ] [    5] Apache Felix Bundle Repository (1.4.2)
> [   8] [Active     ] [    5] Apache Felix Shell Service (1.4.1)
> [   9] [Active     ] [    5] Apache Felix Shell TUI (1.4.1)
> [  10] [Active     ] [    5] Spring AOP (2.5.6)
> [  11] [Active     ] [    5] Spring Beans (2.5.6)
> [  12] [Active     ] [    5] Spring Context (2.5.6)
> [  13] [Active     ] [    5] Spring Context Support (2.5.6)
> [  14] [Active     ] [    5] Spring Core (2.5.6)
> [  15] [Active     ] [    5] spring-osgi-core (1.2.1)
> [  16] [Active     ] [    5] spring-osgi-extender (1.2.1)
> [  17] [Active     ] [    5] spring-osgi-io (1.2.1)
> ============

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.