I'm using maven to build a Java web application which is run in Tomcat. Certain JAR files (e.g. mail-1.4.1.jar and database drivers) have been put in tomcat/lib directory and the maven dependency set to "provided". (I'm not 100% sure why, but I think it's something to do with JNDI.)
Now I have built a standalone executable Java program in the same Maven project which I am trying to execute using mvn exec:java
. Unsurprisingly it can't find mail.jar and I get the error java.lang.NoClassDefFoundError: javax/mail/Session
How do I specify javax.mail scope="runtime" for the standalone Java program whilst still being "provided" for the Tomcat app? Do I have to use Maven profiles? If so, where can I find useful documentation on how this works (are the profile's dependencies additive or do they overwrite the default ones etc?)