Reporting on JBoss

123 views
Skip to first unread message

christian.kersters

unread,
Aug 5, 2011, 2:59:39 AM8/5/11
to javamelody
Has anyone succeeded in sending reports from JBoss-Web?

I'm currently using JBoss 4.2.3

I've tried the following:

- In deploy\jboss-web.deployer\context.xml:
With or without
<Resource name="java:/Mail" auth="Container"
type="javax.mail.Session"
mail.smtp.host="domino01.data.intra"
mail.smtp.user="sender_email"
mail.from="JBoss 4.2.3 on CATD0599"
/>
With
<Parameter name='javamelody.admin-emails'
value='receiver_email' override='false'/>
<Parameter name='javamelody.mail-session' value='java:/Mail'
override='false'/>
<Parameter name='javamelody.mail-periods'
value='day,week,month' override='false'/>

- In deploy\mail-service.xml:
<attribute name="JNDIName">java:/Mail</attribute>
<attribute name="User">sender_mail</attribute>

I always receive:
00:00:09,807 WARN [javamelody] sending mail report failed
javax.naming.NameNotFoundException: java: not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:
529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:
537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:
543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:
625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:
716)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:
587)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at net.bull.javamelody.Mailer.getSession(Mailer.java:72)
at net.bull.javamelody.Mailer.send(Mailer.java:129)
at
net.bull.javamelody.MailReport.sendReportMail(MailReport.java:151)
at
net.bull.javamelody.MailReport.sendReportMailForLocalServer(MailReport.java:
129)
at net.bull.javamelody.MailReport$1.run(MailReport.java:57)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

If I try with similar code, in a web application (as below), it works
fine.

[...]
ctx = new InitialContext();
try {
Session session = (Session) ctx.lookup(mailSessionName);
if (session != null)
out.println("<p>Session retrieved</p>");
final Message msg = new MimeMessage(session);
final InternetAddress[] toAddresses =
InternetAddress.parse(mailRecipients, false);
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject("This is my test");
msg.setFrom(InternetAddress.getLocalAddress(session));
msg.setText("This is my test.\r\nChristian");
String protocol = session.getProperty("mail.transport.protocol");
if (protocol == null) {
protocol = "smtp";
}
Transport.send(msg);
} catch (Exception e) {
e.printStackTrace();
}
[...]

Darren Hartford

unread,
Aug 5, 2011, 8:21:48 AM8/5/11
to javam...@googlegroups.com
I can confirm that I've never gotten javamelody email to work on jboss 4.0.5, nor 4.2.x. But, the same is also true with the sql counters, while jboss 5/6 the sql counters do work, but I never tested the email on jboss 5/6.

-D

--- On Fri, 8/5/11, christian.kersters <christian...@swing.be> wrote:

Emeric Vernat

unread,
Aug 10, 2011, 7:53:18 PM8/10/11
to javam...@googlegroups.com
Hi,

I have tested successfully the mail session with JBoss 5.1.0 GA, and I
suppose that it works also with JBoss 4.x.

I have configured the following (using javamelody 1.30):
- First, configure the mail session in JBoss. In
deploy/mail-service.xml, I have :

<attribute name="JNDIName">java:/Mail</attribute>

...

- Inside the webapp, add the file "WEB-INF/jboss-web.xml":
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<!-- warning: I am not sure that this file is deployed when using
Eclipse WTP -->
<resource-ref>
<res-ref-name>Mail</res-ref-name>
<jndi-name>java:/Mail</jndi-name>
<res-type>javax.mail.Session</res-type>
</resource-ref>
</jboss-web>

- I have not found a Tomcat context.xml in JBoss. But the javamelody
mail parameters can be added in the web.xml file or with system properties.
Inside the webapp, add the following in "WEB-INF/web.xml" in the
javamelody filter declaration :
<init-param>
<param-name>admin-emails</param-name>
<param-value>eve...@free.fr</param-value>
</init-param>
<init-param>
<param-name>mail-session</param-name>
<param-value>Mail</param-value>
</init-param>


And I have made a patch, which is attached to this mail and which I will
commit soon for the next release (javamelody 1.31).
With this patch, it will work the same as above, except that there will
be no need to add the jboss-web.xml file.

Let me know if it works for you.

bye,
Emeric


Le 05/08/2011 14:21, Darren Hartford a �crit :

jboss-mail.patch

Emeric Vernat

unread,
Aug 10, 2011, 7:56:37 PM8/10/11
to javam...@googlegroups.com
I forgot: You can also add the mail periods in the web.xml file of course.

<init-param>
<param-name>mail-periods</param-name>
<param-value>day,week,month</param-value>
</init-param>

Emeric Vernat

unread,
Aug 11, 2011, 5:12:17 PM8/11/11
to javam...@googlegroups.com
I have committed the patch (jboss-web.xml should not be needed).
And a new build is available:
http://code.google.com/p/javamelody/issues/detail?id=134

Emeric

christian.kersters

unread,
Aug 16, 2011, 2:56:18 AM8/16/11
to javamelody
Works fine. Many thanks, Emeric!

Christian
> >> <param-value>ever...@free.fr</param-value>
> >> </init-param>
> >> <init-param>
> >> <param-name>mail-session</param-name>
> >> <param-value>Mail</param-value>
> >> </init-param>
>
> >> And I have made a patch, which is attached to this mail and which I
> >> will commit soon for the next release (javamelody 1.31).
> >> With this patch, it will work the same as above, except that there
> >> will be no need to add the jboss-web.xml file.
>
> >> Let me know if it works for you.
>
> >> bye,
> >> Emeric
>
> >> Le 05/08/2011 14:21, Darren Hartford a écrit :
> >>> I can confirm that I've never gotten javamelody email to work on
> >>> jboss 4.0.5, nor 4.2.x.  But, the same is also true with the sql
> >>> counters, while jboss 5/6 the sql counters do work, but I never
> >>> tested the email on jboss 5/6.
>
> >>> -D
>
> >>> --- On Fri, 8/5/11, christian.kersters<christian.kerst...@swing.be>  
> >>> wrote:
Reply all
Reply to author
Forward
0 new messages