Results 1 to 5 of 5
  1. #1
    JustinCase is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default javax.mail.Session cannot be cast to javax.mail.Session

    Getting this error in my project. When googling this issue, it seems it is caused by more than 1 version of the mail.jar being in the project. However, i cannot find it anywhere other than in the tomcat libraries. If i remove it from there, i get a different exception saying the .jar cannot be found, witch would seem to indicate that i only have 1 version of the file. Anyone have a clue what the problem might be? Is it OS X Lion and some file version checking that is the issue?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,044
    Rep Power
    20

    Default Re: javax.mail.Session cannot be cast to javax.mail.Session

    You're not deploying it with your app are you?

  3. #3
    Oih
    Oih is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default Re: javax.mail.Session cannot be cast to javax.mail.Session

    Hi JustInCase, I'm running into exactly the same problem:

    I deploy my application on Glassfish, in which I have created a java mail session. When I look for the session and try to cast Object to javax.mail.Session I get the same ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session. If I remove mail.jar from my app lib folder then the server doesnt even find the needed classes.

    Did you finally find any solution to this? Just in case, I'm using Glassfish 3.1.1 and java-6-sun-1.6.0.26.

  4. #4
    wayne is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: javax.mail.Session cannot be cast to javax.mail.Session

    Hi,

    I am also looking for a solution with exactly the same problem. Have you found any one? Thanks.

  5. #5
    wayne is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: javax.mail.Session cannot be cast to javax.mail.Session

    I finally figured out what went wrong. There is a third party .jar file under application/WEB-INF/lib. That jar file also contains javax.mail class. I should have checked third party .jar file earlier.

Similar Threads

  1. javax.mail
    By sashaxiv in forum Advanced Java
    Replies: 2
    Last Post: 06-08-2011, 11:37 AM
  2. javax.mail Attachements
    By ravjot28 in forum Networking
    Replies: 3
    Last Post: 02-19-2010, 12:35 AM
  3. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 05:37 AM
  4. javax.mail.Transport
    By sharpi03 in forum Advanced Java
    Replies: 5
    Last Post: 10-23-2009, 05:26 PM
  5. Replies: 2
    Last Post: 05-05-2008, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •