AuthenticationFailedException when using JNDI and JavaMail with SMTP auth

Hi all - I've been banging my head on this one for awhile now - hopefully someone else has done this.
We are working in a servlet container (tomcat), and need obtain a mail session from JNDI. We do this as follows:
               Context initCtx = new InitialContext();
               Context envCtx = (Context) initCtx.lookup("java:comp/env");
               Session mailSession=(Session) envCtx.lookup("mailSession/trumpetinc");so far so good. The jndi entry for the mail session is configured in server.xml as follows:
          <Resource name="mailSession/trumpetinc" scope="Shareable" type="javax.mail.Session"/>
          <ResourceParams name="mailSession/trumpetinc">
            <parameter>
              <name>mail.smtp.host</name>
              <value>mail.server.com</value>
            </parameter>
            <parameter>
              <name>mail.smtp.password</name>
              <value>ABCDEFG</value>
            </parameter>
            <parameter>
              <name>mail.smtp.user</name>
              <value>trumpet_kevin</value>
            </parameter>
         <parameter>
           <name>mail.smtp.auth</name>
           <value>true</value>
         </parameter>
          </ResourceParams>With the above, whenever we hit Transport.send(msg), we got an AuthenticationFailedException thrown. I have run into this before with SMTP authentication, so I decided to try using the transport.sendMessage() method instead.
So, I get the transport:
Transport trans = mailSession.getTransport("smtp");
trans.connect();Then I send my message using:
msg.saveChanges();
trans.sendMessage(msg, msg.getAllRecipients());and finally, I close the transport:
trans.close();Unfortunately, I'm still getting the exception. Is it possible that my connect() method is not picking up the JNDI properties set in the server.xml file (this seems likely)? If so, what's the best way for me to get those properties so I can set them explicitly in the connect() method?
Thanks in advance,
- Kevin

Hi,
I have faced the same problem and after some googling and trying I have discovered what causes the AuthenticationFailedException exception. I just wanted to share the knowedge maybe it will be helpfull to others.
Here it is what the API says:
To use SMTP authentication you'll need to set the mail.smtp.auth property (see below) and provide the SMTP Transport with a username and password when connecting to the SMTP server. You can do this using one of the following approaches:
1.Provide an Authenticator object when creating your mail Session and provide the username and password information during the Authenticator callback.
Note that the mail.smtp.user property can be set to provide a default username for the callback, but the password will still need to be supplied explicitly.
This approach allows you to use the static Transport send method to send messages.
2.Call the Transport connect method explicitly with username and password arguments.
This approach requires you to explicitly manage a Transport object and use the Transport sendMessage method to send the message. The transport.java demo program demonstrates how to manage a Transport object. The following is roughly equivalent to the static Transport send method, but supplies the needed username and password:
Using the Transport.connect makes the JNDI not very helpfull for configuration.
It seems that using just the mail.smtp.user and mail.smtp.pass is not sufficient for the authentication.
so, the solution is :
just place these to lines in the JNDI configuration:
          username="test"
          password="test1"
so it should looks as follows:
          <Resource name="mail/Session" auth="Container"
          type="javax.mail.Session"
          username="test"
          password="test1"
          mail.transport.protocol="smtp"
          mail.smtp.auth="true"     
          mail.smtp.host="localhost"
          mail.smtp.port="25"
          mail.smtp.user="test"
          mail.smtp.password="test1"
/>
where test and test1 are the user's credentials
Regards,
Kiril
Message was edited by:
Kireto
Message was edited by:
Kireto

