【异常】java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher异常解决方法

    今天在做web项目时用到JSONObject,用的是MyEclipse自动导入的struts2的lib,其中自带了json-lib-2.1-jdk15.jar。

    在struts2的action中已经导入了net.sf.json.JSONObject包。发现用到JSONObject jsonObject = new JSONObject()时,MyEclipse是没有报错的,但是到了JSONObject jsonObject = new JSONObject()时就是执行不下去!

 

 

HTTP Status 500 -


 

type Exception report

message

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.reflect.InvocationTargetException
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	……………………
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

 

root cause

java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
	mapsns.action.Login.login(Login.java:34)
	……………………
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

 

root cause

java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
	……………………
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

 

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.


 

Apache Tomcat/7.0.30

 

 

        其中发现java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher,很明显是没有找到相应的class。原来是除了要导入json-lib-2.1-jdk15.jar包外,还要导入其它几个依赖包:commons-beanutils.jar,commons-httpclient.jar,commons-lang.jar,ezmorph.jar,morph-1.0.1.jar

 

       导入这几个依赖包之后就不再出错了!

 

http://blog.csdn.net/weizi4332/article/details/9302229

 

 

猜你喜欢

转载自zgphacker2010.iteye.com/blog/2401325