27 Oct 2008

Fixing log4j email notification under ubuntu

I had a problem under ubuntu to use log4j email notification through SMTPAppender.

The problem:

java.lang.NoClassDefFoundError: gnu/inet/util/GetSystemPropertyAction
at javax.mail.internet.ParameterList.(ParameterList.java:72)
at javax.mail.internet.ContentType.(ContentType.java:104)
at gnu.mail.handler.Text.getJavaCharset(Text.java:160)
at gnu.mail.handler.Text.writeTo(Text.java:140)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:868)
...


Solution:

I think :
apt-get remove libgnuinet-java

is enough but this is the exact command I had to run:
apt-get remove libgnuinet-java libgnujaf-java libgnumail-java-doc


Env:
Jetty 6, java 6, log4j 1.2.15 + commons-logging 1.1

Log4j conf:

log4j.rootLogger=INFO, CONSOLE, FILE, EMAIL
# EMAIL
log4j.appender.EMAIL=org.apache.log4j.net.SMTPAppender
log4j.appender.EMAIL.SMTPHost=xxx
log4j.appender.EMAIL.From=xxx@xx.com
log4j.appender.EMAIL.To=xxx@xx.com
# log4j.appender.EMAIL.SMTPUsername=xxx
# log4j.appender.EMAIL.SMTPPassword=xxx
log4j.appender.EMAIL.Subject=[MyApp] Application Error
log4j.appender.EMAIL.layout=org.apache.log4j.PatternLayout
log4j.appender.EMAIL.layout.ConversionPattern=[%d] [%t] %-5p %c %x - %m%n
log4j.appender.EMAIL.Threshold=ERROR
log4j.appender.EMAIL.BufferSize=1
# log4j.appender.EMAIL.SMTPDebug=true


I'm also using sun jvm using this command:
update-java-alternatives --set java-6-sun

No comments: