Skip to content

Commit 0d72669

Browse files
committed
[bugfix] Make sure the JMXServlet Token is created eagerly so that it is available for tools like Monex
Closes #6
1 parent 03e87e2 commit 0d72669

File tree

2 files changed

+12
-14
lines changed
  • exist-core/src/main/java/org/exist/management/client
  • exist-jetty-config/src/main/resources/webapp/WEB-INF

2 files changed

+12
-14
lines changed

exist-core/src/main/java/org/exist/management/client/JMXServlet.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,14 @@ public void init(ServletConfig config) throws ServletException {
236236
}
237237

238238
// Setup token and tokenfile
239-
obtainTokenFileReference();
240-
241-
LOG.info("JMXservlet token: {}", getToken());
239+
if (tokenFile == null) {
240+
tokenFile = dataDir.resolve(TOKEN_FILE);
241+
LOG.info("Token file: {}", tokenFile.toAbsolutePath().toAbsolutePath());
242+
}
242243

244+
// NOTE(AR) make sure to create the token in init when the servlet is loaded at startup so that it is present for Monex
245+
final String token = getToken();
246+
LOG.info("JMXServlet token: {}", token);
243247
}
244248

245249
/**
@@ -309,17 +313,6 @@ boolean hasSecretToken(HttpServletRequest request, String token) {
309313
return false;
310314
}
311315

312-
/**
313-
* Obtain reference to token file
314-
*/
315-
private void obtainTokenFileReference() {
316-
317-
if (tokenFile == null) {
318-
tokenFile = dataDir.resolve(TOKEN_FILE);
319-
LOG.info("Token file: {}", tokenFile.toAbsolutePath().toAbsolutePath());
320-
}
321-
}
322-
323316
/**
324317
* Get token from file, create if not existent. Data is read for each call so the file can be updated run-time.
325318
*

exist-jetty-config/src/main/resources/webapp/WEB-INF/web.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@
176176
<servlet>
177177
<servlet-name>JMXServlet</servlet-name>
178178
<servlet-class>org.exist.management.client.JMXServlet</servlet-class>
179+
<!-- NOTE(AR) required for Monex to correctly retrieve the JMX Token
180+
as the JMXServlet has to create it before Monex makes its first request
181+
for the status page
182+
-->
183+
<load-on-startup>3</load-on-startup>
179184
</servlet>
180185

181186
<!--

0 commit comments

Comments
 (0)