tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Gamache <cgama...@gmail.com>
Subject Re: tomcat7-maven-plugin and mail
Date Mon, 01 Dec 2014 18:05:26 GMT
A few things you might take a look at. I don't think the Tomcat plugin
requires javax.mail or activation by itself. That part of the plugin
definition probably isn't doing what you intended it to do. I think you
might want to remove the <extraDependencies> section.

By including
<project>
...
<dependencies>
....
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-email</artifactId>
  <version>your_version_here</version>
</dependency>
</dependencies>
</project>


You'll get javax.mail as a transitive dependency. The Maven WAR plugin is
smart enough to include your dependencies and their transitive dependencies
in your war file.

Even though you're looking up the mail Session using JNDI, I still think
you'll be needing the commons email as a "compiled" dependency unless
you've put it in the classpath yourself.

If you have put it in the classpath, using "provided" scope will not
include transitive dependencies, of which there are several for
commons-email. If that's the route you want to go, you'll need to download
and put commons-email's dependencies in the classpath along with
commons-email.

IMO and FWIW, self-managing dependencies like this complicates your project
deployment scheme. The size overhead of including your project's
dependencies in the each war is so worth it when Maven can handle making
sure the dependency artifacts are where they need to be.

On Mon, Dec 1, 2014 at 8:17 AM, James Green <james.mk.green@gmail.com>
wrote:

> Is there a way of getting this to work?
>
> We have a Maven project that depends on Apache's commons-email. We use JNDI
> to look up a mail Session. We use the following in our POM:
>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-war-plugin</artifactId>
>                 <configuration>
>                     <failOnMissingWebXml>false</failOnMissingWebXml>
>                 </configuration>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.tomcat.maven</groupId>
>                 <artifactId>tomcat7-maven-plugin</artifactId>
>                 <version>2.2</version>
>                 <configuration>
>                     <contextFile>tomcat/context.xml</contextFile>
>                     <port>9000</port>
>                     <path>/foo</path>
>                     <fork>true</fork>
>                     <extraDependencies>
>                         <extraDependency>
>                             <groupId>javax.mail</groupId>
>                             <artifactId>mail</artifactId>
>                             <version>1.4</version>
>                         </extraDependency>
>                         <extraDependency>
>                             <groupId>javax.activation</groupId>
>                             <artifactId>activation</artifactId>
>                             <version>1.1.1</version>
>                         </extraDependency>
>                     </extraDependencies>
>                 </configuration>
>                 <executions>
>                     <execution>
>                         <id>start</id>
>                         <goals>
>                             <goal>run-war-only</goal>
>                         </goals>
>                         <phase>pre-integration-test</phase>
>                     </execution>
>                     <execution>
>                         <id>shutdown</id>
>                         <goals>
>                             <goal>shutdown</goal>
>                         </goals>
>                         <phase>post-integration-test</phase>
>                     </execution>
>                 </executions>
>             </plugin>
>
> Deployment fails with the following:
>
> java.lang.ClassNotFoundException: javax.mail.Session
>
> I have both mail and activation listed in the POM's dependencies with a
> scope of provided.
>
> Is further magic required?
>
> Thanks,
>
> James
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message