You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by Guillaume Nodet <gn...@gmail.com> on 2010/10/22 10:51:57 UTC

Logging problems when karaf deploeyd as a WAR (was Re: AW: AW: Manual using scalate now in svn)

On Fri, Oct 22, 2010 at 10:23, Charles Moulliard <cm...@gmail.com>wrote:

> In your case, we need to make sure pax-logging doesn't loads it's classes
> by itself, but uses the one provided by the surrounding jetty-war-class
> loader.
>


That won't work, because pax-logging uses some modified version of the
classes.  It's exactly the same problem if you have a jar in the parent
webserver classloader but need to use a different version in the war itself.
  How do you do that ? You hack the classloader through some webserver
specific hacks.   I'm quite confident it's possible for all the webservers /
jee servers, but there's simply no standard way to do that.

One *possible* way, would be to create our own classloader that would
completely shield karaf from the webapp server.  It might be possible, not
sure though.


>
>
> >> This is correct
>
> Remark : Smx4 can be started when deployed as a WAR file in Jetty/Tomcat
> except that we have a Blueprint error which is not at related to logging
> issue. Even if pax-log does not work in Smx4/Karaf, the log messages are
> redirected to the stdout of the console of jetty/Tomcat but servicemix.log
> stays empty.
>
>
> On 22/10/10 10:15, Achim Nierbeck wrote:
>
>> Charles,
>>
>> but isn't it even worse in your case,
>> you have a jetty (war-class loader) where the Karaf/Servicemix is running
>> as a war file.
>> In this war file you have the pax-logging framework, which isn't working
>> (at least that's my summary of the other thread :) )
>>
>> The issue here is, I have Karaf as Runtime with all the class loaders, and
>> I'm deploying a war file within Karaf. Here we do have a class loader for
>> the war application in which we are loading the log4j stuff, which might end
>> up with a class cast exception since the same class was loaded by different
>> class loaders (number one is pax-logging-class loader and second is the
>> war-class loader)
>>
>> In your case, we need to make sure pax-logging doesn't loads it's classes
>> by itself, but uses the one provided by the surrounding jetty-war-class
>> loader.
>>
>> Please correct me if I did mix something up here :)
>>
>> Cheers,
>> Achim
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Charles Moulliard [mailto:cmoulliard@gmail.com]
>> Gesendet: Freitag, 22. Oktober 2010 10:08
>> An: dev@karaf.apache.org
>> Betreff: Re: AW: Manual using scalate now in svn
>>
>> Achim,
>>
>> The question of question is very important and interesting because we
>> have the following issue when we launch Jetty Web Server containing the
>> WAR file of ServiceMix (= OSGI Server using Apache Felix or Eclipse
>> Equinox). In this case, the logging mechanism of ServiceMix relying on
>> pax-log does not work because log4j class is loaded twice (first time by
>> Jetty and next by pax-log).
>>
>> Regards,
>>
>> Charles
>>
>> On 22/10/10 10:02, Achim Nierbeck wrote:
>>
>>> About the patch, I can look into this probably this evening, or later
>>> this weekend :)
>>> About the pax-logging with the war I have to see into this, but this
>>> sounds like a good, idea.
>>> Even though I'm unsure if the war contains log4j jars how would the
>>> application be able to log out to a file since the initial logging is
>>> configured through the pax-logging. Wouldn't it end up with a class cast
>>> exception because of different class loaders? I think I saw something like
>>> this a couple of weeks ago :)
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Guillaume Nodet [mailto:gnodet@gmail.com]
>>> Gesendet: Freitag, 22. Oktober 2010 09:58
>>> An: dev@karaf.apache.org
>>> Betreff: Re: Manual using scalate now in svn
>>>
>>> Btw, do you think you could provide a patch to update karaf to pax-web
>>> trunk
>>> ?
>>> That would be awesome.
>>>
>>> On a side note, I wonder if we should add to the war url handler a simple
>>> option to import the pax-logging packages automatically (though with a
>>> resolution:=optional) to avoid problems if the war include a log4j or
>>> slf4j
>>> jar for example.  I think this would make deploying wars easier.
>>>  Thoughts ?
>>>
>>> On Fri, Oct 22, 2010 at 09:52, Achim Nierbeck<Ac...@ptv.de>
>>> wrote:
>>>
>>>  +1 for the documentation, great job!
>>>>
>>>> One side node from me concerning the war deployer, with the next pax-web
>>>> the deployer is contained in the pax-web project :)
>>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Guillaume Nodet [mailto:gnodet@gmail.com]
>>>> Gesendet: Freitag, 22. Oktober 2010 07:40
>>>> An: dev@karaf.apache.org
>>>> Betreff: Re: Manual using scalate now in svn
>>>>
>>>> The style is now up to date.
>>>>
>>>> On Fri, Oct 22, 2010 at 03:37, Freeman Fang<fr...@gmail.com>
>>>> wrote:
>>>>
>>>>  +1
>>>>>
>>>>> Thanks
>>>>> Freeman
>>>>>
>>>>> On 2010-10-22, at 上午12:09, Guillaume Nodet wrote:
>>>>>
>>>>>   I think the styling has not been synced yet.  The styling should not
>>>>>
>>>> have
>>>>
>>>>> any red or gray, it's mostly black and blue.
>>>>>>
>>>>>> On Thu, Oct 21, 2010 at 17:55, Charles Moulliard<cmoulliard@gmail.com
>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>   Excellent job. I would like to suggest that we use a different color
>>>>>> or
>>>>>>
>>>>>>> font for the code / console screen. All the text is grey and does not
>>>>>>> allow
>>>>>>> to make clear content separation.
>>>>>>>
>>>>>>>
>>>>>>> On 21/10/10 17:45, Guillaume Nodet wrote:
>>>>>>>
>>>>>>>   I've deployed a snapshot of the karaf manual with the new styling,
>>>>>>> so
>>>>>>>
>>>>>> it
>>>>
>>>>> should be available at in one hour or so (after the mirrors have been
>>>>>>>> updated):
>>>>>>>>   http://karaf.apache.org/manual/2.1.99-SNAPSHOT/index.html
>>>>>>>>
>>>>>>>> Let me know what you think.
>>>>>>>>
>>>>>>>> On Tue, Oct 19, 2010 at 09:25, Guillaume Nodet<gn...@gmail.com>
>>>>>>>>   wrote:
>>>>>>>>
>>>>>>>> I've updated the manual to use the same template / css than the web
>>>>>>>> site,
>>>>>>>>
>>>>>>>>  so that it looks way better now.
>>>>>>>>> That makes we think we deseperatly need  a logo for Karaf ...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Oct 18, 2010 at 10:25, Guillaume Nodet<gn...@gmail.com>
>>>>>>>>>   wrote:
>>>>>>>>>
>>>>>>>>> I've committed the project i've been working on github so far in
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>  main
>>>>>>>>>> svn are, in trunk/documentation.
>>>>>>>>>> In order to keep that up-to-date with each version, I'd ask anyone
>>>>>>>>>>
>>>>>>>>> to
>>>>
>>>>> keep
>>>>>>>>>> it in sync when you modify / add a new feature in Karaf.
>>>>>>>>>> Note that this manual includes an auto-generated section
>>>>>>>>>> containing
>>>>>>>>>> all
>>>>>>>>>> the commands, so we could try to improve the help for those.
>>>>>>>>>> It can be done by adding the following attribute on the annotation
>>>>>>>>>>
>>>>>>>>> as
>>>>
>>>>> it's
>>>>>>>>>> done in the grep command
>>>>>>>>>>
>>>>>>>>>>   @Command(...., detailedDescription="classpath:grep.txt")
>>>>>>>>>>
>>>>>>>>>> And then a file in
>>>>>>>>>>   org/apache/karaf/shell/commands/grep.txt
>>>>>>>>>> The file is loaded from the command class (hence it's
>>>>>>>>>> automatically
>>>>>>>>>> prefixed by the package name, unless an absolute uri is used).
>>>>>>>>>>
>>>>>>>>>> I guess we could try to auto-discover this file too btw.
>>>>>>>>>>
>>>>>>>>>> The manual is not fully complete and there are still sections to
>>>>>>>>>> review
>>>>>>>>>> /
>>>>>>>>>> fill, so feel free to have a look at those.
>>>>>>>>>>
>>>>>>>>>> Also, I'll try to publish a snapshot and have it linked from the
>>>>>>>>>>
>>>>>>>>> main
>>>>
>>>>> web
>>>>>>>>>> site and use it instead of the wiki based manuals, so that we'll
>>>>>>>>>>
>>>>>>>>> have
>>>>
>>>>> easier
>>>>>>>>>> versioning.
>>>>>>>>>> But we need to come up with a better design for the web pages and
>>>>>>>>>>
>>>>>>>>> add
>>>>
>>>>> a
>>>>>>>>>> pdf output.  Help welcome!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Cheers,
>>>>>>>>>> Guillaume Nodet
>>>>>>>>>> ------------------------
>>>>>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>>>>>> ------------------------
>>>>>>>>>> Open Source SOA
>>>>>>>>>> http://fusesource.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>   --
>>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Guillaume Nodet
>>>>>>>>> ------------------------
>>>>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>>>>> ------------------------
>>>>>>>>> Open Source SOA
>>>>>>>>> http://fusesource.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  --
>>>>>> Cheers,
>>>>>> Guillaume Nodet
>>>>>> ------------------------
>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>> ------------------------
>>>>>> Open Source SOA
>>>>>> http://fusesource.com
>>>>>>
>>>>>>  --
>>>>> Freeman Fang
>>>>>
>>>>> ------------------------
>>>>> blog: http://freemanfang.blogspot.com
>>>>> twitter: http://twitter.com/freemanfang
>>>>>
>>>>> Open Source SOA: http://fusesource.com
>>>>> Apache Servicemix:http://servicemix.apache.org
>>>>> Apache Cxf: http://cxf.apache.org
>>>>> Apache Karaf: http://karaf.apache.org
>>>>> Apache Felix: http://felix.apache.org
>>>>>
>>>>>
>>>>>  --
>>>> Cheers,
>>>> Guillaume Nodet
>>>> ------------------------
>>>> Blog: http://gnodet.blogspot.com/
>>>> ------------------------
>>>> Open Source SOA
>>>> http://fusesource.com
>>>>
>>>>
>>>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: AW: Logging problems when karaf deployed as a WAR (was Re: AW: AW: Manual using scalate now in svn)

