[jboss-user] [Installation, Configuration & DEPLOYMENT] - JavaMail : javax.naming.NameNotFoundException: mail not boun

knarenderreddy do-not-reply at jboss.com
Thu May 15 03:40:32 EDT 2008


Hi 

i am getting this bellow error

javax.naming.NameNotFoundException: mail not bound

My Configuration in mail-service is

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z dimitris at jboss.org $ -->


  <!-- ==================================================================== -->
  <!-- Mail Connection Factory                                              -->
  <!-- ==================================================================== -->

  
    mail
    keshireddy.narender at gssamerica.com
    Knreddy03
    
      <!-- A test configuration -->
      
        <!-- Change to your mail server prototocol -->
        <!--   -->
        

        <!-- Change to the user who will receive mail  -->
        

        <!-- Change to the mail server  -->
        

        <!-- Change to the SMTP gateway server -->
        
        
        <!-- The mail server port -->
        
        
        <!-- Change to the address mail will be from  -->
        

        <!-- Enable debugging output from the javamail classes -->
        
		
      
    
    jboss:service=Naming
  



**and my code for getting the JavaMail session is** 

 Context envCtx = null;
                 javax.mail.Session session =null;
		try{
                    
		Properties props= System.getProperties();
                Authenticator auth=new SMTPAuthenticator();
		
		props.put("mail.transport.protocol", "smtp");
		props.put("mail.smtp.host", "mail.abc.com");
		props.put("mail.smtp.port", "25");		
		props.put("mail.smtp.sendpartial","true");
		
                String location=servlet.getServletContext().getRealPath("");
              	props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
               props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
               session = Session.getDefaultInstance(props, auth);
               session.setDebug(true);
                envCtx =new InitialContext(props);
               session = (javax.mail.Session) envCtx.lookup("java:/mail");        
                 
                Message message = new MimeMessage(session);
		message.setFrom(new InternetAddress(from));
		message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
		message.setSubject("mail From Tomcat service: :)"+sub);
		message.setContent(content, "text/plain");
		Transport.send(message);
				return 1;
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    return 0;
                }

and i am writing code like this also
 session = (javax.mail.Session) envCtx.lookup("java:comp/env/mail");   

*when i am sending the mail the server throughs this exception*

12:33:59,036 ERROR [STDERR] javax.naming.NameNotFoundException: mail not bound
12:33:59,036 ERROR [STDERR] 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
12:33:59,036 ERROR [STDERR] 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
12:33:59,036 ERROR [STDERR] 	at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
12:33:59,036 ERROR [STDERR] 	at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
12:33:59,521 ERROR [STDERR] 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
12:33:59,521 ERROR [STDERR] 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
12:33:59,521 ERROR [STDERR] 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
12:33:59,521 ERROR [STDERR] 	at com.gssamerica.expensereporting.ui.common.Mail.sendMail(Mail.java:68)
12:33:59,521 ERROR [STDERR] 	at com.gssamerica.expensereporting.ui.applicationadministrator.ApplicationAdminAction.saveNewAdmin(ApplicationAdminAction.java:843)
12:34:00,006 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:34:00,006 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
12:34:00,006 ERROR [STDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
12:34:00,006 ERROR [STDERR] 	at java.lang.reflect.Method.invoke(Method.java:585)
12:34:00,006 ERROR [STDERR] 	at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
12:34:00,006 ERROR [STDERR] 	at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
12:34:00,006 ERROR [STDERR] 	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
12:34:00,006 ERROR [STDERR] 	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
12:34:00,006 ERROR [STDERR] 	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
12:34:00,006 ERROR [STDERR] 	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
12:34:00,006 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
12:34:00,006 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:34:00,006 ERROR [STDERR] 	at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:34:00,006 ERROR [STDERR] 	at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:34:00,006 ERROR [STDERR] 	at com.gssamerica.expensereporting.ui.common.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:199)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:34:00,006 ERROR [STDERR] 	at com.gssamerica.expensereporting.ui.common.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:199)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:34:00,006 ERROR [STDERR] 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
12:34:00,006 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
12:34:00,006 ERROR [STDERR] 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
12:34:00,006 ERROR [STDERR] 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
12:34:00,006 ERROR [STDERR] 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
12:34:00,006 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
12:34:00,006 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
12:34:00,006 ERROR [STDERR] 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
12:34:00,006 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:595)

if any one knows the solution please help me as early as possible (i am using Jboss4.2.2 sever)

Thanks and regards

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4150949#4150949

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4150949



More information about the jboss-user mailing list