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

来源:互联网 发布:淘宝代购 编辑:程序博客网 时间:2024/05/29 05:55

  今天在做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.InvocationTargetExceptionsun.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/Morphermapsns.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.Morpherorg.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包

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

阅读全文
0 0