0

According to the Spring Boot 1.2.3 Reference Docs. Enabling jolokia seems to be as simple as adding as adding the following Maven dependency:

<dependency>
    <groupId>org.jolokia</groupId>
    <artifactId>jolokia-core</artifactId>
 </dependency>

While this does work for a Spring Boot application packaged as a fat jar, I am unable to get this to work when packaged as a WAR file.

The root cause appears to be:

Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONAware

I'm using STS for development purposes and deploying to an embedded pivotal tc Server 3.1. The dependency(json-simple-1.1.1.jar) containing the org.json.simple.JSONAware does appear under the Maven Dependency node so I'm not sure what the issue is.

mjj1409
  • 3,075
  • 6
  • 28
  • 28

2 Answers2

1

So as I was composing the question I stumbled onto a solution that at least seems to work for me:

I took a look at the effective POM and found this dependency declaration:

      <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
        <optional>true</optional>
      </dependency>

So for lack of better option I declared the following dependency explicitly

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <optional>false</optional>
  </dependency>

Adding false to the the <optional> element seemed necessary.

Now I can access jolokia via the following url:

http://<myurl>:<myport>/<appcontext>/jolokia
mjj1409
  • 3,075
  • 6
  • 28
  • 28
1

Looking at 1.4.4 this seems to have been fixed:

<dependency>
  <!-- Make json-simple non-optional. 
       It is marked optional in boot-dependencies, but required by jolokia-core.
       Without this fix it would be missing when used war-packaging. -->
  <groupId>com.googlecode.json-simple</groupId>
  <artifactId>json-simple</artifactId>
  <optional>false</optional>
</dependency>

Yet I'm seeing similar issues running a war in JBoss.

deanpullen
  • 128
  • 1
  • 10