You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Craig Phillips <lc...@praxiseng.com> on 2008/07/07 12:59:25 UTC

using pax-logger/log4j in embedded felix (class loader issue)

Hi, I probably need to direct this to PAX, but I'll try here (felix dev)
first... Sorry to trouble you, if anyone with felix class loader
intimacy could take a look, I'd be appreciative... for a logger, this
isn't critical and I'll probably just write my own simple FileLogger
that implements LogService, but I suspect there are bigger issues at
play... Some background...

 

I'm embedding felix in a class that is being run within a tomcat web-app
(dot.jsp initiated - just as a driver/tester); Hence, I'm doing a 'new
Felix(map, list)' and invoking the 'felix.start()' method... Here's my
config.properties auto.start list:

 

file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar \

file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \

file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \

file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
jar \

file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar \

file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \

file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \

file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar

 

Anyway, here are the applicable ERROR log entries, seemingly coming from
pax:

 

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
assignable to a "

org.apache.log4j.Appender" variable.

log4j:ERROR The class "org.apache.log4j.Appender" was loaded by

log4j:ERROR [7.0] whereas object of type

log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
[WebappClassLoader

  delegate: false

  repositories:

----------> Parent Classloader:

org.apache.catalina.loader.StandardClassLoader@d1e604

].

log4j:ERROR Could not instantiate appender named "A1".

*DEBUG* Scheduling task ManagedService Update: pid=org.ops4j.pax.logging

*DEBUG* Running task ManagedService Update: pid=org.ops4j.pax.logging

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
assignable to a "

org.apache.log4j.Appender" variable.

log4j:ERROR The class "org.apache.log4j.Appender" was loaded by

log4j:ERROR [7.0] whereas object of type

log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
[WebappClassLoader

  delegate: false

  repositories:

----------> Parent Classloader:

org.apache.catalina.loader.StandardClassLoader@d1e604

].

log4j:ERROR Could not instantiate appender named "A8".

DEBUG: WIRE: 8.0 -> org.osgi.service.log -> 2.0

DEBUG: WIRE: 8.0 -> org.craig.shell.telnet -> 8.0

DEBUG: WIRE: 8.0 -> org.apache.felix.shell -> 1.0

DEBUG: WIRE: 8.0 -> org.osgi.service.component -> 2.0

log4j:WARN No appenders could be found for logger
(org.ops4j.pax.logging.pax-log

ging-service).

log4j:WARN Please initialize the log4j system properly.

DEBUG: WIRE: 4.0 -> org.osgi.service.log -> 2.0

 

Any insight would be appreciated... not critical, but I suspect I'm not
going to see the last of class loader issues, especially in an embedded
environment...  Thanks, Craig Phillips

 


Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Mon, Jul 7, 2008 at 11:24 PM, Stuart McCulloch
<st...@jayway.net> wrote:
> however, setting this would break Pax-Logging, because then the application
> would load the Log4J public API classes from the standard Log4J jar - rather
> than the custom classes from Pax-Logging that fix Log4J logging for OSGi
>
> note you can use mandatory attributes in your manifest if you want to ensure
> that bundles always use the Log4J public classes provided by Pax-Logging:
>
>    http://www.ops4j.org/projects/pax/logging/userguide.html
>
> wrt. the error - the Appender class is probably from the Pax-Logging service
> bundle, which has a Log4J backend - however, this is private to the bundle
> and also contains ConsoleAppender, so it's strange that these two classes
> are being loaded by different classloaders
>
> it looks like the web containers classes are somehow visible to the bundles,
> although the Felix classloader should be keeping them hidden (unless the
> bootdelegation property is set)

Well, it will take me a while to go through the entire discussion, but

org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*

is mentioned above, which I think will create a mess. Not only will
Pax Logging Service use those classes, instead of the internal ones,
but I suspect (need to check the spec) that Pax Logging API will also
use those, which won't work.

The original post seems to indicate that indeed the Log4J classes are
loaded by the web containers classloader, and I can't figure out the
possible breakage scenarios in that case. Please note that the Pax
Logging manifests are trying hard to bind compatible versions of the
packages involved to each other with mandatory attributes.

Another indicator that some "other" Log4J is involved is the
"log4j:WARN No appenders could be found for logger", since Pax Logging
do not utilize the Log4J auto discovery of log4j.properties file, and
instead do an active call to the configuration system in Log4J.

If the entire project is publicly available, please point me to it,
and I'll try to figure out what is going on.


Cheers
Niclas

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Stuart McCulloch <st...@jayway.net>.
2008/7/7 Sahoo <Sa...@sun.com>:

