Source:
Session session = ((Session) new InitialContext().lookup("java:comp/env/mail/Mail"));
ejb-jar.xml:
<resource-ref> <description>A mail session for the Email bean</description> <res-ref-name>mail/Mail</res-ref-name> <res-type>javax.mail.Session</res-type> <res-auth>Container</res-auth> </resource-ref>
jboss.xml:
<resource-managers> <resource-manager> <res-jndi-name>java:/Mail</res-jndi-name> <res-name>mail/Mail</res-name> </resource-manager> </resource-managers>
Marco Tedone wrote:
Hi, I would like to retrieve a javax.mail.Session object from within a class running under Tomcat.
I would like to user the javax.mail.Session provided by Jboss. In the jmx-console, I can see that under the java Namespace there is the 'Mail' name; however, from within my class, when I do the following:
//setJbossProperties() returns a Properties object set for Jboss. It works as another class uses it and my entity/session //beans work greatly
InitialContext context = new InitialContext(JbossService.newInstance().setJbossProperties()); //jndiName contains "java:comp/env/Mail" Object node = context.lookup(jndiName); session = (Session)PortableRemoteObject.narrow(node, Session.class);
I receive the following exception:
ERROR 09 Jun 2003 22:37:41,859 framework.MailService --> NamingException while creating a JavaMail Session: comp not bound
or, if I set jndiName with "java:/Mail"
ERROR 09 Jun 2003 22:37:41,859 framework.MailService --> NamingException while creating a JavaMail Session: Mail not bound
I also tried simply with the following:
InitialContext context = new InitialContext(JbossService.newInstance().setJbossProperties()); session = (Session)context.lookup(jndiName);
Two questions:
1) Is it possible from an external class (let's say under Tomcat) to retrieve a Session object by simply lookup the Jboss JNDI namespace?
2) Is the source I wrote correct?
Thanks for any help,
Marco
------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
-- Guy Rouillier
------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user