0 0

NoClassDefFoundError5

public void receiveJmsMail(MapMessage mailContent) {
        String senderAddress = null; //发送者
        String receiverAddress = null; //接收者
        String content = null;  //发送内容
        String priority = null;  //发送主题
        int mailId = 0;
        try {
            senderAddress = mailContent.getString(Constans.SEND_USER_ID);
            content = mailContent.getString(Constans.MSG_CONTENT);
            receiverAddress = mailContent.getString(Constans.RECEIVE_USER);
            priority = mailContent.getString(Constans.TITLE);
            mailId = Integer.parseInt(mailContent.getString(Constans.SMS_ID));
        } catch (JMSException e) {
            log.error("邮件内容异常 : ",e);
            return ;
        }
        try{
            MailMessage email = new MailMessage(receiverAddress, content, priority);
            SendMailMessage sendMailMessage =  new SendMailMessageImpl();
            SendMessageResult result  =  sendMailMessage.sendMail(email);
            if(result.getResultCode().equals("0")){
                msgService.update(mailId, "发送成功");
                log.info("[邮件消息发送成功,发送者:"+senderAddress+",接收者邮箱:"+receiverAddress+"]");
            }else if(result.getResultCode().equals("1")){
                msgService.update(mailId, "发送失败");
                log.info("[邮件消息发送失败,发送者:"+senderAddress+",接收者邮箱:"+receiverAddress+"]");
            }else if(result.getResultCode().equals("2")){
                retryGiveSendMsg(mailContent,2);//发生异常,重发消息
                msgService.update(mailId,"系统正在重发");
            }
        }catch(Exception e){
            log.error("发送邮件消息异常异常,系统将在:"+delyTime/60/1000+"分钟后重新发送!",e);
            retryGiveSendMsg(mailContent,2);//发生异常,重发消息
            msgService.update(mailId,"系统正在重发");
           
        }
    }

package cn.wzb.common.msg.mail;

/**
* send mail content
* @author gouwei
*
*/
public class MailMessage {
      String receiverAddress;   //接受者邮箱地�?
      String content;      //邮件内容
      String priority;    // 邮件主题
    public String getReceiverAddress() {
        return receiverAddress;
    }
    public void setReceiverAddress(String receiverAddress) {
        this.receiverAddress = receiverAddress;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getPriority() {
        return priority;
    }
    public void setPriority(String priority) {
        this.priority = priority;
    }
    public MailMessage(String receiverAddress,
            String content, String priority) {
        this.receiverAddress = receiverAddress;
        this.content = content;
        this.priority = priority;
    }


  
}调用这个方法的时候报错:NoClassDefFoundError:MailMessage

如果把MailMessage改为单例的。

则不会报这个错。而是:NoClassDefFoundError:SendMailMessageImpl

如果把SendMailMessageImpl改为单例的。

则不会报这个错。而是:NoClassDefFoundError:SendMessageResult

小弟百思不得其解。

调用receiveJmsMail方法为:

/**
* 邮件消息出jms队列
* @author gouwei
*/
public class QueueComsumerMail  extends QueueBase implements MessageListener {
    private static final long serialVersionUID = 1L;
    private static final Logger log = LoggerFactory.getLogger(QueueComsumerMail.class);
    //private MessageDrivenContext mdc;
    private QueueReceiver queueReceiver;
    private JmsCommon jmsCommon = new JmsCommonImpl();
    /**
     * 邮件接收消息
     * @param Message
     */
    public QueueComsumerMail() throws JMSException {
            queueReceiver = queueSession.createReceiver(queueMail);
            queueReceiver.setMessageListener(this);
            queueConnection.start();
    }
    /**
     * 邮件接收消息
     * @param Message
     */
    public void onMessage(Message message) {
        try {
            MapMessage mailContent = (MapMessage)message;
            jmsCommon.receiveJmsMail(mailContent);
        } catch (Exception e) {
            //mdc.setRollbackOnly();
            log.error("接收邮件消息异常!",e);
        }
    }

    public void close() throws JMSException {
        queueReceiver.close();
        queueSession.close();
        queueConnection.close();
    }


有点着急,希望大家帮我分析分析。。谢谢了!

2013年4月01日 19:05

1个答案 按时间排序 按投票排序

0 0

1、是不是没有编译?eclipse的话clean一下工程,重新编译
2、是不是包引用错误?确认一下

2013年4月01日 19:59

相关推荐

Global site tag (gtag.js) - Google Analytics