5608057 / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

Reports are working great - however, cannot e-mail #291

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Have followed this and works great..
http://code.google.com/p/javamelody/wiki/UserGuideAdvanced#Deployment_on_Tomcat_
without_modification_of_monitored_webapps_%28

However, cannot seem to get this to work..
http://code.google.com/p/javamelody/wiki/UserGuide#14._Weekly,_daily_or_monthly_
reports_by_mail

I have downloaded the JavaMail from Oracle and have tried the version from 
maven.org - I am only getting an http 500 error when testing.

What am I missing in trying to get the reports to fire and to fire correctly?

What is the expected output? What do you see instead?
the expectation is the same output as that in the 
"http://localhost/vendorapp/monitoring
The reports generate great and I can even have the server produce PDFs as well.

What I see instead are http500 errors

What version of the product are you using? On what application server, JDK,
operating system?
What version of the product are you using? On what application server, JDK,
> JavaMelody 1.43.0
> jdk1.6.0_26 (64-bit)
> apache-tomcat-6.0.36 for windows (64-bit)
> mail-1.4.1.jar / javamail1_4_6 (from Oracle)

Operating system?
windows 2008 R2 64bit

Please provide any additional information below.

Original issue reported on code.google.com by kentd...@gmail.com on 12 Mar 2013 at 9:29

GoogleCodeExporter commented 8 years ago
When do you have http 500 errors? For what URL(s)?

And the essential question: what say precisely the http 500 errors?

Original comment by evernat@free.fr on 13 Mar 2013 at 12:51

GoogleCodeExporter commented 8 years ago
So..  I go to http://localhost/VendorApp/monitoring and Javamelody comes up 
great..  

http://localhost/VendorApp/monitoring?action=mail_test > gives the http 500 
error.

Specific Error page"
The website cannot display the page - HTTP 500
Most likely causes:
The website is under maintenance.
The website has a programming error.

What you can try:
Refresh the page.
Go back to the previous page.

More information
This error (HTTP 500 Internal Server Error) means that the website you are 
visiting had a server problem which prevent the webpage from displaying.

For more about HTTP errors, see Help.

>>  To get Javamelody running, I followed the directions at: 
http://code.google.com/p/javamelody/wiki/UserGuideAdvanced#Deployment_on_Tomcat_
without_modification_of_monitored_webapps_%28

    For this, copy the files javamelody.jar and jrobin-x.jar and optionally itext-x.jar in the lib directory of Tomcat 6 (and not in the WEB-INF/lib directories of the webapps). 

    Then add the following lines in the web.xml file of the conf directory of Tomcat (and not in the WEB-INF/web.xml files of the webapps). 
[code]
        <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>
[/code]
and this works great. The monitoring pages come up fine..

now, back in the User's Guide, we go to:
http://code.google.com/p/javamelody/wiki/UserGuide#14._Weekly,_daily_or_monthly_
reports_by_mail

And this first part, I think is fine..
    And add a mail session in the configuration of the application server with the name of your smtp server. For example, add the following in the tomcat context of your webapp (xml file located in <tomcat_home>/conf/Catalina/localhost/ or in <tomcat_home>/conf/server.xml): 
[code]
        <Resource name="mail/MySession" auth="Container" type="javax.mail.Session"
                mail.smtp.host="<smtp server>"
                mail.smtp.user="<login>"
                mail.from="MyApplication"
        />
[/code]

Here is where the tricky part comes in as I have tried in my different 
locations..

    Then it is necessary to add the list of mail addresses separated by commas to the parameter admin-emails, in web.xml file or in tomcat context or in system properties like the optional parameters above. 

    And the name of the mail session should also be added in the parameter mail-session. For example, for the tomcat context of your webapp: 
[code]
        <Parameter name='javamelody.admin-emails' value='admin1@societe.fr,admin2@societe.fr' override='false'/>
        <Parameter name='javamelody.mail-session' value='mail/MySession' override='false'/>
[/code]

Thanks,

Kent

Original comment by kentd...@gmail.com on 13 Mar 2013 at 8:34

GoogleCodeExporter commented 8 years ago
I did not expect an error page like that.
Do you use Internet Explorer instead of a browser?

And if you use Internet Explorer, can you try to turn off "friendly HTTP error 
messages" in IE and try again?

See for example at the bottom of:
http://windows.microsoft.com/en-us/windows-vista/get-help-with-website-error-mes
sages-http-errors

Original comment by evernat@free.fr on 13 Mar 2013 at 10:30

