Optional might not be working because another dependency is pulling the JAR in. You can run "mvn dependency:tree" to see a dependency graph.
Matt On Wed, Oct 15, 2008 at 8:44 PM, Alexander Coles <[EMAIL PROTECTED]> wrote: > On Oct 15, 2008, at 4:14 AM, Matt Raible wrote: > >> On Tue, Oct 14, 2008 at 7:44 PM, Alex Coles <[EMAIL PROTECTED]> wrote: >>> >>> Setting up with a Mail Session, however, is causing a headache and this >>> is where I would appreciate some help. I did the following: >>> * Moved mailSender bean definition out of core's >>> applicationContext-service.xml. >>> * Created JNDI mail session bean and mailSender in web's >>> applicationContext-resources.xml >>> * Create test mailSender bean definitions for testing in core + >>> public-client's applicationContext-resources.xml. >>> >>> And here's what I am experiencing: >>> java.lang.IllegalArgumentException: >>> Cannot convert value of type [javax.mail.Session] to required type >>> [javax.mail.Session] for property 'session': no matching editors >>> or conversion strategy found >>> >>> This is pretty cryptic, but I found a pointer to what the issue might be >>> in this blog post under the heading "Alternative 2": >>> http://springtips.blogspot.com/2008/06/send-e-mail-using-spring-and-javamail.html >>> >>> Although the blog posting suggests this happens with Tomcat, I guess it >>> may also come up in Jetty? That is, that activation.jar and mail.jar must be >>> excluded from the web application's classpath if using the JNDI and mail. >>> >>> My QUESTION THEREFORE, is it possible to exclude certain Jars from the >>> application classpath using the maven-jetty-plugin? >> >> You should be able to modify the dependencies in pom.xml (or exclude them >> if they're from another dependency) and set them to >> <optional>true</optional> so they're not included in the WAR. >> >> Matt > > > Thanks, Matt. I tried adding the optional element to the javax.mail > dependency in my core/pom.xml. > > <dependency> > <groupId>javax.mail</groupId> > <artifactId>mail</artifactId> > <version>${javamail.version}</version> > <optional>true</optional> > </dependency> > > This didn't seem to fix it, though. However, what did do the trick was to > add an exclusion in the reference to the parent POM in web/pom.xml (as I > stated before, I've run appfuse:full-source). > > <dependency> > <groupId>${pom.parent.groupId}</groupId> > <artifactId>${pom.parent.artifactId}-core</artifactId> > <version>${pom.parent.version}</version> > <exclusions> > <exclusion> > <artifactId>mail</artifactId> > <groupId>javax.mail</groupId> > </exclusion> > </exclusions> > </dependency> > > For right now, it works. But, I am not sure 100% why the <optional> element > isn't working -- perhaps I am not understanding the documentation at > http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html > correctly? > > Alex > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