Similar Messages

  • Delay when using doubletap and hold with bootcamp 5

    Hi,
    I just bought a 15" MBPro and discoverd a delay when I use doubletap and hold to scroll or to mark text or drag. Is this a know problem of the bootcamp trackpad driver?
    Hoping for answers
    Bye
    Michael

    I have the same problem, except that I'm using the Apple Trackpad in Windows 8 in Boot Camp on a 2012 iMac, so my guess is that the driver is to blame.

  • AUTH Command is not enabled, when try to enable webmail with smtp auth

    Hi,
    I'm trying to force all the webmail users to authenticate (smtp auth) when they send an email.
    I already configure this:
    local.service.http.smtpauthpassword = xxxxx
    local.service.http.smtpauthuser = admin
    and reload the http service. (the password is correct)
    Then, enter to the webmail interface and tried to sent an email but when pressed "sent" the following message appears:
    SMTP: Error 5.7.1 AUTH Command is not enabled.
    Do I have to do something else? Any lead?
    Regards

    Thanks Jay,
    I know about the little use of the webmail authentication but it is something I need to do because in my configuration I have to differentiate between users who can send emails to internet and users who can not, and in order to do that, I need to authenticate all the users. So far is working if the user uses an email client.
    For webmail I did not know that I have to add in the tcp_intranet channel definition the attribute: mustsaslserver.

  • When using printer Epson R1900 with Aperture 3 and if I mistakenly choose the wrong paper such as, epson's luster instead of glossy, does that change the exposure? Like make it too dark one or two stops!

    When using printer Epson R1900 with Aperture 3 and if I mistakenly choose the wrong paper such as, epson's luster instead of glossy, does that change the exposure? Like make it too dark one or two stops!

    Hi,
       If you choose the incorrect settings for printing, yes - the print quality will be affected.
    Different papers absorb the ink differently, so you can end up with prints that are too light, too dark, or have a colour cast if you make incorrect choices in your Aperture or printer settings.

  • When using google and you do a new search it goes back to previous search only happens with fireox

    when using google and you do a new search it goes back to previous search only happens with fireox

    Try to connect to iTunes during the setup.

  • How do I close a JInternalFrame when using subclasses and a separate cla...

    The heading should be: How do I close a JInternalFrame when using subclasses and a separate class for the actionListener?
    I have just created a JInternalFrame appclication and now I want to structure up my code. I have a Superclass that contains the usual settings for the two JInternalFrame:s, and the two subclasses with frame specific information. Both the JInternalFrames use the same OK button. I want to have the actionListener outside the classes to avoid repetition of code. But the dispose()-function does not work properly, it does not close the opened JInternalFrame. What�s wrong?
    class Superclass extends JFrame
         JButton b= new JButton("ok");    
         Superclass()
    class Subclass1 extends Superclass
         Subclass1 ()
              add(ok);
           ok.addActionListener(new Listener());
    class Subclass2 extends Superclass
         Subclass2 ()
              add(ok);
           ok.addActionListener(new Listener());
    class Listener extends Superclass implements ActionListener
         public void actionPerformed(ActionEvent e)
                   dispose();
    }How do I controll in the Listener class that the button in Subclass1 is beeing pressed?

    First of all I think I misunderstood your question. You said you had two internal frames, so I thought you wanted to close the internal frame.
    It now looks to me like you want to close the entire JFrame, which makes the code even a little easier. Something like:
    JComponent component = (JComponent)event.getSource();
    JFrame frame = (JFrame)SwingUtilities.windowForComponent( component );
    frame.dispose();
    Ok, I will make a try:
    public static Container getAncestorOfClass(Class c, Component comp)
    w.getAncestorOfClass(w, this); Fiirst you need to learn the basics of reading the API.
    "getAncestorOfClass()" is a static method. That means you don't use a variable to invoke the method. You use the class itself.
    "w" is a variable, which is a JFrame, but that is not what the first parameter should be. The first parameter is a "Class".
    "this" will refer to your Listener class, but you need the Component that generated the ActionEvent.
    When I thought you wanted to close an internal frame then the code would have been something like:
    JComponent component = (JComponent)event.getSource();
    Container container = SwingUtilities.getAncesterOfClass( JInternalFrame.class, component );
    JInternalFrame internalFrame = (JInternalFrame)container;
    internalFrame.invokeSomeMethodHere();If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
    http://homepage1.nifty.com/algafield/sscce.html

  • When using facetime having difficulty with video, sound is ok.screen says reconnecting.

    When using facetime having difficulty with video.msound is ok. Screen says reconnecting

    There have been numerous reports of FaceTime problems for the last several days and it is unclear what the cause if. Following is one of many discussions of the issue: https://discussions.apple.com/thread/6096640?tstart=120

  • LabView (8.2) hangs when using I/O operations with traditiona​l NI-DAQ 7.4.4 after aborting LabView program

    Hello!
    We have the following problem:
    LabView (8.2) hangs when using I/O operations with traditional NI-DAQ 7.4.4 after aborting LabView program
    We freshly installed LabView 8.2 (2006) and NI-DAQ 7.4.4 on a PC running Windows XP (Service Pack 3). We built a larger vi that remotely controls a traditional NI-DAQ card (AT-AO-10) on a second PC via NI-VISA 5.0.3. We were successfully running this program until a power failure caused the first computer to crash. After this crash we were unable to start the program again: LabView freezes while loading the vi. LabView itself can be started but freezes when adding I/O operations from the NI-DAQ palette to a block diagram.
    We have tried to re-install NI-DAQ 7.4.4, but it did not help. We then re-installed all NI software, but still no improvement. In the end we decided to reinstall ALL software, first Windows XP, then LabView and finally NI-DAQ 7.4.4. This worked. However, after a few days of running the program we had to abort LabView via Windows Task manager and afterward we again experienced the same problem as before: LabView freezes when loading the program.
    Obviously, we cannot afford to reinstall Windows every time. Are there any known Windows XP / NI-DAQ issues that might cause the freezing of LabView? We would be very grateful for any idea.
    Best regards,
    Matthias

    Hello Sprice,
    Browse the shipping examples according to “Directory Structure” and then select
    DAQ to find the Traditional DAQ examples. 
    There a lot of examples that are written for counters (Counter >>
    daq-stc.llb >> Count Edges (DAQ-STC).vi). 
    What kind of signals are your photons creating?  Are they TTL compatible at a certain
    frequency?  You don’t care about overwriting
    your buffer?
    Respectfully,
    Rob F
    Test Engineer
    Condition Measurements
    National Instruments

  • Is there any event in windows universal app (wp8.1&win8.1) that fires when screen locked and unlocked with in the app?

    Hi All,
    Is there any event in windows universal app (wp8.1&win8.1) that fires when screen locked and unlocked with in the app
    Right now, I am using this below mentioned event
    Window.Current.VisibilityChanged +=
    CurrentWindow_VisibilityChanged;, but it fires even when app relaunches.
    Please anybody help me to solve this issue.

    Thanks for your early reply. but, those are system triggers used in background task. I want an event that fires when screen gets locked. like this...(a networkstatuschangedevent)
    NetworkStatusChangedEventHandler
    networkStatusCallback =
    newNetworkStatusChangedEventHandler(OnNetworkStatusChange);

  • Building executables when using LV and MATRIXx

    Hi!
    With respect to Building executables when using LV and MATRIXx, I need clarification on following:
    1) Pre-requisites to use MATRIXx? We have LV 7.1 FDS with application builder.
    2) Licensing scheme? We would like to have MATRIX on 3 development stations.
    3) Can we build stand alone executables when using MATRIXx with LV?
    4) Do we need to purchase any addon to achieve (3) ?
    Thanks,
    Gurdas
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu

    Hello Gurdas,
    Before I answer your questions, I am curious to know what you have in mind for the stand alone executables you are interested in building. It may help me to know a little more detail about your plans. Depending on your application, some of these answers may or may not be applicable. In any case, here are answers to your questions:
    1) There are no prerequisites for using MATRIXx. LabVIEW is not required. However, with LabVIEW FDS, you do have an Xmath Script node located in the Functions > All Functions > Analyze > Mathematics > Formula palette. This node can be used to call Xmath scripts from LabVIEW.
    Note: To use the Xmath Script node successfully, you will want to install LabVIEW 7.1.1 Maintenance Release. Refer to KnowledgeBase 300A6NDT: How Can I Resolve MATLAB and Xmath Script Node Issues in LabVIEW?
    2) There are two licensing options for MATRIXx: node-locked and floating (concurrent). A node-locked license is restricted to a specific node and can be installed and used on that single computer. A floating (concurrent) license allows use of the product by a specified number of concurrent users on any computer on a local area network that includes a server running a single license manager. For more information, follow the link to the MATRIXx Price List from Products and Services: MATRIXx.
    3) There are two ways you might build executables when using MATRIXx and LabVIEW. One way uses a component of MATRIXx to automatically generate C code. AutoCode is a component of MATRIXx that allows the user to turn system models into C code. This C code can then be compiled into an EXE or DLL. If built into a DLL, LabVIEW can be used to call the DLL. A more thorough explanation of this is provided in Developer Zone Tutorial: Running MATRIXx SystemBuild Models in LabVIEW/LabVIEW Real-Time.
    Another way that may work is to build an executable from a LabVIEW VI that uses an Xmath Script Node. Any target machine running this executable would need to have Xmath and the LabVIEW Run-Time Engine installed.
    4) No other add-ons are needed for (3). Do be sure to refer to the note following the answer to (1).
    Regards,
    Eric M.

  • How to use audio and mic with multipoint server with out it crashing on you

    how to use audio and mic with multipoint server with out it crashing on you when i use them to make calls thru my station (zero client) at the same time it crashes on me and i need to restart the multipoint is there a setting i may have mist that enable's
    them to work at the same time and if posible can i use a non USB device 

    Look for "Single Sign-on Using Kerberos in Java" in google or on Sun's web site. Maybe this paper will help you.
    Claude

  • [svn:fx-4.x] 15119: Menu. popUpMenu textAlign should be start rather than left so it works correctly when using FTEText and direction =rtl.

    Revision: 15119
    Revision: 15119
    Author:   [email protected]
    Date:     2010-03-29 13:49:52 -0700 (Mon, 29 Mar 2010)
    Log Message:
    Menu.popUpMenu textAlign should be start rather than left so it works correctly when using FTEText and direction=rtl.  Also made same change for AccordionHeader, CheckBox and RadioButton just to be safe.
    QE notes:
    Doc notes: None
    Bugs: SDK-26028
    Reviewed By: Kevin
    Tests run: checkintests
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-26028
    Modified Paths:
        flex/sdk/branches/4.x/frameworks/projects/framework/defaults.css

    Thank you so much wchp, this is brilliant. I have had this annoying problem for a long time. I eventually rang Mac support, they did not know how to fix the problem as you have suggested so they instigated many hardware replacements which eventually left my iMac severely crippled. They eventually replaced it with the latest model. But I spent two months working with a disabled computer which really interfere with my work.
    Your solution appears to have solved my problem, at least so far, but I am hopeful that it is a permanent fix. I hope that your suggestions are taken up by Apple support. This may solve many users problems and avoid Apple making expensive fixes that don't actually work.
    I thought that the new iMac would not have the 'Wake up from sleep by painting in the login window' problem but it did, this really annoyed me. Anyway now the problem appears to be solved, it's not I will repost and keep working on it. Thanks again.

  • When using i-Cloud PAGES with another shared person, how to you shift ownership control of the file to the other who started as a collaborator?

    When using i-Cloud PAGES with another shared person who is a collaborator, how to you shift ownership control of the file to the shared person who started as a collaborator and needs to take over file ownership responsibilities?

    Thanks, but I have searched here but have not found or heard a direct answer to my question as stated above...

  • Sending e-mails when using talkmobile and talktalk...

    When using Talkmobile and a TALKTALK e-mail address, I can only receive e-mails;
    I cannot send e-mails!
    Talkmobile blame Talktalk, and vice versa!
    Has anyone any suggestions, please!

    You need to contact T-T and find out their SMTP settings ( which allows the sending of emails over wifi via your ISP) This info is probably on their website
    I assume you do not have a 3G iPad .In which case go to  the Apple site
    http://www.apple.com/support/ipad/
    where you should find very clear guidance on most issues

  • How do I use Qt and OpenGL with Visual Studio

    Hi! I mainly want to program in C++ and I want to use Qt and OpenGL with Visual Studio.
    I am currently revising C++ and later on i am going to start reading Qt and OpenGL. I have a background of
    Embedded firmware design(C and Assembly).
    The Visual Studio Version I have is 2013 ultimate. How do I use Qt and OpenGL with Visual Studio?
    Thanks
    Alexandros

    Hi ClassicalGuitar,
    The forum supports VS setup and installation. And your issue is not about the forum. I will move the thread to off-topic forum. Thanks for your understanding.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

