I got an java.lang.NoClassDefFoundError when running my program!?
Here is the stack trace:
java.lang.NoClassDefFoundError: org/apache/xerces/framework/XMLParser
abc.def.presentation.controllers.UnixServerJobController.handleRequestInternal(UnixServerJobController.java:64)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
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:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
Here is the code for those who concern
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception{
try{
String jobName = request.getParameter("JobName");
jobName.concat(".xml");
String config = request.getParameter("Config");
File file = new File(config + "/"+jobName);
ConfigFile jobConfig = new ConfigFile(file);
SchdJobCaller jobCaller = getJobCaller();
jobCaller.runJobs(jobConfig);
}
catch(Exception e){
e.printStackTrace();
throw e;
}
return null;
}
Just passing an url like this abc.com/def.jsp?JobName=name1&Config=config1 to be handled by the controller in Spring Web MVC!
This is what I found when googling around!
If you are working in J2EE environment than visibility of Class among multiple Classloaders can also cause java.lang.NoClassDefFoundError, see examples and scenario section for detailed discussion.
Read more: http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-in.html#ixzz28CQRODWN
This could be the root of the problem, but how to solve the visibility of Class to multiple Classloaders!??
This is the first time I got an error like this!
Is there any advice for me?
Thanks
You have to find a JAR containing the Apache Xerces XML parser and put it in your CLASSPATH.
Looks like the investxa controllers package wants to use Xerces. Personally, I don’t think that’s a good idea. The Java JDK has had DOM and SAX parsers built in for quite a while.