facebook

Accessing Javamail from EJB in jboss 4.0

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #223648 Reply

    Jason Price
    Member

    This is somthing really simple that I just can’t get to work. I’m sure I’ve done it before but I can’t figure out what I’m doing wrong!

    I’m trying to send an email from an EJB using the java:\Mail context that jboss 4 sets up. I have configured the mail-service.xml file and when jboss starts I get

    [MailService] Mail Service bound to java:/Mail

    when I access it in the ejb like this:

    Context ctx = new InitialContext();
    Session ses =(Session)ctx.lookup("Mail");

    I get the following exception in the jboss logs

    javax.naming.NameNotFoundException: Mail not bound

    has anyone got any ideas?
    Its got to be something simple I’m missing but googling about hasn’t turned up anything useful.

    #223681 Reply

    Riyad Kalla
    Member

    Shot in the dark, but have you tried:
    /Mail

    I ask because in this link:
    http://java.sun.com/developer/onlineTraining/Programming/JDCBook/lookup.html

    They bind an EJB to the context using a name like “registration” then later look it up with exactly the same name… so I wonder if Mail is bound via “/Mail”. There is also that prefix you sometimes see “/java/env” for JNDI entities, although I don’t know when/where to use it. Hibernate seems to need it when I specify a JNDI context…

    #227682 Reply

    a_debona
    Member

    Hi there,

    i am completely new to JBoss and I also wanted to be able to send emails… i understand that we need to change the mail-service.xml
    and get the mail handle from JNDI … My question is what API is the Session object belong to ? javax.mail ? It is not part of JBoss api’s ?

    Did you have to import the J2EE.jar from Sun ?

    #227719 Reply

    a_debona
    Member

    Okay.. i found it… all i had to do was add the mail.jar to the server/default/lib directory and then my
    import of javax.mail.* worked… it just wasn’t in the classpath of Eclipse project..

    #227720 Reply

    a_debona
    Member

    correction above.. i just had to add the mail.jar in the server/default/lib directory to my eclipse project java build path

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Accessing Javamail from EJB in jboss 4.0

You must be logged in to post in the forum log in