Code Monkey home page Code Monkey logo

Comments (12)

hazendaz avatar hazendaz commented on May 30, 2024

Would dropping javax.mail in tomcat lib work for you?

Sent by Outlook for Android

On Mon, Jul 20, 2015 at 5:25 PM -0700, "kbjp" [email protected] wrote:
Hi,
Could someone tell me know how I can use of the STMPAppender in combination with tomcat-slf4j-logback ? (I'm getting "java.lang.ClassNotFoundException: javax.mail.internet.AddressException").
Ideally, I would also like to use the STMPAppender in my deployed web applications as well.
(the idea being to send an email notification for any caught or uncaught appilcation errors)
Thank you very much in advance for your feedback.
Regards
kbjp


Reply to this email directly or view it on GitHub:
#68

from tomcat-slf4j-logback.

ntjp avatar ntjp commented on May 30, 2024

sharing the mail jar between tomcat and the deployed applications works but that requires a special build for each web app which excludes mail.jar from the war file...Ideally, I would like to be able to just drop the full war (including mail.jar) into tomcat and have it work as-is.

from tomcat-slf4j-logback.

hazendaz avatar hazendaz commented on May 30, 2024

I take it adding this in WAR is causing issue in not allowing it to work properly. Is it possibly you could create a small demo we can check out to see how best to address this? I don’t know that you really need to exclude the mail jar at webapp level. Classloader should only load one anyways. If we bring it into this build which is already pretty large, we would want to shade it to avoid classpath issues. I’m not exactly sure that is worth the effort. Keep in mind I personally have mail jar running in my own productionized tomcats in the tomcat lib directory. Most of the projects I work on are maven based so it’s a simply notation to make it provided scope and assume tomcat will have the jar.

@grgrzybek – any thoughts on this?

From: kbjp [mailto:[email protected]]
Sent: Tuesday, July 21, 2015 8:06 PM
To: grgrzybek/tomcat-slf4j-logback
Cc: Jeremy Landis
Subject: Re: [tomcat-slf4j-logback] How to make use of the SMTPAppender ? (#68)

sharing the mail jar between tomcat and the deployed applications works but that requires a special build for each web app which excludes mail.jar from the war file...Ideally, I would like to be able to just drop the full war (including mail.jar) into tomcat and have it work as-is.


Reply to this email directly or view it on GitHub #68 (comment) . https://github.com/notifications/beacon/AA7ho3iZnjlMrt7HHj6fCrz2RK2HkoK8ks5oftXbgaJpZM4FcYjL.gif

from tomcat-slf4j-logback.

grgrzybek avatar grgrzybek commented on May 30, 2024

@kbjp entire tomcat-slf4j-logback works by shadowing org.slf4j and ch.qos.logback packages, so what Tomcat core sees is actually different set of packages. And it's working fine without conflicts with slf4j/logback JARs in your WAR.
To make it work the same with javax.mail, we'd have to shadow javax.mail as well.

If you drop mail.jar into $TOMCAT_HOME/lib, it'll be visible to all web applications and to Tomcat itself.
What happens if you have the same version of mail.jar in both $TOMCAT_HOME/lib and in WEB-INF/lib of the WAR?

from tomcat-slf4j-logback.

ntjp avatar ntjp commented on May 30, 2024

if I just put mail.jar in the lib folder, I still get a classnotfound exception linked to mail.jar during instantiation/construction of the SMTPAppender linked to tomcat. The only way it works for me is if I make mail.jar part of the classpath inside setenv.bat (using win7 + tomcat8 + java8)

Would it be possible to know if you've successfully managed to use an SMTPappender linked to tomcat itself by just putting mail.jar in the lib folder ?
Regards
kbjp

from tomcat-slf4j-logback.

grgrzybek avatar grgrzybek commented on May 30, 2024

OK, I know - you're getting ClassNotFoundException, because $TOMCAT_HOME/bin/tomcat-juli.jar is loaded earlier than class loader for $TOMCAT_HOME/lib is set.
That's why you have to add it to setenv.bat. I think that when you do it, having mail.jar in WEB-INF/lib won't do any harm.

from tomcat-slf4j-logback.

ntjp avatar ntjp commented on May 30, 2024

If I also keep the mail.jar in my application war in addition to bin folder + setenv classpath (don't want to put it in tomcat'slib folder as during development I use another web server: undertow, not tomcat), the stmpappender for tomcat itself seems to stop working.
So, as initially discussed, I end up needing a dev profile and a prod profile (where mail.jar is listed as provided). ..I was still hoping for a solution where mail.jar could be part of the war file at any time.

from tomcat-slf4j-logback.

grgrzybek avatar grgrzybek commented on May 30, 2024

If you want to have mail.jar in WAR, there's no way Tomcat would see it.
I don't have good solution for you, I'd use SMTPAppender for logging configuration in WAR and have e-mails being sent when error occurs in web application.
I wonder why Tomcat doesn't use setenv provided mail.jar - I guess it is related to awfully static nature of javax.mail - it's full of static fields and methods.

from tomcat-slf4j-logback.

ntjp avatar ntjp commented on May 30, 2024

The whole idea is that if an application uncaught exception bubbles up into tomcat, I still want tomcat to notify me about the problem by sending me an email (which is why I end up needing 2 STMP-appenders: one for caught exceptions at the app level and one for uncaught exceptions at the tomcat level)...
I have something working already; I was just hoping for something simpler...Anyway, thanks a lot for the feedback.

from tomcat-slf4j-logback.

grgrzybek avatar grgrzybek commented on May 30, 2024

I usually like to tackle such issues, but I have too much other work to do now before my holidays ;)
In your case, I'd prefer having single, application-wide uncaught exception resolver - that's quite easy to do if you have Spring-based application

from tomcat-slf4j-logback.

ntjp avatar ntjp commented on May 30, 2024

yes...Spring is nice...Unfortunately the legacy app I'm currently dealing with is GWT (google-web-toolkit), and in it I have to cater for uncaught exceptions. :-(
Anyway, thanks a lot once again for taking time to provide feedback.

from tomcat-slf4j-logback.

hazendaz avatar hazendaz commented on May 30, 2024

Closing issue as it appears the discussion is complete.

from tomcat-slf4j-logback.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.