Maybe you are looking for

  • Error while running the query on web.

    Hello Friends I am getting the error message "Result set too large (1056716 cells); data retrieval restricted by configuration (maximum = 500000 cells)" while executing the query on the web in BI 2004s. How can this be resolved. Any help in this rega

  • Where did my object go? :(

    I'm having a bit of trouble passing an object from one view to the next and I was really hoping someone could give me a hand. I am using a table view that when an item is clicked, an object is passed to the next view based on the selected item. When

  • Restricting access to the Admin WebConsole of WebAccess 2012

    Hi, With the new WebAccess 2012 web application, the console is now a WebConsole that can be accessed by the URL http://<server>/gw/webacc?action=Admin.Open I search the KB, the documentation and now this forum, looking for a way to restrict access t

  • R/3 Table name not shown in RSO2

    I have a Z Table in my R/3 system which I can see from SE11 but when I try to create a Data Source from RSO2 with Create Data Source from DB table or view, it doesn't show that table name in the list. Do I have to create a view for that Z table or ca

  • New to Time Capsule and Airport Utility App not current...

    I just received a Time Capsule for Christmas with the main purpose being to back up photos from my Mac and iPhone. When trying to install the Time Capsule I get this message: "This version of AirPort Utility doesn't support this AirPort wireless devi