Posted by Achim Nierbeck <bc...@googlemail.com>.
OK, 

since I was curious, I did look for the cocoon-paranoid stuff :)
It's not a classloader anymore it is a servlet, acting like a paranoid
classloader. 
So you might just take a look at the following:

http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/servlet/ParanoidCocoonServlet.html

Greetings, Achim


Achim Nierbeck-2 wrote:
> 
> About the shielding, I think I saw something like this in one of our apps.
> With one of our Apps we specifically use a different Classloader. I think
> it is one provided by the Cocoon-Engine (or had been provided), it was
> called cocoon-paranoid or something like that. 
> As far as I can remember this Classloader loads first the classes provided
> by the war archive and after that delegates to the parent loader, and so
> forth. It's quite some time ago since I took some deeper insight into this
> loader, but I think this one might solve this issue. 
> 
> -----Ursprüngliche Nachricht-----
> Von: Guillaume Nodet [mailto:gnodet@gmail.com] 
> Gesendet: Freitag, 22. Oktober 2010 10:52
> An: dev@karaf.apache.org
> Betreff: Logging problems when karaf deploeyd as a WAR (was Re: AW: AW:
> Manual using scalate now in svn)
> 
> On Fri, Oct 22, 2010 at 10:23, Charles Moulliard
> <cm...@gmail.com>wrote:
> 
>> In your case, we need to make sure pax-logging doesn't loads it's classes
>> by itself, but uses the one provided by the surrounding jetty-war-class
>> loader.
>>
> 
> 
> That won't work, because pax-logging uses some modified version of the
> classes.  It's exactly the same problem if you have a jar in the parent
> webserver classloader but need to use a different version in the war
> itself.
>   How do you do that ? You hack the classloader through some webserver
> specific hacks.   I'm quite confident it's possible for all the webservers
> /
> jee servers, but there's simply no standard way to do that.
> 
> One *possible* way, would be to create our own classloader that would
> completely shield karaf from the webapp server.  It might be possible, not
> sure though.
> 
> 
>>
>>
>> >> This is correct
>>
>> Remark : Smx4 can be started when deployed as a WAR file in Jetty/Tomcat
>> except that we have a Blueprint error which is not at related to logging
>> issue. Even if pax-log does not work in Smx4/Karaf, the log messages are
>> redirected to the stdout of the console of jetty/Tomcat but
>> servicemix.log
>> stays empty.
>>
>>
>> On 22/10/10 10:15, Achim Nierbeck wrote:
>>
>>> Charles,
>>>
>>> but isn't it even worse in your case,
>>> you have a jetty (war-class loader) where the Karaf/Servicemix is
>>> running
>>> as a war file.
>>> In this war file you have the pax-logging framework, which isn't working
>>> (at least that's my summary of the other thread :) )
>>>
>>> The issue here is, I have Karaf as Runtime with all the class loaders,
>>> and
>>> I'm deploying a war file within Karaf. Here we do have a class loader
>>> for
>>> the war application in which we are loading the log4j stuff, which might
>>> end
>>> up with a class cast exception since the same class was loaded by
>>> different
>>> class loaders (number one is pax-logging-class loader and second is the
>>> war-class loader)
>>>
>>> In your case, we need to make sure pax-logging doesn't loads it's
>>> classes
>>> by itself, but uses the one provided by the surrounding jetty-war-class
>>> loader.
>>>
>>> Please correct me if I did mix something up here :)
>>>
>>> Cheers,
>>> Achim
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Charles Moulliard [mailto:cmoulliard@gmail.com]
>>> Gesendet: Freitag, 22. Oktober 2010 10:08
>>> An: dev@karaf.apache.org
>>> Betreff: Re: AW: Manual using scalate now in svn
>>>
>>> Achim,
>>>
>>> The question of question is very important and interesting because we
>>> have the following issue when we launch Jetty Web Server containing the
>>> WAR file of ServiceMix (= OSGI Server using Apache Felix or Eclipse
>>> Equinox). In this case, the logging mechanism of ServiceMix relying on
>>> pax-log does not work because log4j class is loaded twice (first time by
>>> Jetty and next by pax-log).
>>>
>>> Regards,
>>>
>>> Charles
>>>
>>> On 22/10/10 10:02, Achim Nierbeck wrote:
>>>
>>>> About the patch, I can look into this probably this evening, or later
>>>> this weekend :)
>>>> About the pax-logging with the war I have to see into this, but this
>>>> sounds like a good, idea.
>>>> Even though I'm unsure if the war contains log4j jars how would the
>>>> application be able to log out to a file since the initial logging is
>>>> configured through the pax-logging. Wouldn't it end up with a class
>>>> cast
>>>> exception because of different class loaders? I think I saw something
>>>> like
>>>> this a couple of weeks ago :)
>>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Guillaume Nodet [mailto:gnodet@gmail.com]
>>>> Gesendet: Freitag, 22. Oktober 2010 09:58
>>>> An: dev@karaf.apache.org
>>>> Betreff: Re: Manual using scalate now in svn
>>>>
>>>> Btw, do you think you could provide a patch to update karaf to pax-web
>>>> trunk
>>>> ?
>>>> That would be awesome.
>>>>
>>>> On a side note, I wonder if we should add to the war url handler a
>>>> simple
>>>> option to import the pax-logging packages automatically (though with a
>>>> resolution:=optional) to avoid problems if the war include a log4j or
>>>> slf4j
>>>> jar for example.  I think this would make deploying wars easier.
>>>>  Thoughts ?
>>>>
>>>> On Fri, Oct 22, 2010 at 09:52, Achim Nierbeck<Ac...@ptv.de>
>>>> wrote:
>>>>
>>>>  +1 for the documentation, great job!
>>>>>
>>>>> One side node from me concerning the war deployer, with the next
>>>>> pax-web
>>>>> the deployer is contained in the pax-web project :)
>>>>>
>>>>> -----Ursprüngliche Nachricht-----
>>>>> Von: Guillaume Nodet [mailto:gnodet@gmail.com]
>>>>> Gesendet: Freitag, 22. Oktober 2010 07:40
>>>>> An: dev@karaf.apache.org
>>>>> Betreff: Re: Manual using scalate now in svn
>>>>>
>>>>> The style is now up to date.
>>>>>
>>>>> On Fri, Oct 22, 2010 at 03:37, Freeman Fang<fr...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>  +1
>>>>>>
>>>>>> Thanks
>>>>>> Freeman
>>>>>>
>>>>>> On 2010-10-22, at 上午12:09, Guillaume Nodet wrote:
>>>>>>
>>>>>>   I think the styling has not been synced yet.  The styling should
>>>>>> not
>>>>>>
>>>>> have
>>>>>
>>>>>> any red or gray, it's mostly black and blue.
>>>>>>>
>>>>>>> On Thu, Oct 21, 2010 at 17:55, Charles
>>>>>>> Moulliard<cmoulliard@gmail.com
>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>   Excellent job. I would like to suggest that we use a different
>>>>>>> color
>>>>>>> or
>>>>>>>
>>>>>>>> font for the code / console screen. All the text is grey and does
>>>>>>>> not
>>>>>>>> allow
>>>>>>>> to make clear content separation.
>>>>>>>>
>>>>>>>>
>>>>>>>> On 21/10/10 17:45, Guillaume Nodet wrote:
>>>>>>>>
>>>>>>>>   I've deployed a snapshot of the karaf manual with the new
>>>>>>>> styling,
>>>>>>>> so
>>>>>>>>
>>>>>>> it
>>>>>
>>>>>> should be available at in one hour or so (after the mirrors have been
>>>>>>>>> updated):
>>>>>>>>>   http://karaf.apache.org/manual/2.1.99-SNAPSHOT/index.html
>>>>>>>>>
>>>>>>>>> Let me know what you think.
>>>>>>>>>
>>>>>>>>> On Tue, Oct 19, 2010 at 09:25, Guillaume Nodet<gn...@gmail.com>
>>>>>>>>>   wrote:
>>>>>>>>>
>>>>>>>>> I've updated the manual to use the same template / css than the
>>>>>>>>> web
>>>>>>>>> site,
>>>>>>>>>
>>>>>>>>>  so that it looks way better now.
>>>>>>>>>> That makes we think we deseperatly need  a logo for Karaf ...
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mon, Oct 18, 2010 at 10:25, Guillaume Nodet<gn...@gmail.com>
>>>>>>>>>>   wrote:
>>>>>>>>>>
>>>>>>>>>> I've committed the project i've been working on github so far in
>>>>>>>>>> the
>>>>>>>>>>
>>>>>>>>>>  main
>>>>>>>>>>> svn are, in trunk/documentation.
>>>>>>>>>>> In order to keep that up-to-date with each version, I'd ask
>>>>>>>>>>> anyone
>>>>>>>>>>>
>>>>>>>>>> to
>>>>>
>>>>>> keep
>>>>>>>>>>> it in sync when you modify / add a new feature in Karaf.
>>>>>>>>>>> Note that this manual includes an auto-generated section
>>>>>>>>>>> containing
>>>>>>>>>>> all
>>>>>>>>>>> the commands, so we could try to improve the help for those.
>>>>>>>>>>> It can be done by adding the following attribute on the
>>>>>>>>>>> annotation
>>>>>>>>>>>
>>>>>>>>>> as
>>>>>
>>>>>> it's
>>>>>>>>>>> done in the grep command
>>>>>>>>>>>
>>>>>>>>>>>   @Command(...., detailedDescription="classpath:grep.txt")
>>>>>>>>>>>
>>>>>>>>>>> And then a file in
>>>>>>>>>>>   org/apache/karaf/shell/commands/grep.txt
>>>>>>>>>>> The file is loaded from the command class (hence it's
>>>>>>>>>>> automatically
>>>>>>>>>>> prefixed by the package name, unless an absolute uri is used).
>>>>>>>>>>>
>>>>>>>>>>> I guess we could try to auto-discover this file too btw.
>>>>>>>>>>>
>>>>>>>>>>> The manual is not fully complete and there are still sections to
>>>>>>>>>>> review
>>>>>>>>>>> /
>>>>>>>>>>> fill, so feel free to have a look at those.
>>>>>>>>>>>
>>>>>>>>>>> Also, I'll try to publish a snapshot and have it linked from the
>>>>>>>>>>>
>>>>>>>>>> main
>>>>>
>>>>>> web
>>>>>>>>>>> site and use it instead of the wiki based manuals, so that we'll
>>>>>>>>>>>
>>>>>>>>>> have
>>>>>
>>>>>> easier
>>>>>>>>>>> versioning.
>>>>>>>>>>> But we need to come up with a better design for the web pages
>>>>>>>>>>> and
>>>>>>>>>>>
>>>>>>>>>> add
>>>>>
>>>>>> a
>>>>>>>>>>> pdf output.  Help welcome!
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Cheers,
>>>>>>>>>>> Guillaume Nodet
>>>>>>>>>>> ------------------------
>>>>>>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>>>>>>> ------------------------
>>>>>>>>>>> Open Source SOA
>>>>>>>>>>> http://fusesource.com
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>   --
>>>>>>>>>>>
>>>>>>>>>> Cheers,
>>>>>>>>>> Guillaume Nodet
>>>>>>>>>> ------------------------
>>>>>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>>>>>> ------------------------
>>>>>>>>>> Open Source SOA
>>>>>>>>>> http://fusesource.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  --
>>>>>>> Cheers,
>>>>>>> Guillaume Nodet
>>>>>>> ------------------------
>>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>>> ------------------------
>>>>>>> Open Source SOA
>>>>>>> http://fusesource.com
>>>>>>>
>>>>>>>  --
>>>>>> Freeman Fang
>>>>>>
>>>>>> ------------------------
>>>>>> blog: http://freemanfang.blogspot.com
>>>>>> twitter: http://twitter.com/freemanfang
>>>>>>
>>>>>> Open Source SOA: http://fusesource.com
>>>>>> Apache Servicemix:http://servicemix.apache.org
>>>>>> Apache Cxf: http://cxf.apache.org
>>>>>> Apache Karaf: http://karaf.apache.org
>>>>>> Apache Felix: http://felix.apache.org
>>>>>>
>>>>>>
>>>>>>  --
>>>>> Cheers,
>>>>> Guillaume Nodet
>>>>> ------------------------
>>>>> Blog: http://gnodet.blogspot.com/
>>>>> ------------------------
>>>>> Open Source SOA
>>>>> http://fusesource.com
>>>>>
>>>>>
>>>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
> 
> 

