GeeCON Prague 2014*
The moose likes JBoss/WildFly and the fly likes Problem facing with send email program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Problem facing with send email program" Watch "Problem facing with send email program" New topic
Author

Problem facing with send email program

Chandraprabha Rajput
Ranch Hand

Joined: Apr 01, 2003
Posts: 37
Hello All.

I want to send email to people if program fails.

to do this i have set JBOSS mail-service.xml
and the send my email program is :


while running getting an exception : can not cast javax.mail.session to javax.mail.session at mailSession = (Session) ictx.lookup("java:/Mail");

Kindly help me

Thanks,
Chandra
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

First, please use the code tag for source listing - makes them much easier to read. I edited your post for you this time...

Second, what JAR files are you packaging with your app? I suspect that you have mail.jar file in your app. If so, remove it.


JBoss In Action
Chandraprabha Rajput
Ranch Hand

Joined: Apr 01, 2003
Posts: 37
Thanks for formating and reply.


I have checked my app build but it does not have mail .jar file.




Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Add the -verbose:class option to JAVA_OPTS within run.bat (or run.comf on Linux). This option prints out each class loaded and the JAR file it came from. This should help you located the addition JAR file containing javax.mail.Session.
Chandraprabha Rajput
Ranch Hand

Joined: Apr 01, 2003
Posts: 37
Thanks a lot for help.

I could find that javax.mail.Session class is getting loaded twice.

It gets loaded by pom file. Could you please tell me how i can find from which pom.xml it is getting loaded.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

You are going to have to tell us a little bit more about your application and how you are running it because I am surprised that pom.xml is even involved.

Also, how did you determine that it is because of the pom? Exactly what output did you get from -verbose:class for the two instances of the javax.mail.Session class that were loaded?
Chandraprabha Rajput
Ranch Hand

Joined: Apr 01, 2003
Posts: 37
I could find out from which pom file, it was loading the extra jar file.

Thanks a lot for help it realy saved my day .
 
GeeCON Prague 2014
 
subject: Problem facing with send email program