u011148770
老李的地下室
采纳率0%
2016-08-26 10:20 阅读 2.6k

java.lang.NoClassDefFoundError:

2

java 开发中遇到java.lang.NoClassDefFoundError: org/apache/avalon/framework/CascadingThrowable
错误信息,有时候会报,是什么原因导致的,如何解决,各路英雄好汉。下面附件错哦无信息图片和代码。谢谢

图片说明

package cn.com.pkufi.business.web.action.wechat;

import org.apache.avalon.framework.ExceptionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.com.jingpeng.business.util.authorize.AuthorizeUtil;
import cn.com.jingpeng.business.web.action.BaseAction;

public class Test1 extends BaseAction{

private String forwardUrl;
private String openId;
private String code;

private static final Logger logger = LoggerFactory.getLogger("wechat");



public String oauth2() {
    try {
        logger.info("[被动方式]授权用户获得的code : "+code+",req:"+request.getParameter("code"));
        String oauth2AccessToken = "" ;
        AuthorizeUtil.authorize(code);
        openId = AuthorizeUtil.openId;
        oauth2AccessToken = AuthorizeUtil.oauth2AccessToken ;
        session.put("Oauth2.AccessToken", oauth2AccessToken);
        logger.info("[被动方式]授权用户获得的openid : "+openId);
        session.put("wechat.openId", openId);
        logger.info("[被动方式]授权后跳转, forwardUrl: "+forwardUrl); 
        logger.info("=============授权成功==============="); 
    } catch (Exception e) {
        logger.error(ExceptionUtil.printStackTrace(e));
        e.printStackTrace();
        return ERROR;
    }
    return SUCCESS;
}



public String getOpenId() {
    return openId;
}

public void setOpenId(String openId) {
    this.openId = openId;
}

public String getForwardUrl() {
    return forwardUrl;
}

public void setForwardUrl(String forwardUrl) {
    this.forwardUrl = forwardUrl;
}

public String getCode() {
    return code;
}

public void setCode(String code) {
    this.code = code;
}

@Override
protected void processResultBusiness(boolean resultSuccess,
        String resultCode, String resultDescription) {
    // TODO Auto-generated method stub

}

}


[16-8-26 9:25:24:234 CST] 00000ad1 SystemOut O 2016-08-26 09:25:24,234 [WebContainer : 17] [org.hibernate.impl.SessionImpl] DEBUG org.hibernate.impl.SessionImpl -opened session at timestamp: 14721747242
[16-8-26 9:25:24:235 CST] 00000ad1 SystemOut O 2016-08-26 09:25:24,235 [WebContainer : 17] [cn.com.pkufi.business.web.action.wechat.AuthorityAction] INFO wechat -[被动方式]授权用户获得的code : null
[16-8-26 9:25:24:236 CST] 00000ad1 DefaultDispat E com.opensymphony.xwork2.util.logging.commons.CommonsLogger error Exception occurred during processing request: Method "oauth2" failed for object cn.com.pkufi.business.web.action.wechat.AuthorityAction@23fb8621
ognl.MethodFailedException: Method "oauth2" failed for object cn.com.pkufi.business.web.action.wechat.AuthorityAction@23fb8621 [java.lang.NoClassDefFoundError: org/apache/avalon/framework/CascadingThrowable]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1306)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

6条回答 默认 最新

  • CSDN_ZOL csdn_ZOL 2016-08-26 11:09

    code没有赋值,没赋值就还是初始化的null,

    写成code = request.getParameter("code");

    这样试试吧。

    点赞 评论 复制链接分享
  • qq_26929957 Cc_Davis_cC 2016-08-26 11:36

    java.lang.NoClassDefFoundError,看到这几字,我想到了:是不是jar包少了。

    点赞 评论 复制链接分享
  • qq_28298977 hanlang_java 2016-08-26 16:34

    java.lang.NoClassDefFoundError一般有两种情况下会出现
    一、所需要的类不在classpath中,或者类所在的jar不在classpath中
    二、classLoader根据类加载规则,无法找到对应的类的字节码
    第一种很好解决,只需要找到相关的类,并把它放到classpath中去,第二种一般情况比较复杂,需要按图索冀,查找到classLoader相关的信息来做分析

    点赞 评论 复制链接分享
  • Marksinoberg 泰 戈 尔 2016-08-26 22:27

    丢包了吧。检查一下吧

    点赞 评论 复制链接分享
  • yeluofengchui Z_yq 2016-08-29 02:24

    检查是否最少对应的jar包,如果存在jar包找不到对应类,是需要clean

    点赞 评论 复制链接分享
  • yeluofengchui Z_yq 2016-08-29 02:25

    缺少对应的jar包,找不到这个类

    点赞 评论 复制链接分享

相关推荐