Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javamail question

Status
Not open for further replies.

keegank

Programmer
Aug 12, 2003
10
GB
I am trying to use the sendMail example that comes with tomcat here


When I submit I get the following error

ENCOUNTERED EXCEPTION: java.lang.NoClassDefFoundError: javax/activation/DataSource
java.lang.NoClassDefFoundError: javax/activation/DataSource
at SendMailServlet.doPost(SendMailServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)



I have the activation.jar and mail.jar in the common/lib directory and have the followin added to the classpath

C:\tomcat\Tomcat 4.1\common\lib\activation.jar; C:\tomcat\Tomcat 4.1\common\lib\mail.jar

Does anyone have an idea what the error actually means and what I need to do to fix it.

Thanks

Andy
 
Do the flowing steps to configure mail for tomcat:


1. paste the following line at the bottom, or below similar entry in <installdir>\conf\catalina.policy file: and modify the smtp server with your own.


// Permission to send email via SMTP - (permission to connect to mail server).
permission java.net.SocketPermission &quot;smtp.host:25&quot;, &quot;connect,resolve&quot; ;

2. modify your <installdir>\conf\server.xml as shown blow with your relevant info...(change only &quot;value&quot; and not the parameters.

<Resource name=&quot;mail/Session&quot; auth=&quot;Container&quot;
type=&quot;javax.mail.Session&quot;/>
<ResourceParams name=&quot;mail/Session&quot;>
<parameter>
<name>mail.smtp.host</name>
<value>smtp-server.host</value>
</parameter>
<parameter><name>mail.smtp.user</name>
<value>username</value>
</parameter>
<parameter><name>mail.from</name>
<value>username@host.com</value>
</parameter>

3. enter the <value>smtp.host</value> line. Change the value to the name of your SMTP mailhost.

4.enter the <value>userid</value> line. Change the value to the userid you use for sending and receiving mail.

5.enter the <value>username@mail.host</value> line. Change the value to the return e-mail address (the 'From' field)

You should now be all set to go.


Libaax
Hakuna Matata....;)
 
There is nothing to do here with Tomcat policy since the exception is a NoClassDefFoundError.

The JVM will throw an AccessControlException or a SecurityException when the SecurityManager detects a security policy violation.

If CLASSPATH is set up correctly then the only problem would be: there is no read access for the class.

Actually I had the same problem.

jaf-1_0_2.zip contains:
-rw------- activation.jar

If the user doesn't own the file he won't have rigths to access it.

solution:
-rw-r--r--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top