-- 
View this message in context: http://karaf.922171.n3.nabble.com/Logging-problems-when-karaf-deploeyd-as-a-WAR-was-Re-AW-AW-Manual-using-scalate-now-in-svn-tp1751361p1755467.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

AW: Logging problems when karaf deployed as a WAR (was Re: AW: AW: Manual using scalate now in svn)

Posted by Achim Nierbeck <Ac...@ptv.de>.
About the shielding, I think I saw something like this in one of our apps. With one of our Apps we specifically use a different Classloader. I think it is one provided by the Cocoon-Engine (or had been provided), it was called cocoon-paranoid or something like that. 
As far as I can remember this Classloader loads first the classes provided by the war archive and after that delegates to the parent loader, and so forth. It's quite some time ago since I took some deeper insight into this loader, but I think this one might solve this issue. 

-----Ursprüngliche Nachricht-----
Von: Guillaume Nodet [mailto:gnodet@gmail.com] 
Gesendet: Freitag, 22. Oktober 2010 10:52
An: dev@karaf.apache.org
Betreff: Logging problems when karaf deploeyd as a WAR (was Re: AW: AW: Manual using scalate now in svn)

On Fri, Oct 22, 2010 at 10:23, Charles Moulliard <cm...@gmail.com>wrote:

> In your case, we need to make sure pax-logging doesn't loads it's classes
> by itself, but uses the one provided by the surrounding jetty-war-class
> loader.
>


