users@glassfish.java.net

RE: Help with JavaMail

From: David Salter <david_at_davidsalter.com>
Date: Fri, 01 Jun 2007 05:23:38 -0700

Thanks, I've found an answer on how to configure this all using
annotations.

If anyone's interested, the answer can be found at:

http://java.sun.com/javaee/5/docs/tutorial/doc/Resources5.html

When I follow the instructions here, it all works as expected.

Thanks,

Dave.


> -------- Original Message --------
> Subject: Help with JavaMail
> From: David Salter <david_at_davidsalter.com>
> Date: Fri, June 01, 2007 9:58 am
> To: users_at_glassfish.dev.java.net
>
> Hi,
>
> I've configured a JavaMail Session within Glassfish and caled it
> "glassfishmail" to test it out. I'm trying to use this from within an
> EJB that I am accessing via a web service. My code is pretty much like
> below, but I get a class cast exception thrown.
>
> @Stateless()
> @WebService()
> public class EmailTest {
> @WebMethod
> ...
> InitialContext ctx = new InitialContext();
> Session session = (Session).lookup("glassfishmail"); //
> ClassCastException thrown here.
> Message msg = new MimeMessage(session);
> ...
>
> From what I've read, I'm guessing that I need to specify a res-ref
> within my sun-ejb-jar.xml file. If this is correct, does anyone have
> an example of what I need? Also, can this be done via annotations
> rather than xml?
>
> I also suspect that I need to look up
> "java:comp/env/mail/glassfishmail", but this gives me a
> NameNotFoundException.
>
> Any help much appreciated.
>
>
> Thanks in advance,
>
> Dave.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net