• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mailing from a servlet

 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having problems with the javax/mail/Message class I am getting a ClassDefNotFound Error here is the setup:

- I am working on a remote server using netbeans with Mounted Network drives

- I have built a Email class with a static send method, obviously it accesses the javax.mail package

- Everything compiles correctly because I am using netbeans with mounted drives.

- However, when I am trying to send an email I get the error.

- I have probably pasted mail.jar and activation.jar in every directory that I know of ( /jre/lib/ext, /lib, WEB-INF/lib, shared/lib )

I do not understand why tomcat can 'see' some classes but not others. Where do these classes need to be, I know tomcat does not pay attention to the CLASS_PATH but shouldn't it be able to see it in these other directories. Frustrating...

Any help is greatly appreciated,

Kerry R. Wilson
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be helpful to clue us in on what class is offending Tomcat's sensibilities.
 
Himanshu Bisht
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i am too,dojng the same thing-sending email through servlet and was having the same problem.
Instead of copyng files in all those folders try setting a classpath variable and i assure u it will work provided ur code doesn't have any silly errors.

make a .bat file and set paths for all jar in it just run the bat file before compiling the servlet.You can use mine

set CLASSPATH=.;D:\jakarta-tomcat-5\common\lib\servlet-api.jar;D:\jakarta-tomcat-5\common\lib\jsp-api.jar;C:\j2sdk1.4.0\lib\tools.jar;C:\j2sdk1.4.0\jre\lib\rt.jar;C:\j2sdk1.4.0\jre\lib\ext\activation.jar;D:\jakarta-tomcat-5\webapps\ap\WEB-INF\classes\mail.jar;

copy this and pastes it in autoexec.bat

Best of Luck
 
Himanshu Bisht
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by copy and pasting i meant that u will just have make changed according to your directory structure.

pardon me if i confused you in any way.I just wanted to give an example
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class is javax.mail.Message.

My problem is that tomcat is not compiling the servlet, so why does it need to see the mail.jar file. I have that file in the jre/lib/ext directory, so the jre should be able to see it. I am assuming that the only reason you would use CLASSPATH is that tomcat needs it to compile jsp files. Am I incorrect?
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally figured it out, we had another jvm installation that tomcat was using seperate of the one we had the app using. But I would still like to know: when we deploy this is the lib directory used to put jar files such that the jre can 'see' them or is it just used such that tomcat can compile servlets, and we still need to put mail.jar in JAVA_HOME/jre/lib/ext?
 
Himanshu Bisht
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you are right.
Classpath is for complile time but it does give this error at run time because the classpath is not set for the jar.
I happened with me.I am looking for answer of such questions.
Lets see!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic