title: NoSuchMethod error when using org.json to convert XML to JSON
body: <p>My project uses Spring Boot 2.0.4. I'm trying to read XML from a file and then convert it to JSON. This used to work, but recently it has stopped working and throws the exception below;</p>
  
  <pre><code>java.lang.NoSuchMethodError: org.json.JSONTokener.&lt;init&gt;(Ljava/io/Reader;)V
      at org.json.XMLTokener.&lt;init&gt;(XMLTokener.java:57) ~[json-20180813.jar:na]
      at org.json.XML.toJSONObject(XML.java:516) ~[json-20180813.jar:na]
      at org.json.XML.toJSONObject(XML.java:548) ~[json-20180813.jar:na]
      at org.json.XML.toJSONObject(XML.java:472) ~[json-20180813.jar:na]
      at com.zf.trw.visualisation.parser.handler.AttritionHandler.extractLineData(AttritionHandler.java:32) ~[classes/:na]
      at com.zf.trw.visualisation.parser.handler.HandlerImp.processFile(HandlerImp.java:79) ~[classes/:na]
      at com.zf.trw.visualisation.shared.service.ParserService.manuallyProcessAttritionData(ParserService.java:85) ~[classes/:na]
      at com.zf.trw.visualisation.parser.component.ScheduledTask.processAttritionDataFilesForAllLines(ScheduledTask.java:49) ~[classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
      at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
      at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
      at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93) [spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_171]
      at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_171]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_171]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_171]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171]
      at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
  </code></pre>
  
  <p>The code I'm using to convert the XML to JSON is as follows;</p>
  
  <pre><code>String fileContents = FileUtils.readFileToString(file, "UTF-8");
  json = XML.toJSONObject(fileContents);
  </code></pre>
  
  <p>In my POM file, I'm defining the dependency like this;</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;org.json&lt;/groupId&gt;
              &lt;artifactId&gt;json&lt;/artifactId&gt;
              &lt;version&gt;20180813&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>The exception appears to show it's trying to use the same version that I have specified in the POM file, which is the latest version.</p>
  
  <p>Why am I seeing this error?</p>