It doesn’t work because the classes from dependency
javax/javaee-api/provided they are purpose built. They are not usable runtimes because the methods implementation is missing.
Simply add classes from the dependency
javax.mail/mail/1.4.5 al classpath doesn’t help, because classes from
javax/javaee-api/provided are already present. Having only addiction to
javax.mail/mail/1.4.5 solves your problem, but most likely you need other classes from
What you can do is get rid of the addiction
javax/javaee-api/provided and obtain these classes, for example, from the dependencies provided by the target application server. For example, you can use the following:
org.jboss.spec jboss-javaee-6.0 1.0.0.Final pom provided
Since the scope is provided, it does not affect the artifact to be constructed. That’s why you can use this with other application servers than JBoss too. It’s the same API as your original dependency, but it contains normal classes.