log4j
Is it possible to use log4j in karaf ? I have log4j classes in my bundle but I cant access them: try { Class? aClass = Class.forName(org.apache.log4j.Appender); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api [4] ... Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api [4] at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787) at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26] at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645) at org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99) at org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390) at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722) at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26] at java.lang.Class.forName0(Native Method)[:1.6.0_26] at java.lang.Class.forName(Class.java:169)[:1.6.0_26] -- View this message in context: http://karaf.922171.n3.nabble.com/log4j-tp3958839.html Sent from the Karaf - User mailing list archive at Nabble.com.
Re: log4j
I'm not sure what you are trying to do, but log4j as slf4j and a couple more logging framworks are supported by Karaf. We use Pax Logging for this, log4j is even the underlying implementation for logging. If you want to use your own appenders you need to take special care for this. Regards, Achim 2012/5/3 maaruks maris.orbid...@gmail.com: Is it possible to use log4j in karaf ? I have log4j classes in my bundle but I cant access them: try { Class? aClass = Class.forName(org.apache.log4j.Appender); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api [4] ... Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api [4] at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787) at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26] at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645) at org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99) at org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390) at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722) at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26] at java.lang.Class.forName0(Native Method)[:1.6.0_26] at java.lang.Class.forName(Class.java:169)[:1.6.0_26] -- View this message in context: http://karaf.922171.n3.nabble.com/log4j-tp3958839.html Sent from the Karaf - User mailing list archive at Nabble.com. -- Apache Karaf http://karaf.apache.org/ Committer PMC OPS4J Pax Web http://wiki.ops4j.org/display/paxweb/Pax+Web/ Committer Project Lead OPS4J Pax Vaadin http://team.ops4j.org/wiki/display/PAXVAADIN/Home Commiter Project Lead blog http://notizblog.nierbeck.de/
Re: log4j
Custom appenders can be deployed by using fragments attached to the pax-logging-service bundle fwiw. On Thu, May 3, 2012 at 1:21 PM, Achim Nierbeck bcanh...@googlemail.comwrote: I'm not sure what you are trying to do, but log4j as slf4j and a couple more logging framworks are supported by Karaf. We use Pax Logging for this, log4j is even the underlying implementation for logging. If you want to use your own appenders you need to take special care for this. Regards, Achim 2012/5/3 maaruks maris.orbid...@gmail.com: Is it possible to use log4j in karaf ? I have log4j classes in my bundle but I cant access them: try { Class? aClass = Class.forName(org.apache.log4j.Appender); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api [4] ... Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api [4] at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787) at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26] at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645) at org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99) at org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390) at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722) at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26] at java.lang.Class.forName0(Native Method)[:1.6.0_26] at java.lang.Class.forName(Class.java:169)[:1.6.0_26] -- View this message in context: http://karaf.922171.n3.nabble.com/log4j-tp3958839.html Sent from the Karaf - User mailing list archive at Nabble.com. -- Apache Karaf http://karaf.apache.org/ Committer PMC OPS4J Pax Web http://wiki.ops4j.org/display/paxweb/Pax+Web/ Committer Project Lead OPS4J Pax Vaadin http://team.ops4j.org/wiki/display/PAXVAADIN/Home Commiter Project Lead blog http://notizblog.nierbeck.de/ -- Guillaume Nodet Blog: http://gnodet.blogspot.com/ FuseSource, Integration everywhere http://fusesource.com
Re: Is there a way to query osgi framework status (e.g. started)?
Hi, you can add a BundleListener and check if the state of the bundle of ID 0. Anyway it looks weird to me to define some logic at startup. Why not using a bootFeature or a startup bundle ? Regards JB On 05/03/2012 05:28 PM, bobshort wrote: We have bundles that do some intensive processing. Right now they are starting as the framework is starting and slowing startup down considerably. The osgi container is running on a plug computer so resources are minimal. I want to start my processing only after the osgi container is fully started. I've implemented a framework listener to detect when the framework is started and then trigger my startup logic: /public class EventListener implements FrameworkListener { @Override public void frameworkEvent(FrameworkEvent event) { if (event.getType() == FrameworkEvent.STARTED) { // Do startup logic here. } } }/ This works if my bundles are installed before the framework is started, but it obviously does not work for modules installed after the framework is started. Is there any way I can query the framework status from my bundle so I can detect if the container is already fully started when the bundle is installed? I'd like to do something like: / public void onBundleStarted() { if (**test if framework already running**) { // Do startup logic here. } } / Is this possible? -- View this message in context: http://karaf.922171.n3.nabble.com/Is-there-a-way-to-query-osgi-framework-status-e-g-started-tp3959588.html Sent from the Karaf - User mailing list archive at Nabble.com. -- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com
Re: Is there a way to query osgi framework status (e.g. started)?
There's no such thing as a 'started' state. The osgi framework is fully asynchronous and things can even be done on behalf of other bundles. The only real way to know if 'something' is started is to have this thing register an osgi service when started and wait for this service to be registered. A lot of bundles do behave in this way so that you have inter-bundles dependencies using services. But at the end, 'started' depends on what meaning you put behind this word, and that mostly depends on what you deploy. On Thu, May 3, 2012 at 5:28 PM, bobshort jer...@check-it.ca wrote: We have bundles that do some intensive processing. Right now they are starting as the framework is starting and slowing startup down considerably. The osgi container is running on a plug computer so resources are minimal. I want to start my processing only after the osgi container is fully started. I've implemented a framework listener to detect when the framework is started and then trigger my startup logic: /public class EventListener implements FrameworkListener { @Override public void frameworkEvent(FrameworkEvent event) { if (event.getType() == FrameworkEvent.STARTED) { // Do startup logic here. } } }/ This works if my bundles are installed before the framework is started, but it obviously does not work for modules installed after the framework is started. Is there any way I can query the framework status from my bundle so I can detect if the container is already fully started when the bundle is installed? I'd like to do something like: / public void onBundleStarted() { if (**test if framework already running**) { // Do startup logic here. } } / Is this possible? -- View this message in context: http://karaf.922171.n3.nabble.com/Is-there-a-way-to-query-osgi-framework-status-e-g-started-tp3959588.html Sent from the Karaf - User mailing list archive at Nabble.com. -- Guillaume Nodet Blog: http://gnodet.blogspot.com/ FuseSource, Integration everywhere http://fusesource.com
Re: Is there a way to query osgi framework status (e.g. started)?
Thanks for the replies! The main thing I'm trying to accomplish is to not start expensive processing while the framework is booting. On a embedded ARM device it can take framework startup times from 2 min to +5 min. I was thinking of trying a bundle with a very high run level and use it to signal all other bundles to start. I'll give that go and see how well it works. -- View this message in context: http://karaf.922171.n3.nabble.com/Is-there-a-way-to-query-osgi-framework-status-e-g-started-tp3959588p3959787.html Sent from the Karaf - User mailing list archive at Nabble.com.