karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Hendley <shend...@greenenergycorp.com>
Subject Re: Using Log4j mail appender in Karaf with pax logging
Date Wed, 20 Jul 2011 13:38:53 GMT
Thanks guys, I was able to get emails working with pax-logging and karaf.

I tried exporting the javax.mail packages in jre.properties as suggested by
Mike but I was getting the same error. I tried Jean's suggestion of loading
the osgi packaged version of javax.mail and that worked, log4j would
correctly start.

However when it tried to actually send an email I got errors like:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
multipart/mixed;

This was due to the javax.activation package exposed by the jre not working.
Servicemix has created an OSGI friendly version of this package. I had to
comment out the javax.activation export from jre.properties and load the
following feature:

<feature name="javax-mail-in-osgi">
  <bundle>mvn:javax.mail/mail/1.4.3</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/1.7.0</bundle>
</feature>

Thanks for the quick response! I was close to the solution but could have
easily burnt half a day trying different permutations.

Sam

On Tue, Jul 19, 2011 at 1:47 AM, Jean-Baptiste Onofré <jb@nanthrax.net>wrote:

> Hi,
>
> You have to install javax.mail bundle. This bundle is part of the jetty
> feature or you can install by hand:
>
> osgi:install mvn:javax.mail/mail/1.4.3
>
> Regards
> JB
>
>
> On 07/19/2011 01:01 AM, Sam Hendley wrote:
>
>> 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 <http://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.**findClassOrResourceByDelegatio*
>> *n(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<http://forums.pragprog.com/forums/103/topics/3736>
>>
>> General javax.mail in OSGi writeup
>> http://thecarlhall.wordpress.**com/2009/10/27/javamail-in-**osgi/<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<http://camel.465427.n5.nabble.com/new-wiki-page-notes-on-mail-and-osgi-td4557069.html>
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Mime
View raw message