javax.naming.NameNotFoundException: Name mail is not bound in this Context

1,554 views
Skip to first unread message

Ashmi

unread,
Jul 24, 2012, 4:37:51 AM7/24/12
to javam...@googlegroups.com
Hi,

I am using JavaMelody to configure mail sessions for my web application. It is a RESTful web application. I am using is eclipse as IDE for this project.I have created a Contect.xml file inside webContent/ META-INF.
The code for Context.xml is as follows:

<Context>
<Resource name="mail/MySession" auth="Container" type="javax.mail.Session"
                mail.smtps.host="he******.ni*****.com"
                mail.transport.protocol="smtps"
                mail.smtps.user="ashmi.*******.ap@*******.com"
                mail.from="MyApplication"
                mail.smtps.auth="true"
                mail.smtps.password="*********"
                />
            <Parameter name='javamelody.admin-emails' value='ashmi.****@****.com' override='false'/>
            <Parameter name='javamelody.mail-session' value='mail/MySession' override='false'/>
            <Parameter name='javamelody.mail-periods' value='day,week,month' override='false'/>    
</Context>   



and I have added the configuration required for JavaMelody in the web.xml of web application as follows:

<web-app>
<filter>
    <filter-name>monitoring</filter-name>
    <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>monitoring</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>net.bull.javamelody.SessionListener</listener-class>
  </listener>
</web-app>
============================================================================
============================================================================

When I am testing this mail configuration, I am getting below error.... I am able to understand what is the root cause...

HTTP Status 500 -


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.RuntimeException: javax.naming.NameNotFoundException: Name mail is not bound in this Context
	net.bull.javamelody.Action.mailTest(Action.java:268)
	net.bull.javamelody.Action.execute(Action.java:163)
	net.bull.javamelody.MonitoringController.executeActionIfNeeded(MonitoringController.java:122)
	net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:308)
	net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:150)

root cause

javax.naming.NameNotFoundException: Name mail is not bound in this Context
	org.apache.naming.NamingContext.lookup(NamingContext.java:820)
	org.apache.naming.NamingContext.lookup(NamingContext.java:168)
	org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
	javax.naming.InitialContext.lookup(InitialContext.java:392)
	net.bull.javamelody.Mailer.getSession(Mailer.java:79)
	net.bull.javamelody.Mailer.send(Mailer.java:138)
	net.bull.javamelody.MailReport.sendReportMail(MailReport.java:151)
	net.bull.javamelody.MailReport.sendReportMailForLocalServer(MailReport.java:129)
	net.bull.javamelody.Action.mailTest(Action.java:261)
	net.bull.javamelody.Action.execute(Action.java:163)
	net.bull.javamelody.MonitoringController.executeActionIfNeeded(MonitoringController.java:122)
	net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:308)
	net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:150)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.25 logs.


Please help me to fix this issue. I have been spending many days everyday on this. did lots of googling but did not find the solution. I would be grateful to your support.

Vernat Emeric

unread,
Jul 25, 2012, 5:41:46 AM7/25/12
to javam...@googlegroups.com

Hi,

The context of Context.xml and of web.xml seems good.
But in general this file is named context.xml and not Contect.xml or Context.xml.


Anyway, I suggest to test your webapp in Tomcat alone without Eclipse, because for whatever reason you Context.xml file may be currently ignored.

And you may also enable debugging logs in javamelody.
See https://code.google.com/p/javamelody/wiki/UserGuideAdvanced#Debugging_logs
Then, you should see something like the following in the logs:
11:11:00.182 [main] DEBUG net.bull.javamelody - parameter defined: mail-session=mail/Session
11:11:00.182 [main] DEBUG net.bull.javamelody - parameter defined: admin-emails=xxx
11:11:00.182 [main] DEBUG net.bull.javamelody - parameter defined: mail-periods=day,week,month
...
11:11:00.792 [main] DEBUG net.bull.javamelody - mail report for the day period scheduled with next execution date at Wed Aug 18 00:00:00 CES
 T 2010
11:11:00.792 [main] DEBUG net.bull.javamelody - mail report for the week period scheduled with next execution date at Sun Aug 22 00:00:00 CE
 ST 2010
11:11:00.792 [main] DEBUG net.bull.javamelody - mail report for the month period scheduled with next execution date at Wed Sep 01 00:00:00 C
 EST 2010
11:11:00.792 [main] DEBUG net.bull.javamelody - mail reports scheduled for xxx
11:11:00.792 [main] DEBUG net.bull.javamelody - JavaMelody filter init done

bye,
Emeric
Reply all
Reply to author
Forward
0 new messages