您的位置:首页 > 编程语言 > Java开发

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

2017-11-10 14:05 471 查看
  今天在做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

      点击下载依赖jar包

       导入这几个依赖包之后就不再出错了!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