GoogleCodeExporter commented 8 years ago
Mar 13, 2013 6:15:00 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Mar 13, 2013 6:16:42 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.RuntimeException: javax.naming.NameNotFoundException: Name mail is 
not bound in this Context
    at net.bull.javamelody.Action.mailTest(Action.java:294)
    at net.bull.javamelody.Action.execute(Action.java:173)
    at net.bull.javamelody.MonitoringController.executeActionIfNeeded(MonitoringController.java:117)
    at net.bull.javamelody.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:130)
    at net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:340)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:170)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at com.googlecode.psiprobe.Tomcat60AgentValve.invoke(Tomcat60AgentValve.java:30)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.naming.NameNotFoundException: Name mail is not bound in this 
Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at net.bull.javamelody.Mailer.lookupFromJndiName(Mailer.java:98)
    at net.bull.javamelody.Mailer.getSession(Mailer.java:72)
    at net.bull.javamelody.Mailer.send(Mailer.java:143)
    at net.bull.javamelody.MailReport.sendReportMail(MailReport.java:153)
    at net.bull.javamelody.MailReport.sendReportMailForLocalServer(MailReport.java:131)
    at net.bull.javamelody.Action.mailTest(Action.java:287)
    ... 18 more

Original comment by kentd...@gmail.com on 13 Mar 2013 at 11:26

GoogleCodeExporter commented 8 years ago
That's better.
And the exception says that the mail session, named something like 
"mail/MySession", was not found in JNDI.
In fact, it means that neither "new 
InitialContext().lookup("java:comp/env/mail/MySession"), neither "new 
InitialContext().lookup("java:/mail/MySession") found a result in JNDI.

So where do you have declared you mail Resource?

When using Tomcat, I think you can either declare the mail session inside :
- conf/Catalina/localhost/mycontext.xml
- conf/context.xml
- or conf/server.xml (in GlobalNamingResources), but this needs to add a 
resource-ref in the web.xml of your web-app, or in conf/web.xml, for example 
like this:
    <resource-ref>
        <res-ref-name>mail/MySession</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

Original comment by evernat@free.fr on 14 Mar 2013 at 2:12

GoogleCodeExporter commented 8 years ago
did some work on this..  Did find some insightful information - 
http://tomcat.10.n6.nabble.com/Shared-email-resource-td2158768.html

Have made the following modifications:
D:\tomcat\conf\web.xml
[code]
    <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>
[/code]

D:\tomcat\conf\context.xml
[code]
<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>
new InitialContext().lookup("java:comp/env/mail/Session");
    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->
</Context>
[/code]

Then, the last modification is: 
D:\tomcat\webapps\vendorApp\META-INF
[code]
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="true" reloadable="true">
    <ResourceLink auth="Container" global="jdbc/vendorDB" name="jdbc/vendorDB" type="javax.sql.DataSource" />
    <Resource name="mail/MySession" type="javax.mail.Session" 
      mail.smtp.host="smtp.company.com"
      mail.from="MyApplication" />
      <Parameter name='javamelody.admin-emails' value='user@company.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>
[/code]

Resulting error is:
[code]
Mar 14, 2013 8:46:22 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: mail-session has no value: add the 
mail-session parameter
    at net.bull.javamelody.Action.mailTest(Action.java:277)
    at net.bull.javamelody.Action.execute(Action.java:173)
    at net.bull.javamelody.MonitoringController.executeActionIfNeeded(MonitoringController.java:117)
    at net.bull.javamelody.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:130)
    at net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:340)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:170)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at com.googlecode.psiprobe.Tomcat60AgentValve.invoke(Tomcat60AgentValve.java:30)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
    at java.lang.Thread.run(Thread.java:662)
[/code]

Thanks,

Kent

Original comment by kentd...@gmail.com on 14 Mar 2013 at 5:44

GoogleCodeExporter commented 8 years ago
This exception means that 
servletContext.getInitParameter("javamelody.mail-session") == null.

What is the name of your file in webapps\vendorApp\META-INF?

Have you tried to move the following from 
webapps/VendorApp/META-INF/context.xml to conf/context.xml?

    <Resource name="mail/MySession" type="javax.mail.Session" 
      mail.smtp.host="smtp.company.com"
      mail.from="MyApplication" />
      <Parameter name='javamelody.admin-emails' value='user@company.com' override='false'/>
      <Parameter name='javamelody.mail-session' value='mail/MySession' override='false'/>
      <Parameter name='javamelody.mail-periods' value='day,week,month' override='false'/>

Original comment by evernat@free.fr on 20 Apr 2013 at 2:38

GoogleCodeExporter commented 8 years ago
Any news?
Can we close this issue or do you still want to make the mail work in this 
particular context (documented to be beta by the way)?

Original comment by evernat@free.fr on 9 Jul 2013 at 2:21

GoogleCodeExporter commented 8 years ago
No response, so closing as invalid/incomplete.

Original comment by evernat@free.fr on 9 Aug 2013 at 12:35

GoogleCodeExporter commented 8 years ago
I am back on this again.  I apologize, but due to issues seen, we are still 
seeing this.  I have copied the activation.jar and the mail.jar from the 
vendor's published to the /tomcat/webapps/application/lib folder to the 
/tomcat/lib folder and now I see:
nosuchproviderexception smtp

in the browser window

Thanks,

Kent

Original comment by kentd...@gmail.com on 15 Nov 2013 at 5:43

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Getting the following error and have attached..
>>
Nov 15, 2013 5:24:48 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.RuntimeException: javax.mail.NoSuchProviderException: smtp
>>

Thanks,

Kent

Original comment by kentd...@gmail.com on 15 Nov 2013 at 11:36

Attachments: