I have a simple XML file that I have parsed to JSON. All is fine and dandy, I have a Java class that is stand alone (i.e. it has a public static void main (String args[])....)
This has a private constructor (because I need to call it with Strings either a filename or the actual data). So I have two methods that return an instance of the object. I know a bit of Java as you can tell.
OK. When I run the code in Eclipse that runs the main method my file is loaded and decoded as required. It also works for a raw String that I run via JUnit.
So I know the following facts -
- the parsing of a static String works and decodes perfectly
- if I provide a file it is loaded and decoded correctly.
Now the issue:
As soon as I run it in Spring framework I can write to standard out the entire file content that I have run via the stand alone code.
But before it can run anything at all I get the below error -
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:920) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
The stand alone code is run in Eclipse, and the Spring is run pointing to that code using Tomcat 7.
Why is it not finding the ParsException correctly?
The imports in the calling Spring controller are
import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import org.apache.commons.lang.StringUtils; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser;
Is their a way of altering the build order, and would that fix it?