That won't work, because pax-logging uses some modified version of the
classes.  It's exactly the same problem if you have a jar in the parent
webserver classloader but need to use a different version in the war itself.
  How do you do that ? You hack the classloader through some webserver
specific hacks.   I'm quite confident it's possible for all the webservers /
jee servers, but there's simply no standard way to do that.

One *possible* way, would be to create our own classloader that would
completely shield karaf from the webapp server.  It might be possible, not
sure though.


>
>
> >> This is correct
>
> Remark : Smx4 can be started when deployed as a WAR file in Jetty/Tomcat
> except that we have a Blueprint error which is not at related to logging
> issue. Even if pax-log does not work in Smx4/Karaf, the log messages are
> redirected to the stdout of the console of jetty/Tomcat but servicemix.log
> stays empty.
>
>
> On 22/10/10 10:15, Achim Nierbeck wrote:
>
>> Charles,
>>
>> but isn't it even worse in your case,
>> you have a jetty (war-class loader) where the Karaf/Servicemix is running
>> as a war file.
>> In this war file you have the pax-logging framework, which isn't working
>> (at least that's my summary of the other thread :) )
>>
>> The issue here is, I have Karaf as Runtime with all the class loaders, and
>> I'm deploying a war file within Karaf. Here we do have a class loader for
>> the war application in which we are loading the log4j stuff, which might end
>> up with a class cast exception since the same class was loaded by different
>> class loaders (number one is pax-logging-class loader and second is the
>> war-class loader)
>>
>> In your case, we need to make sure pax-logging doesn't loads it's classes
>> by itself, but uses the one provided by the surrounding jetty-war-class
>> loader.
>>
>> Please correct me if I did mix something up here :)
>>
>> Cheers,
>> Achim
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Charles Moulliard [mailto:cmoulliard@gmail.com]
>> Gesendet: Freitag, 22. Oktober 2010 10:08
>> An: dev@karaf.apache.org
>> Betreff: Re: AW: Manual using scalate now in svn
>>
>> Achim,
>>
>> The question of question is very important and interesting because we
>> have the following issue when we launch Jetty Web Server containing the
>> WAR file of ServiceMix (= OSGI Server using Apache Felix or Eclipse
>> Equinox). In this case, the logging mechanism of ServiceMix relying on
>> pax-log does not work because log4j class is loaded twice (first time by
>> Jetty and next by pax-log).
>>
>> Regards,
>>
>> Charles
>>
>> On 22/10/10 10:02, Achim Nierbeck wrote:
>>
>>> About the patch, I can look into this probably this evening, or later
>>> this weekend :)
>>> About the pax-logging with the war I have to see into this, but this
>>> sounds like a good, idea.
>>> Even though I'm unsure if the war contains log4j jars how would the
>>> application be able to log out to a file since the initial logging is
>>> configured through the pax-logging. Wouldn't it end up with a class cast
>>> exception because of different class loaders? I think I saw something like
>>> this a couple of weeks ago :)
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Guillaume Nodet [mailto:gnodet@gmail.com]
>>> Gesendet: Freitag, 22. Oktober 2010 09:58
>>> An: dev@karaf.apache.org
>>> Betreff: Re: Manual using scalate now in svn
>>>
>>> Btw, do you think you could provide a patch to update karaf to pax-web
>>> trunk
>>> ?
>>> That would be awesome.
>>>
>>> On a side note, I wonder if we should add to the war url handler a simple
>>> option to import the pax-logging packages automatically (though with a
>>> resolution:=optional) to avoid problems if the war include a log4j or
>>> slf4j
>>> jar for example.  I think this would make deploying wars easier.
>>>  Thoughts ?
>>>
>>> On Fri, Oct 22, 2010 at 09:52, Achim Nierbeck<Ac...@ptv.de>
>>> wrote:
>>>
>>>  +1 for the documentation, great job!
>>>>
>>>> One side node from me concerning the war deployer, with the next pax-web
>>>> the deployer is contained in the pax-web project :)
>>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Guillaume Nodet [mailto:gnodet@gmail.com]
>>>> Gesendet: Freitag, 22. Oktober 2010 07:40
>>>> An: dev@karaf.apache.org
>>>> Betreff: Re: Manual using scalate now in svn
>>>>
>>>> The style is now up to date.
>>>>
>>>> On Fri, Oct 22, 2010 at 03:37, Freeman Fang<fr...@gmail.com>
>>>> wrote:
>>>>
>>>>  +1
>>>>>
>>>>> Thanks
>>>>> Freeman
>>>>>
>>>>> On 2010-10-22, at 上午12:09, Guillaume Nodet wrote:
>>>>>
>>>>>   I think the styling has not been synced yet.  The styling should not
>>>>>
>>>> have
>>>>
>>>>> any red or gray, it's mostly black and blue.
>>>>>>
>>>>>> On Thu, Oct 21, 2010 at 17:55, Charles Moulliard<cmoulliard@gmail.com
>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>   Excellent job. I would like to suggest that we use a different color
>>>>>> or
>>>>>>
>>>>>>> font for the code / console screen. All the text is grey and does not
>>>>>>> allow
>>>>>>> to make clear content separation.
>>>>>>>
>>>>>>>
>>>>>>> On 21/10/10 17:45, Guillaume Nodet wrote:
>>>>>>>
>>>>>>>   I've deployed a snapshot of the karaf manual with the new styling,
>>>>>>> so
>>>>>>>
>>>>>> it
>>>>
>>>>> should be available at in one hour or so (after the mirrors have been
>>>>>>>> updated):
>>>>>>>>   http://karaf.apache.org/manual/2.1.99-SNAPSHOT/index.html
>>>>>>>>
>>>>>>>> Let me know what you think.
>>>>>>>>
>>>>>>>> On Tue, Oct 19, 2010 at 09:25, Guillaume Nodet<gn...@gmail.com>
>>>>>>>>   wrote:
>>>>>>>>
>>>>>>>> I've updated the manual to use the same template / css than the web
>>>>>>>> site,
>>>>>>>>
>>>>>>>>  so that it looks way better now.
>>>>>>>>> That makes we think we deseperatly need  a logo for Karaf ...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Oct 18, 2010 at 10:25, Guillaume Nodet<gn...@gmail.com>
>>>>>>>>>   wrote:
>>>>>>>>>
>>>>>>>>> I've committed the project i've been working on github so far in
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>  main
>>>>>>>>>> svn are, in trunk/documentation.
>>>>>>>>>> In order to keep that up-to-date with each version, I'd ask anyone
>>>>>>>>>>
>>>>>>>>> to
>>>>
>>>>> keep
>>>>>>>>>> it in sync when you modify / add a new feature in Karaf.
>>>>>>>>>> Note that this manual includes an auto-generated section
>>>>>>>>>> containing
>>>>>>>>>> all
>>>>>>>>>> the commands, so we could try to improve the help for those.
>>>>>>>>>> It can be done by adding the following attribute on the annotation
>>>>>>>>>>
>>>>>>>>> as
>>>>
>>>>> it's
>>>>>>>>>> done in the grep command
>>>>>>>>>>
>>>>>>>>>>   @Command(...., detailedDescription="classpath:grep.txt")
>>>>>>>>>>
>>>>>>>>>> And then a file in
>>>>>>>>>>   org/apache/karaf/shell/commands/grep.txt
>>>>>>>>>> The file is loaded from the command class (hence it's
>>>>>>>>>> automatically
>>>>>>>>>> prefixed by the package name, unless an absolute uri is used).
>>>>>>>>>>
>>>>>>>>>> I guess we could try to auto-discover this file too btw.
>>>>>>>>>>
>>>>>>>>>> The manual is not fully complete and there are still sections to
>>>>>>>>>> review
>>>>>>>>>> /
>>>>>>>>>> fill, so feel free to have a look at those.
>>>>>>>>>>
>>>>>>>>>> Also, I'll try to publish a snapshot and have it linked from the
>>>>>>>>>>
>>>>>>>>> main
>>>>
>>>>> web
>>>>>>>>>> site and use it instead of the wiki based manuals, so that we'll
>>>>>>>>>>
>>>>>>>>> have
>>>>
>>>>> easier
>>>>>>>>>> versioning.
>>>>>>>>>> But we need to come up with a better design for the web pages and
>>>>>>>>>>
>>>>>>>>> add
>>>>
>>>>> a
>>>>>>>>>> pdf output.  Help welcome!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Cheers,
>>>>>>>>>> Guillaume Nodet
>>>>>>>>>> ------------------------
>>>>>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>>>>>> ------------------------
>>>>>>>>>> Open Source SOA
>>>>>>>>>> http://fusesource.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>   --
>>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Guillaume Nodet
>>>>>>>>> ------------------------
>>>>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>>>>> ------------------------
>>>>>>>>> Open Source SOA
>>>>>>>>> http://fusesource.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  --
>>>>>> Cheers,
>>>>>> Guillaume Nodet
>>>>>> ------------------------
>>>>>> Blog: http://gnodet.blogspot.com/
>>>>>> ------------------------
>>>>>> Open Source SOA
>>>>>> http://fusesource.com
>>>>>>
>>>>>>  --
>>>>> Freeman Fang
>>>>>
>>>>> ------------------------
>>>>> blog: http://freemanfang.blogspot.com
>>>>> twitter: http://twitter.com/freemanfang
>>>>>
>>>>> Open Source SOA: http://fusesource.com
>>>>> Apache Servicemix:http://servicemix.apache.org
>>>>> Apache Cxf: http://cxf.apache.org
>>>>> Apache Karaf: http://karaf.apache.org
>>>>> Apache Felix: http://felix.apache.org
>>>>>
>>>>>
>>>>>  --
>>>> Cheers,
>>>> Guillaume Nodet
>>>> ------------------------
>>>> Blog: http://gnodet.blogspot.com/
>>>> ------------------------
>>>> Open Source SOA
>>>> http://fusesource.com
>>>>
>>>>
>>>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com