即使存在try / Catch块,JMS异常编译错误

问题描述 投票:0回答:1
package com.spring.trip.spring3.jms.activemq;
import java.util.Map;

import org.springframework.jms.JmsException;
import org.springframework.jms.core.JmsTemplate;
public class MessageSender 
{

    private final JmsTemplate jmsTemplate;

    public MessageSender(final JmsTemplate jmsTemplate) {
        this.jmsTemplate = jmsTemplate;
    }

    public void send(final Map map) throws java.lang.Exception
    {
          try {
            jmsTemplate.convertAndSend(map);
        } catch (JmsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

上面是我的代码,即使我有try / catch块,也会出现以下错误。有帮助吗?非常感谢!!!

No exception of type JmsException can be thrown; an exception type must be a subclass of Throwable
java exception-handling jms try-catch
1个回答
0
投票

可能你的类加载器中没有NestedRuntimeException ...或者JmsException heriarchy的任何类

添加到classLoader spring-core jar并确保它开始工作!

© www.soinside.com 2019 - 2024. All rights reserved.