0 Replies Latest reply on Oct 30, 2002 11:34 AM by loic

    could not dereference object

    loic

      hello,

      I have always the same problem to open a session with Javamail in a Servlet. I use the JBOSS 2.4.4

      My web.xml file has this parameter:
      <resource-ref>
      <res-ref-name>mail/DefaultMail</res-ref-name>
      <res-type>javax.mail.Session</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      My mail.properties is declared (in dir default) and this is my code part:

      try {
      Session session = (Session)new InitialContext().lookup("java:comp/env/mail/DefaultMail");
      return session;
      } catch (javax.naming.NamingException e) {
      e.printStackTrace();
      }

      And this is the error:

      [ERROR,Default] javax.naming.NamingException: Could not dereference object. Roo
      t exception is
      [ERROR,Default] java.lang.NullPointerException
      [ERROR,Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext
      .java:418)
      [ERROR,Default]
      [ERROR,Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext
      .java:457)
      [ERROR,Default]
      [ERROR,Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext
      .java:333)
      [ERROR,Default]
      [ERROR,Default] at javax.naming.InitialContext.lookup(InitialContext.jav
      a:350)


      What could be the problem.....Thanks

      Loic