karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Hendley <shend...@greenenergycorp.com>
Subject Using Log4j mail appender in Karaf with pax logging
Date Mon, 18 Jul 2011 23:01:03 GMT
Is it possible to use the log4j email appenders in karaf?

I have been googling for a few hours and I have seen a number of partial
answers but nothing definative one way or the other.

Here is my SMTP appender configuration in org.ops4j.pax.logging.cfg

log4j.appender.MAIL=org.apache.log4j.net.SMTPAppender
log4j.appender.MAIL.BufferSize=10
log4j.appender.MAIL.SMTPHost=xxxxx
log4j.appender.MAIL.From=xxxxxx
log4j.appender.MAIL.to=xxxxx
log4j.appender.MAIL.Subject=Error Alert
log4j.appender.MAIL.layout=org.apache.log4j.PatternLayout
log4j.appender.MAIL.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

and the exception I get:

Jul 18, 2011 6:43:50 PM org.apache.karaf.main.SimpleFileLock lock
INFO: locking
18 Jul 2011 18:43:50,484 ERROR [CM Configuration Updater (ManagedService
Update: pid=org.ops4j.pax.logging)] org.apache.felix.configadmin (?:   ?)
[org.osgi.service.log.LogService, org.knopflerfish.service.log.LogService,
org.ops4j.pax.logging.PaxLoggingService, org.osgi.service.cm.ManagedService,
id=8, bundle=4]: Unexpected problem updating Configuration
PID=org.ops4j.pax.logging, factoryPID=null,
bundleLocation=mvn:org.ops4j.pax.logging/pax-logging-service/1.6.3-LOCATION
java.lang.NoClassDefFoundError: javax/mail/MessagingException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
at
org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)
at
org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at
org.apache.log4j.PaxLoggingConfigurator.parseAppender(PaxLoggingConfigurator.java:81)
at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
at
org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
at
org.apache.log4j.PaxLoggingConfigurator.doConfigure(PaxLoggingConfigurator.java:57)
at
org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:187)
at
org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:321)
at
org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1160)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:104)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
not found by org.ops4j.pax.logging.pax-logging-service [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:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 15 more

This seems to indicate that the log4j SMTPAppender class is being found
correctly but then it cannot resolve the javax.mail package.

What is the best way to get the javax.mail package available to the pax
logging bundle? I found a number of postings that indicated this requires an
update to the jre or config properties file but I hesitate to start randomly
changing things I dont understand.

Thanks!

Sam Hendley

PS: The following are the pages I found that seem to relate to this topic:

Eclispe specific way of adding javax.mail
http://forums.pragprog.com/forums/103/topics/3736

General javax.mail in OSGi writeup
http://thecarlhall.wordpress.com/2009/10/27/javamail-in-osgi/

Using javax.mail in OSGi from camel list
http://camel.465427.n5.nabble.com/new-wiki-page-notes-on-mail-and-osgi-td4557069.html

Mime
View raw message