I tried with your code, Guy. Anyway, I'm trying to getting a Jboss Mail Session from a class running under Tomcat (running as separate bundle), therefore I don't bind the <resource-ref> element to any session or entity bean. What I would like is just to retrieve a Mail Session Object from JBoss and to use it, instead of implementing (as I've done) it on my own.
I tried your code, but I obtain the following exception (the first part is customized): NamingException while getting the Jboss Mail Session: Mail not bound The InitialContext object has been set correctly, as I manage entity and session bean successfully. If you don't have time to follow this issue, just leave it, I'm happy with the service I implemented under Tomcat right now, but if I could use Jboss I would be happier. Marco ----- Original Message ----- From: "Guy Rouillier" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 10, 2003 5:07 AM Subject: Re: [JBoss-user] Retrieving a mail session object from Jboss [3.2.1] > Here is what I did under 2.4.3. The same thing should work in 3.2.1, as > I see mail-service.xml is in the default server. Check your server > (either the logs or jmx-console) to make sure the mail service has > started properly. > > 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 > ------------------------------------------------------- This SF.NET email is sponsored by: eBay Great deals on office technology -- on eBay now! Click here: http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user