Payara 4.1.1.164 -> Error in server.log

19 views
Skip to first unread message

thomask...@gmail.com

unread,
Dec 19, 2016, 4:34:50 PM12/19/16
to javamelody
Hi Group,

I installed javamelody in an application running on payara 4.1.1.164. Although I can see nearly all (not SQL - see my last post) infomations I always get the following error in my server.log:

2016-12-19 20:37:15,812 WARN  [http-thread-pool(2)] javax.enterprise.web - StandardWrapperValve[default]: Servlet.service() for servlet default threw exception
java.lang.StringIndexOutOfBoundsException: String index out of range: -27
    at java.lang.String.substring(String.java:1967)
    at net.bull.javamelody.I18N.writeTo(I18N.java:181)
    at net.bull.javamelody.I18N.writelnTo(I18N.java:198)
    at net.bull.javamelody.HtmlAbstractReport.writeln(HtmlAbstractReport.java:110)
    at net.bull.javamelody.HtmlJavaInformationsReport.writeServerInfoAndContextPath(HtmlJavaInformationsReport.java:222)
    at net.bull.javamelody.HtmlJavaInformationsReport.writeDetails(HtmlJavaInformationsReport.java:173)
    at net.bull.javamelody.HtmlJavaInformationsReport.toHtml(HtmlJavaInformationsReport.java:82)
    at net.bull.javamelody.HtmlCoreReport.toHtml(HtmlCoreReport.java:215)
    at net.bull.javamelody.HtmlReport.toHtml(HtmlReport.java:76)
    at net.bull.javamelody.HtmlController.doHtml(HtmlController.java:100)

I looked at the source code and think that the problem starts in HtmlJavaInformationsReport.java:

private void writeServerInfoAndContextPath(JavaInformations javaInformations)
throws IOException {
final String serverInfo = javaInformations.getServerInfo();
if (serverInfo != null) {
final String columnEnd = " </td></tr>";
writeln("<tr><td>#Serveur#: </td><td>");
final String applicationServerIconName = getApplicationServerIconName(serverInfo);
if (applicationServerIconName != null) {
writeln("<img src='?resource=servers/" + applicationServerIconName
+ "' alt='#Serveur#'/>");
}
writeln(serverInfo + columnEnd);
writeln("<tr><td>#Contexte_webapp#: </td><td>" + javaInformations.getContextPath()
+ columnEnd);
}
}        

plus there is no check if the searched character was found in the htmlstring -> I18N.java

static void writeTo(String html, Writer writer) throws IOException {
int index = html.indexOf('#');
if (index == -1) {
writer.write(html);
} else {
final ResourceBundle resourceBundle = getResourceBundle();
int begin = 0;
while (index != -1) {
writer.write(html, begin, index - begin);
final int nextIndex = html.indexOf('#', index + 1);
final String key = html.substring(index + 1, nextIndex);
writer.write(resourceBundle.getString(key));
begin = nextIndex + 1;
index = html.indexOf('#', begin);
}
writer.write(html, begin, html.length() - begin);
}
}

best regards
Thomas


thomask...@gmail.com

unread,
Dec 19, 2016, 5:30:26 PM12/19/16
to javamelody, thomask...@gmail.com
I open Issue #594 https://github.com/javamelody/javamelody/issues/594 and also created a pull rquest which solves the problem.
br
Thomas


Reply all
Reply to author
Forward
0 new messages