> Karl Pauls wrote:
>
>> On Mon, Jul 7, 2008 at 4:08 PM, Sahoo <Sa...@sun.com> wrote:
>>
>>
>>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>>>> assignable to a "
>>>>
>>>> org.apache.log4j.Appender" variable.
>>>>
>>>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>>>
>>>> log4j:ERROR [7.0] whereas object of type
>>>>
>>>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>>>> [WebappClassLoader
>>>>
>>>>  delegate: false
>>>>
>>>>
>>>>
>>>>
>>> As someone already pointed out, this seems to be the real issue.
>>>
>>>
>>
>> Why would that be an issue?
>>
>>
>>
> WebappClassLoader, which is what the war uses to load any class, has loaded
> ConsoleAppender as well as the interface Appender. In the OSGi classloading
> space, Appender is loaded by some bundle's class loader. I was thinking that
> somehow the ConsoleAppender as loaded by the application class loader is
> coming in contact with Appender which is loaded by a bundle.
>
>> Try setting the following in felix/config.properties file or whatever
>>> equivalent way to
>>> pass it while invoking Felix using an API:
>>>
>>> org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*
>>> I am not suggesting this as a long term solution, but this can take us
>>> towards the solution.
>>>
>>>
>>
>> How?
>>
>>
>>
> Since Felix is started by the web app, Felix would use that web app's class
> loader for any delegation. By having this property, both OSGi bundles should
> see same log4j classes as the web app.
>

however, setting this would break Pax-Logging, because then the application
would load the Log4J public API classes from the standard Log4J jar - rather
than the custom classes from Pax-Logging that fix Log4J logging for OSGi

note you can use mandatory attributes in your manifest if you want to ensure
that bundles always use the Log4J public classes provided by Pax-Logging:

   http://www.ops4j.org/projects/pax/logging/userguide.html

wrt. the error - the Appender class is probably from the Pax-Logging service
bundle, which has a Log4J backend - however, this is private to the bundle
and also contains ConsoleAppender, so it's strange that these two classes
are being loaded by different classloaders

it looks like the web containers classes are somehow visible to the bundles,
although the Felix classloader should be keeping them hidden (unless the
bootdelegation property is set)

Thanks,
> Sahoo
>
>> regards,
>>
>> Karl
>>
>>
>>
>>> Thanks,
>>> Sahoo
>>>
>>
-- 
Cheers, Stuart

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Tue, Jul 8, 2008 at 4:40 AM, Karl Pauls <ka...@gmail.com> wrote:

>> So, depending on how you are setting this up, you need to do
>> "something", like either replicate the ContextFinder approach, or
>> plainly set the TCL to null prior to loading up Felix.
>
> Is that something pax logging can do?

Can - yes.
Should - I don't know.

One thing that has been lurking in the shadows for a looooong time by
now, is to do an isolation layer in Pax Logging, where the Log4j
execution happens in a separate thread to avoid deadlocks, fast log
event returns,  and what not...

Pressure in the Cooker is growing...

Cheers
Niclas

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Karl Pauls <ka...@gmail.com>.
On Mon, Jul 7, 2008 at 10:27 PM, Niclas Hedhman <ni...@hedhman.org> wrote:
> On Tue, Jul 8, 2008 at 3:26 AM, Niclas Hedhman <ni...@hedhman.org> wrote:
>> On Tue, Jul 8, 2008 at 1:31 AM, Karl Pauls <ka...@gmail.com> wrote:
>>> Is it somehow possible that log4j is
>>> doing some classloader magic itself and maybe is using the context
>>> classloader? The context classloader would be the WebAppClassloader I
>>> think ...
>>
>> Good Suggestion. Will investigate that initially.
>
> Ok. Here is the funky bits. Me and Alin Dreghiciu have both been
> looking at different problems today(!) turning out to be the same
> thing.
>
> Craig, if you took the time to try out Equinox, you would probably
> find that it might work in Equinox (the Spring case does), but not in
> Felix and not in Knopflerfish... Why?
>
> Log4J (as Spring in Alin's case) try to use the thread context
> classloader, if one is present, otherwise use the classloader of
> "itself". Hence we are seeing the Webapp classloader being used in
> Log4J's loading of resources, resulting in terrible mismatches.
> So why does it work in Equinox. Equinox sets the thread context
> classloader to something they call ContextFinder, which will look at
> the call stack, and take the first classloader found other than system
> CL, which would be the classloader of Pax Logging Service in your
> case.
>
> So, depending on how you are setting this up, you need to do
> "something", like either replicate the ContextFinder approach, or
> plainly set the TCL to null prior to loading up Felix.

Is that something pax logging can do?

> I would be interested to hear if that helps. Also Many Thanks to Karl
> who provided a 'short-cut', as the TCL was not the first thing on my
> mind.

Well, it was the only thing left before considering it a framework bug
- I'm lazy :-)

regards,

Karl

> Cheers
> Niclas
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Karl Pauls <ka...@gmail.com>.
You would have to do the following around all calls into the framework:

ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try
{
   Thread.currentThread().setContextClassLoader(null);
   // call into the framework
}
finally
{
   Thread.currentThread().setContextClassLoader(tccl);
}

regards,

Karl

On Mon, Jul 7, 2008 at 11:51 PM, Craig Phillips
<lc...@praxiseng.com> wrote:
> Hi,
>
> - I can't use Equinox because I discovered a Null Pointer Exception when attempting to restart it (in the same "context" loosely speaking -- embedded); Also, equinox as embedded is not really "instance" based out of the box; I logged a bug on the NPE and it's probably fixed by now, but it's not officially released as a non-beta and that presents issues for me that I plan to avoid;
> - Since I wrote the small layer that creates the Felix instance, I have no problem tweaking that code to set the TCL to null (seems easier to do that than replicating a context finder);
>
> Dumb question - what is a TCL and how would I go about setting it to null (I could also ask the same of the context finder approach but setting something to null just sounds way easier) [I have written a class loader / jar loader or two or three in my time, so I'm not totally ignorant... just lazy if I can get away with it]...
>
> Thanks, Craig
>
> ________________________________
>
> From: hedhman@gmail.com on behalf of Niclas Hedhman
> Sent: Mon 7/7/2008 4:27 PM
> To: dev@felix.apache.org
> Subject: Re: using pax-logger/log4j in embedded felix (class loader issue)
>
>
>
> On Tue, Jul 8, 2008 at 3:26 AM, Niclas Hedhman <ni...@hedhman.org> wrote:
>> On Tue, Jul 8, 2008 at 1:31 AM, Karl Pauls <ka...@gmail.com> wrote:
>>> Is it somehow possible that log4j is
>>> doing some classloader magic itself and maybe is using the context
>>> classloader? The context classloader would be the WebAppClassloader I
>>> think ...
>>
>> Good Suggestion. Will investigate that initially.
>
> Ok. Here is the funky bits. Me and Alin Dreghiciu have both been
> looking at different problems today(!) turning out to be the same
> thing.
>
> Craig, if you took the time to try out Equinox, you would probably
> find that it might work in Equinox (the Spring case does), but not in
> Felix and not in Knopflerfish... Why?
>
> Log4J (as Spring in Alin's case) try to use the thread context
> classloader, if one is present, otherwise use the classloader of
> "itself". Hence we are seeing the Webapp classloader being used in
> Log4J's loading of resources, resulting in terrible mismatches.
> So why does it work in Equinox. Equinox sets the thread context
> classloader to something they call ContextFinder, which will look at
> the call stack, and take the first classloader found other than system
> CL, which would be the classloader of Pax Logging Service in your
> case.
>
> So, depending on how you are setting this up, you need to do
> "something", like either replicate the ContextFinder approach, or
> plainly set the TCL to null prior to loading up Felix.
>
> I would be interested to hear if that helps. Also Many Thanks to Karl
> who provided a 'short-cut', as the TCL was not the first thing on my
> mind.
>
>
> Cheers
> Niclas
>
>
>



-- 
Karl Pauls
karlpauls@gmail.com

RE: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Craig Phillips <lc...@praxiseng.com>.
Hi,
 
- I can't use Equinox because I discovered a Null Pointer Exception when attempting to restart it (in the same "context" loosely speaking -- embedded); Also, equinox as embedded is not really "instance" based out of the box; I logged a bug on the NPE and it's probably fixed by now, but it's not officially released as a non-beta and that presents issues for me that I plan to avoid;
- Since I wrote the small layer that creates the Felix instance, I have no problem tweaking that code to set the TCL to null (seems easier to do that than replicating a context finder);
 
Dumb question - what is a TCL and how would I go about setting it to null (I could also ask the same of the context finder approach but setting something to null just sounds way easier) [I have written a class loader / jar loader or two or three in my time, so I'm not totally ignorant... just lazy if I can get away with it]...
 
Thanks, Craig

________________________________

From: hedhman@gmail.com on behalf of Niclas Hedhman
Sent: Mon 7/7/2008 4:27 PM
To: dev@felix.apache.org
Subject: Re: using pax-logger/log4j in embedded felix (class loader issue)



On Tue, Jul 8, 2008 at 3:26 AM, Niclas Hedhman <ni...@hedhman.org> wrote:
> On Tue, Jul 8, 2008 at 1:31 AM, Karl Pauls <ka...@gmail.com> wrote:
>> Is it somehow possible that log4j is
>> doing some classloader magic itself and maybe is using the context
>> classloader? The context classloader would be the WebAppClassloader I
>> think ...
>
> Good Suggestion. Will investigate that initially.

Ok. Here is the funky bits. Me and Alin Dreghiciu have both been
looking at different problems today(!) turning out to be the same
thing.

Craig, if you took the time to try out Equinox, you would probably
find that it might work in Equinox (the Spring case does), but not in
Felix and not in Knopflerfish... Why?

Log4J (as Spring in Alin's case) try to use the thread context
classloader, if one is present, otherwise use the classloader of
"itself". Hence we are seeing the Webapp classloader being used in
Log4J's loading of resources, resulting in terrible mismatches.
So why does it work in Equinox. Equinox sets the thread context
classloader to something they call ContextFinder, which will look at
the call stack, and take the first classloader found other than system
CL, which would be the classloader of Pax Logging Service in your
case.

So, depending on how you are setting this up, you need to do
"something", like either replicate the ContextFinder approach, or
plainly set the TCL to null prior to loading up Felix.

I would be interested to hear if that helps. Also Many Thanks to Karl
who provided a 'short-cut', as the TCL was not the first thing on my
mind.


Cheers
Niclas



Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Tue, Jul 8, 2008 at 3:26 AM, Niclas Hedhman <ni...@hedhman.org> wrote:
> On Tue, Jul 8, 2008 at 1:31 AM, Karl Pauls <ka...@gmail.com> wrote:
>> Is it somehow possible that log4j is
>> doing some classloader magic itself and maybe is using the context
>> classloader? The context classloader would be the WebAppClassloader I
>> think ...
>
> Good Suggestion. Will investigate that initially.

Ok. Here is the funky bits. Me and Alin Dreghiciu have both been
looking at different problems today(!) turning out to be the same
thing.

Craig, if you took the time to try out Equinox, you would probably
find that it might work in Equinox (the Spring case does), but not in
Felix and not in Knopflerfish... Why?

Log4J (as Spring in Alin's case) try to use the thread context
classloader, if one is present, otherwise use the classloader of
"itself". Hence we are seeing the Webapp classloader being used in
Log4J's loading of resources, resulting in terrible mismatches.
So why does it work in Equinox. Equinox sets the thread context
classloader to something they call ContextFinder, which will look at
the call stack, and take the first classloader found other than system
CL, which would be the classloader of Pax Logging Service in your
case.

So, depending on how you are setting this up, you need to do
"something", like either replicate the ContextFinder approach, or
plainly set the TCL to null prior to loading up Felix.

I would be interested to hear if that helps. Also Many Thanks to Karl
who provided a 'short-cut', as the TCL was not the first thing on my
mind.


Cheers
Niclas

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Tue, Jul 8, 2008 at 1:31 AM, Karl Pauls <ka...@gmail.com> wrote:
> Is it somehow possible that log4j is
> doing some classloader magic itself and maybe is using the context
> classloader? The context classloader would be the WebAppClassloader I
> think ...

Good Suggestion. Will investigate that initially.

Cheers
Niclas

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Karl Pauls <ka...@gmail.com>.
On Mon, Jul 7, 2008 at 7:17 PM, Niclas Hedhman <ni...@hedhman.org> wrote:
> On Tue, Jul 8, 2008 at 12:22 AM, Stuart McCulloch
> <st...@jayway.net> wrote:
>
>> again, this wouldn't solve the Pax-Logging issue because
>> then the application will have all it's logging calls bound to
>> the original Log4J jar, which lacks the OSGi support that
>> Pax-Logging provides (various other things will then fail)
>
> Correct. I suspect that the Log4J classes from the WebAppClassloader
> is "leaking" and what causes the problems. So, either it is in Craig's
> configuration "somewhere" that the Framework should expose those
> packages from the parent CL, or we are touching on a bug in Felix.

That is what triggered me as well. I did look into it a little bit but
no other explanation as of now. Is it somehow possible that log4j is
doing some classloader magic itself and maybe is using the context
classloader? The context classloader would be the WebAppClassloader I
think ...

regards,

Karl

>> I believe Niclas has some ideas on how to proceed...
>
> I have received the whole project from Craig, and will try to look at
> it later when I am back "home"... Stay tuned.
>
>
> Cheers
> Niclas
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Tue, Jul 8, 2008 at 12:22 AM, Stuart McCulloch
<st...@jayway.net> wrote:

> again, this wouldn't solve the Pax-Logging issue because
> then the application will have all it's logging calls bound to
> the original Log4J jar, which lacks the OSGi support that
> Pax-Logging provides (various other things will then fail)

Correct. I suspect that the Log4J classes from the WebAppClassloader
is "leaking" and what causes the problems. So, either it is in Craig's
configuration "somewhere" that the Framework should expose those
packages from the parent CL, or we are touching on a bug in Felix.

> I believe Niclas has some ideas on how to proceed...

I have received the whole project from Craig, and will try to look at
it later when I am back "home"... Stay tuned.


Cheers
Niclas

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Stuart McCulloch <st...@jayway.net>.
2008/7/8 Sahoo <sa...@sun.com>:

> Karl Pauls wrote:
>
>> Since Felix is started by the web app, Felix would use that web app's
>>> class
>>> loader for any delegation. By having this property, both OSGi bundles
>>> should
>>> see same log4j classes as the web app.
>>>
>>>
>>
>> Right. I'll try to investigate this a bit more.
>>
>>
> Since the parent class loader, which in this case is WebappClassLoader, has
> all the log4j classes, a better alternative would be to configure the OSGi
> framework to export log4j classes and related classes (like commons-logging
> may be) using org.osgi.framework.system.packages system property. That way,
> there is still some control over log4j class loading.
>

again, this wouldn't solve the Pax-Logging issue because
then the application will have all it's logging calls bound to
the original Log4J jar, which lacks the OSGi support that
Pax-Logging provides (various other things will then fail)

I believe Niclas has some ideas on how to proceed...

-- 
Cheers, Stuart

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Sahoo <sa...@sun.com>.
Karl Pauls wrote:
>> Since Felix is started by the web app, Felix would use that web app's class
>> loader for any delegation. By having this property, both OSGi bundles should
>> see same log4j classes as the web app.
>>     
>
> Right. I'll try to investigate this a bit more.
>   
Since the parent class loader, which in this case is WebappClassLoader, 
has all the log4j classes, a better alternative would be to configure 
the OSGi framework to export log4j classes and related classes (like 
commons-logging may be) using org.osgi.framework.system.packages system 
property. That way, there is still some control over log4j class loading.

Thanks,
Sahoo

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Karl Pauls <ka...@gmail.com>.
On Mon, Jul 7, 2008 at 4:50 PM, Sahoo <Sa...@sun.com> wrote:
> Karl Pauls wrote:
>>
>> On Mon, Jul 7, 2008 at 4:08 PM, Sahoo <Sa...@sun.com> wrote:
>>
>>>>
>>>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>>>> assignable to a "
>>>>
>>>> org.apache.log4j.Appender" variable.
>>>>
>>>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>>>
>>>> log4j:ERROR [7.0] whereas object of type
>>>>
>>>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>>>> [WebappClassLoader
>>>>
>>>>  delegate: false
>>>>
>>>>
>>>>
>>>
>>> As someone already pointed out, this seems to be the real issue.
>>>
>>
>> Why would that be an issue?
>>
>>
>
> WebappClassLoader, which is what the war uses to load any class, has loaded
> ConsoleAppender as well as the interface Appender. In the OSGi classloading
> space, Appender is loaded by some bundle's class loader. I was thinking that
> somehow the ConsoleAppender as loaded by the application class loader is
> coming in contact with Appender which is loaded by a bundle.

Yes, that is what must be happening. I misunderstood your comment -
thinking that you where referring to the "delegate: false". Now it
makes sense :-)

>>> Try setting the following in felix/config.properties file or whatever
>>> equivalent way to
>>> pass it while invoking Felix using an API:
>>>
>>> org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*
>>> I am not suggesting this as a long term solution, but this can take us
>>> towards the solution.
>>>
>>
>> How?
>>
>>
>
> Since Felix is started by the web app, Felix would use that web app's class
> loader for any delegation. By having this property, both OSGi bundles should
> see same log4j classes as the web app.

Right. I'll try to investigate this a bit more.

regards,

Karl

> Thanks,
> Sahoo
>>
>> regards,
>>
>> Karl
>>
>>
>>>
>>> Thanks,
>>> Sahoo
>>>
>>>
>>
>>
>>
>>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Sahoo <Sa...@Sun.COM>.
Karl Pauls wrote:
> On Mon, Jul 7, 2008 at 4:08 PM, Sahoo <Sa...@sun.com> wrote:
>   
>>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>>> assignable to a "
>>>
>>> org.apache.log4j.Appender" variable.
>>>
>>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>>
>>> log4j:ERROR [7.0] whereas object of type
>>>
>>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>>> [WebappClassLoader
>>>
>>>  delegate: false
>>>
>>>
>>>       
>> As someone already pointed out, this seems to be the real issue.
>>     
>
> Why would that be an issue?
>
>   
WebappClassLoader, which is what the war uses to load any class, has 
loaded ConsoleAppender as well as the interface Appender. In the OSGi 
classloading space, Appender is loaded by some bundle's class loader. I 
was thinking that somehow the ConsoleAppender as loaded by the 
application class loader is coming in contact with Appender which is 
loaded by a bundle.
>> Try setting the following in felix/config.properties file or whatever equivalent way to
>> pass it while invoking Felix using an API:
>>
>> org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*
>> I am not suggesting this as a long term solution, but this can take us
>> towards the solution.
>>     
>
> How?
>
>   
Since Felix is started by the web app, Felix would use that web app's 
class loader for any delegation. By having this property, both OSGi 
bundles should see same log4j classes as the web app.

Thanks,
Sahoo
> regards,
>
> Karl
>
>   
>> Thanks,
>> Sahoo
>>
>>     
>
>
>
>   

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Karl Pauls <ka...@gmail.com>.
On Mon, Jul 7, 2008 at 4:08 PM, Sahoo <Sa...@sun.com> wrote:
>
>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>> assignable to a "
>>
>> org.apache.log4j.Appender" variable.
>>
>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>
>> log4j:ERROR [7.0] whereas object of type
>>
>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>> [WebappClassLoader
>>
>>  delegate: false
>>
>>
>
> As someone already pointed out, this seems to be the real issue.

Why would that be an issue?

> Try setting the following in felix/config.properties file or whatever equivalent way to
> pass it while invoking Felix using an API:
>
> org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*
> I am not suggesting this as a long term solution, but this can take us
> towards the solution.

How?

regards,

Karl

> Thanks,
> Sahoo
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Dennis Geurts <de...@luminis.nl>.
Graig,

We've conjured up a very lightweight wrapper around log4j and made it  
available
to the public...

https://opensource.luminis.net/confluence/display/SITE/OSGi+LogListener+implementation

Might be worthwhile to at least compare its classloading behavior with  
that of the pax implementation.

cheers, Dennis




On 7 jul 2008, at 16:28, Craig Phillips wrote:

<snip>

>
> In the end, I am not a fan of these heavy weight loggers... I'll
> probably just write my own file logger... But, I'll respond to Karl's
> question(s) next...
>
> Thanks, Craig

> <end snip>

RE: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Craig Phillips <lc...@praxiseng.com>.
Hi,

This seemed to work, sort of:

> org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*

There was a class cast exception, as follows:

> ERROR: EventDispatcher: Error during dispatch.
(java.lang.ClassCastException:
org.ops4j.pax.logging.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingS
ervice can not be cast to org.ops4j.pax.logging.PaxLoggingService)

And, some other posthemus weird error from pax:

> org.ops4j.pax.logging.pax-logging-api[org.apache.felix.configadmin] :
[org.osgi.service.log.LogService,org.knopflerfish.service.log.LogService
,org.ops4j.pax.logging.PaxLoggingService,
org.osgi.service.cm.ManagedService]: Unexpected problem updating
configuration java.lang.VerifyError: (class: org/apache/log4j/Hierarchy,
method: updateChildren signature:
(Lorg/apache/log4j/ProvisionNode;Lorg/apache/log4j/Logger;)V)
Incompatible type for getting or setting field

In the end, I am not a fan of these heavy weight loggers... I'll
probably just write my own file logger... But, I'll respond to Karl's
question(s) next...

Thanks, Craig

-----Original Message-----
From: Sanjeeb.Sahoo@Sun.COM [mailto:Sanjeeb.Sahoo@Sun.COM] On Behalf Of
Sahoo
Sent: Monday, July 07, 2008 10:08 AM
To: dev@felix.apache.org
Subject: Re: using pax-logger/log4j in embedded felix (class loader
issue)


> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>   delegate: false
>
>   
As someone already pointed out, this seems to be the real issue. Try 
setting the following in felix/config.properties file or whatever 
equivalent way to pass it while invoking Felix using an API:

org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*


I am not suggesting this as a long term solution, but this can take us 
towards the solution.

Thanks,
Sahoo

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Sahoo <Sa...@Sun.COM>.
> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>   delegate: false
>
>   
As someone already pointed out, this seems to be the real issue. Try 
setting the following in felix/config.properties file or whatever 
equivalent way to pass it while invoking Felix using an API:

org.osgi.framework.bootdelegation=sun.*,com.sun.*, org.apache.log4j.*


I am not suggesting this as a long term solution, but this can take us 
towards the solution.

Thanks,
Sahoo

RE: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Craig Phillips <lc...@praxiseng.com>.
Karl,

I can send you a zip in a few...

Re: strange... yeah... I want to believe that I should not have any
class loader issues in OSGi in that I simply rely on the manifests and
then "world is good"... Of course, I rely on the BND tool, which I
couldn't live without, incidentally (I avoid maven like the plague, but
that's another discussion)...

In my list parameter, I just do the Main.loadProperties() and then add
my Felix config.properties from before....

Now, Pax-Logger et al is very heavyweight, and it uses the following
config:

log4j.rootLogger=DEBUG, A8
log4j.appender.A8=org.apache.log4j.ConsoleAppender
log4j.appender.A8.layout=org.apache.log4j.PatternLayout

I'll try to whip up a zip in a few... thanks, Craig

-----Original Message-----
From: Karl Pauls [mailto:karlpauls@gmail.com] 
Sent: Monday, July 07, 2008 10:11 AM
To: dev@felix.apache.org
Subject: Re: using pax-logger/log4j in embedded felix (class loader
issue)

Strange. Somehow a class is loaded from the outside and then used
inside a bundle...

Are you maybe bridging something from the outside to the inside (maybe
via the list parameter in the felix constructor)?

Can you make an example that fails available to me (either send it to
me directly or create a jira issue and attach it there)?

regards,

Karl

On Mon, Jul 7, 2008 at 1:44 PM, Craig Phillips
<lc...@praxiseng.com> wrote:
> Hi,
>
> Hmmm... looks like the dev mailing list doesn't like attachments...
OK,
> I'll copy/paste the thing in... again, this would work if you run
> felix.jar standalone...  I'm not going to do all the jre entries, they
> go on forever...  Craig
>
> org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0,
\
>  org.osgi.service.packageadmin; version=1.2.0, \
>  org.osgi.service.startlevel; version=1.0.0, \
>  org.osgi.service.url; version=1.0.0, \
>  org.osgi.util.tracker; version=1.3.2 \
>  ${jre-${java.specification.version}}
>
> #
> # LCP - This next section of entries are the entries that are
typically
> edited:
> # file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
> #
> felix.auto.start.1= \
>  file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar
\
>  file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
>  file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
>
>
file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
> jar \
>
file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar
> \
>  file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
>  file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
> felix.cache.profile=felix_starter
> felix.cache.dir=../webapps/craigbox/WEB-INF/felix_cache
> felix.embedded.execution=true
>
> felix.log.level=4
> felix.startlevel.framework=1
> felix.startlevel.bundle=1
> osgi.shell.telnet=on
> #felix.service.urlhandlers=false
> #org.osgi.framework.bootdelegation=sun.*,com.sun.*
>
> #
> # Bundle config properties.
> #
> org.osgi.service.http.port=8080
> osgi.shell.telnet=on
>
#obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=reposi
> tory
>
>
> #
> # Java platform package export properties.
> #
> jre-1.3=, \
>  javax.accessibility; \
>  javax.naming; \
>  javax.naming.directory; \
>  javax.naming.event; \
> etc etc etc
>
> -----Original Message-----
> From: Karl Pauls [mailto:karlpauls@gmail.com]
> Sent: Monday, July 07, 2008 7:33 AM
> To: dev@felix.apache.org
> Subject: Re: using pax-logger/log4j in embedded felix (class loader
> issue)
>
> Could you maybe post your complete config.properties?
>
> regards,
>
> Karl
>
> On Mon, Jul 7, 2008 at 12:59 PM, Craig Phillips
> <lc...@praxiseng.com> wrote:
>> Hi, I probably need to direct this to PAX, but I'll try here (felix
> dev)
>> first... Sorry to trouble you, if anyone with felix class loader
>> intimacy could take a look, I'd be appreciative... for a logger, this
>> isn't critical and I'll probably just write my own simple FileLogger
>> that implements LogService, but I suspect there are bigger issues at
>> play... Some background...
>>
>>
>>
>> I'm embedding felix in a class that is being run within a tomcat
> web-app
>> (dot.jsp initiated - just as a driver/tester); Hence, I'm doing a
'new
>> Felix(map, list)' and invoking the 'felix.start()' method... Here's
my
>> config.properties auto.start list:
>>
>>
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar
> \
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
>>
>>
>
file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
>> jar \
>>
>>
file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar
> \
>>
>> file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
>>
>> file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
>>
>>
>>
>> Anyway, here are the applicable ERROR log entries, seemingly coming
> from
>> pax:
>>
>>
>>
>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>> assignable to a "
>>
>> org.apache.log4j.Appender" variable.
>>
>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>
>> log4j:ERROR [7.0] whereas object of type
>>
>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>> [WebappClassLoader
>>
>>  delegate: false
>>
>>  repositories:
>>
>> ----------> Parent Classloader:
>>
>> org.apache.catalina.loader.StandardClassLoader@d1e604
>>
>> ].
>>
>> log4j:ERROR Could not instantiate appender named "A1".
>>
>> *DEBUG* Scheduling task ManagedService Update:
> pid=org.ops4j.pax.logging
>>
>> *DEBUG* Running task ManagedService Update: pid=org.ops4j.pax.logging
>>
>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>> assignable to a "
>>
>> org.apache.log4j.Appender" variable.
>>
>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>
>> log4j:ERROR [7.0] whereas object of type
>>
>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>> [WebappClassLoader
>>
>>  delegate: false
>>
>>  repositories:
>>
>> ----------> Parent Classloader:
>>
>> org.apache.catalina.loader.StandardClassLoader@d1e604
>>
>> ].
>>
>> log4j:ERROR Could not instantiate appender named "A8".
>>
>> DEBUG: WIRE: 8.0 -> org.osgi.service.log -> 2.0
>>
>> DEBUG: WIRE: 8.0 -> org.craig.shell.telnet -> 8.0
>>
>> DEBUG: WIRE: 8.0 -> org.apache.felix.shell -> 1.0
>>
>> DEBUG: WIRE: 8.0 -> org.osgi.service.component -> 2.0
>>
>> log4j:WARN No appenders could be found for logger
>> (org.ops4j.pax.logging.pax-log
>>
>> ging-service).
>>
>> log4j:WARN Please initialize the log4j system properly.
>>
>> DEBUG: WIRE: 4.0 -> org.osgi.service.log -> 2.0
>>
>>
>>
>> Any insight would be appreciated... not critical, but I suspect I'm
> not
>> going to see the last of class loader issues, especially in an
> embedded
>> environment...  Thanks, Craig Phillips
>>
>>
>>
>>
>
>
>
> --
> Karl Pauls
> karlpauls@gmail.com
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Karl Pauls <ka...@gmail.com>.
Strange. Somehow a class is loaded from the outside and then used
inside a bundle...

Are you maybe bridging something from the outside to the inside (maybe
via the list parameter in the felix constructor)?

Can you make an example that fails available to me (either send it to
me directly or create a jira issue and attach it there)?

regards,

Karl

On Mon, Jul 7, 2008 at 1:44 PM, Craig Phillips <lc...@praxiseng.com> wrote:
> Hi,
>
> Hmmm... looks like the dev mailing list doesn't like attachments... OK,
> I'll copy/paste the thing in... again, this would work if you run
> felix.jar standalone...  I'm not going to do all the jre entries, they
> go on forever...  Craig
>
> org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \
>  org.osgi.service.packageadmin; version=1.2.0, \
>  org.osgi.service.startlevel; version=1.0.0, \
>  org.osgi.service.url; version=1.0.0, \
>  org.osgi.util.tracker; version=1.3.2 \
>  ${jre-${java.specification.version}}
>
> #
> # LCP - This next section of entries are the entries that are typically
> edited:
> # file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
> #
> felix.auto.start.1= \
>  file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar \
>  file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
>  file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
> jar \
>  file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar
> \
>  file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
>  file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
> felix.cache.profile=felix_starter
> felix.cache.dir=../webapps/craigbox/WEB-INF/felix_cache
> felix.embedded.execution=true
>
> felix.log.level=4
> felix.startlevel.framework=1
> felix.startlevel.bundle=1
> osgi.shell.telnet=on
> #felix.service.urlhandlers=false
> #org.osgi.framework.bootdelegation=sun.*,com.sun.*
>
> #
> # Bundle config properties.
> #
> org.osgi.service.http.port=8080
> osgi.shell.telnet=on
> #obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=reposi
> tory
>
>
> #
> # Java platform package export properties.
> #
> jre-1.3=, \
>  javax.accessibility; \
>  javax.naming; \
>  javax.naming.directory; \
>  javax.naming.event; \
> etc etc etc
>
> -----Original Message-----
> From: Karl Pauls [mailto:karlpauls@gmail.com]
> Sent: Monday, July 07, 2008 7:33 AM
> To: dev@felix.apache.org
> Subject: Re: using pax-logger/log4j in embedded felix (class loader
> issue)
>
> Could you maybe post your complete config.properties?
>
> regards,
>
> Karl
>
> On Mon, Jul 7, 2008 at 12:59 PM, Craig Phillips
> <lc...@praxiseng.com> wrote:
>> Hi, I probably need to direct this to PAX, but I'll try here (felix
> dev)
>> first... Sorry to trouble you, if anyone with felix class loader
>> intimacy could take a look, I'd be appreciative... for a logger, this
>> isn't critical and I'll probably just write my own simple FileLogger
>> that implements LogService, but I suspect there are bigger issues at
>> play... Some background...
>>
>>
>>
>> I'm embedding felix in a class that is being run within a tomcat
> web-app
>> (dot.jsp initiated - just as a driver/tester); Hence, I'm doing a 'new
>> Felix(map, list)' and invoking the 'felix.start()' method... Here's my
>> config.properties auto.start list:
>>
>>
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar
> \
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
>>
>>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
>> jar \
>>
>> file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar
> \
>>
>> file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
>>
>> file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
>>
>> file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
>>
>>
>>
>> Anyway, here are the applicable ERROR log entries, seemingly coming
> from
>> pax:
>>
>>
>>
>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>> assignable to a "
>>
>> org.apache.log4j.Appender" variable.
>>
>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>
>> log4j:ERROR [7.0] whereas object of type
>>
>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>> [WebappClassLoader
>>
>>  delegate: false
>>
>>  repositories:
>>
>> ----------> Parent Classloader:
>>
>> org.apache.catalina.loader.StandardClassLoader@d1e604
>>
>> ].
>>
>> log4j:ERROR Could not instantiate appender named "A1".
>>
>> *DEBUG* Scheduling task ManagedService Update:
> pid=org.ops4j.pax.logging
>>
>> *DEBUG* Running task ManagedService Update: pid=org.ops4j.pax.logging
>>
>> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
>> assignable to a "
>>
>> org.apache.log4j.Appender" variable.
>>
>> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>>
>> log4j:ERROR [7.0] whereas object of type
>>
>> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
>> [WebappClassLoader
>>
>>  delegate: false
>>
>>  repositories:
>>
>> ----------> Parent Classloader:
>>
>> org.apache.catalina.loader.StandardClassLoader@d1e604
>>
>> ].
>>
>> log4j:ERROR Could not instantiate appender named "A8".
>>
>> DEBUG: WIRE: 8.0 -> org.osgi.service.log -> 2.0
>>
>> DEBUG: WIRE: 8.0 -> org.craig.shell.telnet -> 8.0
>>
>> DEBUG: WIRE: 8.0 -> org.apache.felix.shell -> 1.0
>>
>> DEBUG: WIRE: 8.0 -> org.osgi.service.component -> 2.0
>>
>> log4j:WARN No appenders could be found for logger
>> (org.ops4j.pax.logging.pax-log
>>
>> ging-service).
>>
>> log4j:WARN Please initialize the log4j system properly.
>>
>> DEBUG: WIRE: 4.0 -> org.osgi.service.log -> 2.0
>>
>>
>>
>> Any insight would be appreciated... not critical, but I suspect I'm
> not
>> going to see the last of class loader issues, especially in an
> embedded
>> environment...  Thanks, Craig Phillips
>>
>>
>>
>>
>
>
>
> --
> Karl Pauls
> karlpauls@gmail.com
>



-- 
Karl Pauls
karlpauls@gmail.com

RE: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Craig Phillips <lc...@praxiseng.com>.
Hi,

Hmmm... looks like the dev mailing list doesn't like attachments... OK,
I'll copy/paste the thing in... again, this would work if you run
felix.jar standalone...  I'm not going to do all the jre entries, they
go on forever...  Craig

org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \
 org.osgi.service.packageadmin; version=1.2.0, \
 org.osgi.service.startlevel; version=1.0.0, \
 org.osgi.service.url; version=1.0.0, \
 org.osgi.util.tracker; version=1.3.2 \
 ${jre-${java.specification.version}}

#
# LCP - This next section of entries are the entries that are typically
edited:
# file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
#
felix.auto.start.1= \
 file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar \
 file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
 file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
 
file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
jar \
 file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar
\
 file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
 file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
felix.cache.profile=felix_starter
felix.cache.dir=../webapps/craigbox/WEB-INF/felix_cache
felix.embedded.execution=true

felix.log.level=4
felix.startlevel.framework=1
felix.startlevel.bundle=1
osgi.shell.telnet=on
#felix.service.urlhandlers=false
#org.osgi.framework.bootdelegation=sun.*,com.sun.*

#
# Bundle config properties.
#
org.osgi.service.http.port=8080
osgi.shell.telnet=on
#obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=reposi
tory


#
# Java platform package export properties.
#
jre-1.3=, \
 javax.accessibility; \
 javax.naming; \
 javax.naming.directory; \
 javax.naming.event; \
etc etc etc

-----Original Message-----
From: Karl Pauls [mailto:karlpauls@gmail.com] 
Sent: Monday, July 07, 2008 7:33 AM
To: dev@felix.apache.org
Subject: Re: using pax-logger/log4j in embedded felix (class loader
issue)

Could you maybe post your complete config.properties?

regards,

Karl

On Mon, Jul 7, 2008 at 12:59 PM, Craig Phillips
<lc...@praxiseng.com> wrote:
> Hi, I probably need to direct this to PAX, but I'll try here (felix
dev)
> first... Sorry to trouble you, if anyone with felix class loader
> intimacy could take a look, I'd be appreciative... for a logger, this
> isn't critical and I'll probably just write my own simple FileLogger
> that implements LogService, but I suspect there are bigger issues at
> play... Some background...
>
>
>
> I'm embedding felix in a class that is being run within a tomcat
web-app
> (dot.jsp initiated - just as a driver/tester); Hence, I'm doing a 'new
> Felix(map, list)' and invoking the 'felix.start()' method... Here's my
> config.properties auto.start list:
>
>
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar
\
>
> file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
>
>
file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
> jar \
>
> file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar
\
>
> file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
>
>
>
> Anyway, here are the applicable ERROR log entries, seemingly coming
from
> pax:
>
>
>
> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>  delegate: false
>
>  repositories:
>
> ----------> Parent Classloader:
>
> org.apache.catalina.loader.StandardClassLoader@d1e604
>
> ].
>
> log4j:ERROR Could not instantiate appender named "A1".
>
> *DEBUG* Scheduling task ManagedService Update:
pid=org.ops4j.pax.logging
>
> *DEBUG* Running task ManagedService Update: pid=org.ops4j.pax.logging
>
> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>  delegate: false
>
>  repositories:
>
> ----------> Parent Classloader:
>
> org.apache.catalina.loader.StandardClassLoader@d1e604
>
> ].
>
> log4j:ERROR Could not instantiate appender named "A8".
>
> DEBUG: WIRE: 8.0 -> org.osgi.service.log -> 2.0
>
> DEBUG: WIRE: 8.0 -> org.craig.shell.telnet -> 8.0
>
> DEBUG: WIRE: 8.0 -> org.apache.felix.shell -> 1.0
>
> DEBUG: WIRE: 8.0 -> org.osgi.service.component -> 2.0
>
> log4j:WARN No appenders could be found for logger
> (org.ops4j.pax.logging.pax-log
>
> ging-service).
>
> log4j:WARN Please initialize the log4j system properly.
>
> DEBUG: WIRE: 4.0 -> org.osgi.service.log -> 2.0
>
>
>
> Any insight would be appreciated... not critical, but I suspect I'm
not
> going to see the last of class loader issues, especially in an
embedded
> environment...  Thanks, Craig Phillips
>
>
>
>



-- 
Karl Pauls
karlpauls@gmail.com

RE: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Craig Phillips <lc...@praxiseng.com>.
Hi, Attached... Craig

PS - Note: this basic setup works fine if you run felix.jar standalone;
I think the key error log entry is:
whereas object of type "org.apache.log4j.ConsoleAppender" was loaded by
[WebappClassLoader

-----Original Message-----
From: Karl Pauls [mailto:karlpauls@gmail.com] 
Sent: Monday, July 07, 2008 7:33 AM
To: dev@felix.apache.org
Subject: Re: using pax-logger/log4j in embedded felix (class loader
issue)

Could you maybe post your complete config.properties?

regards,

Karl

On Mon, Jul 7, 2008 at 12:59 PM, Craig Phillips
<lc...@praxiseng.com> wrote:
> Hi, I probably need to direct this to PAX, but I'll try here (felix
dev)
> first... Sorry to trouble you, if anyone with felix class loader
> intimacy could take a look, I'd be appreciative... for a logger, this
> isn't critical and I'll probably just write my own simple FileLogger
> that implements LogService, but I suspect there are bigger issues at
> play... Some background...
>
>
>
> I'm embedding felix in a class that is being run within a tomcat
web-app
> (dot.jsp initiated - just as a driver/tester); Hence, I'm doing a 'new
> Felix(map, list)' and invoking the 'felix.start()' method... Here's my
> config.properties auto.start list:
>
>
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar
\
>
> file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
>
>
file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
> jar \
>
> file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar
\
>
> file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
>
>
>
> Anyway, here are the applicable ERROR log entries, seemingly coming
from
> pax:
>
>
>
> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>  delegate: false
>
>  repositories:
>
> ----------> Parent Classloader:
>
> org.apache.catalina.loader.StandardClassLoader@d1e604
>
> ].
>
> log4j:ERROR Could not instantiate appender named "A1".
>
> *DEBUG* Scheduling task ManagedService Update:
pid=org.ops4j.pax.logging
>
> *DEBUG* Running task ManagedService Update: pid=org.ops4j.pax.logging
>
> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>  delegate: false
>
>  repositories:
>
> ----------> Parent Classloader:
>
> org.apache.catalina.loader.StandardClassLoader@d1e604
>
> ].
>
> log4j:ERROR Could not instantiate appender named "A8".
>
> DEBUG: WIRE: 8.0 -> org.osgi.service.log -> 2.0
>
> DEBUG: WIRE: 8.0 -> org.craig.shell.telnet -> 8.0
>
> DEBUG: WIRE: 8.0 -> org.apache.felix.shell -> 1.0
>
> DEBUG: WIRE: 8.0 -> org.osgi.service.component -> 2.0
>
> log4j:WARN No appenders could be found for logger
> (org.ops4j.pax.logging.pax-log
>
> ging-service).
>
> log4j:WARN Please initialize the log4j system properly.
>
> DEBUG: WIRE: 4.0 -> org.osgi.service.log -> 2.0
>
>
>
> Any insight would be appreciated... not critical, but I suspect I'm
not
> going to see the last of class loader issues, especially in an
embedded
> environment...  Thanks, Craig Phillips
>
>
>
>



-- 
Karl Pauls
karlpauls@gmail.com

Re: using pax-logger/log4j in embedded felix (class loader issue)

Posted by Karl Pauls <ka...@gmail.com>.
Could you maybe post your complete config.properties?

regards,

Karl

On Mon, Jul 7, 2008 at 12:59 PM, Craig Phillips
<lc...@praxiseng.com> wrote:
> Hi, I probably need to direct this to PAX, but I'll try here (felix dev)
> first... Sorry to trouble you, if anyone with felix class loader
> intimacy could take a look, I'd be appreciative... for a logger, this
> isn't critical and I'll probably just write my own simple FileLogger
> that implements LogService, but I suspect there are bigger issues at
> play... Some background...
>
>
>
> I'm embedding felix in a class that is being run within a tomcat web-app
> (dot.jsp initiated - just as a driver/tester); Hence, I'm doing a 'new
> Felix(map, list)' and invoking the 'felix.start()' method... Here's my
> config.properties auto.start list:
>
>
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.shell-1.0.1.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.osgi.compendium-1.0.1.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.scr-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.apache.felix.configadmin-1.0.1.
> jar \
>
> file:../webapps/craigbox/WEB-INF/lib/pax-confman-propsloader-0.2.1.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/pax-logging-api-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/pax-logging-service-1.0.0.jar \
>
> file:../webapps/craigbox/WEB-INF/lib/org.craig.play.Play01.jar
>
>
>
> Anyway, here are the applicable ERROR log entries, seemingly coming from
> pax:
>
>
>
> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>  delegate: false
>
>  repositories:
>
> ----------> Parent Classloader:
>
> org.apache.catalina.loader.StandardClassLoader@d1e604
>
> ].
>
> log4j:ERROR Could not instantiate appender named "A1".
>
> *DEBUG* Scheduling task ManagedService Update: pid=org.ops4j.pax.logging
>
> *DEBUG* Running task ManagedService Update: pid=org.ops4j.pax.logging
>
> log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
> assignable to a "
>
> org.apache.log4j.Appender" variable.
>
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
>
> log4j:ERROR [7.0] whereas object of type
>
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader
>
>  delegate: false
>
>  repositories:
>
> ----------> Parent Classloader:
>
> org.apache.catalina.loader.StandardClassLoader@d1e604
>
> ].
>
> log4j:ERROR Could not instantiate appender named "A8".
>
> DEBUG: WIRE: 8.0 -> org.osgi.service.log -> 2.0
>
> DEBUG: WIRE: 8.0 -> org.craig.shell.telnet -> 8.0
>
> DEBUG: WIRE: 8.0 -> org.apache.felix.shell -> 1.0
>
> DEBUG: WIRE: 8.0 -> org.osgi.service.component -> 2.0
>
> log4j:WARN No appenders could be found for logger
> (org.ops4j.pax.logging.pax-log
>
> ging-service).
>
> log4j:WARN Please initialize the log4j system properly.
>
> DEBUG: WIRE: 4.0 -> org.osgi.service.log -> 2.0
>
>
>
> Any insight would be appreciated... not critical, but I suspect I'm not
> going to see the last of class loader issues, especially in an embedded
> environment...  Thanks, Craig Phillips
>
>
>
>



-- 
Karl Pauls
karlpauls@gmail.com