【问题标题】:Spring JMX Integration IssueSpring JMX 集成问题
【发布时间】:2015-11-10 09:13:16
【问题描述】:

我有一个类似下面的 java 类,

public class MyImportService {
    Logger m_logger = Logger.getLogger(MyImportService.class);
    @Autowired
    @Qualifier("tService")
    private TService m_tservice;
    public Integer import(String zipFilePath,String userName) {
        int result = 0;
        File file = new File(zipFilePath);
        try {
            FileInputStream fileInputStream = new FileInputStream(zipFilePath);
            ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
            m_taskservice.importT(zipInputStream, file.getName(), userName);
            m_logger.info("SuccessFully Imported"");
        }
        catch (IOException e){
            result =  1;
            m_logger.error("Error while importing the file :",e);
        }
        return result;
    }
}

在我的应用程序上下文中,我的配置如下所示。

<bean id="myImportService" class="com.service.MyImportService " />
    <bean id="exporter"
          class="org.springframework.jmx.export.MBeanExporter">
        <property name="server" ref="mbeanServer" />
        <property name="beans">
            <map>
                <entry
                        key="application.MyApp:service=importTService"
                        value-ref="myImportService" />
            </map>
        </property>
    </bean>

如果出现异常,它的工作正常,我会得到一个返回值 1。但如果文件存在,我会得到一个运行时异常。

javax.management.MBeanException:在尝试调用操作时在RequiredModelMBean中抛出RuntimeException

请帮帮我

【问题讨论】:

  • 您是否尝试调试以确定“快乐路径”为什么会引发异常?异常消息肯定会包含详细原因 - 您没有在问题中包含这个最重要的难题...

标签: java spring jmx spring-jmx


【解决方案1】:

添加一个catch (RuntimeException e) catch 块并打印堆栈跟踪,这样您就可以看到根本问题是什么。

【讨论】:

    猜你喜欢
    • 2017-01-27
    • 1970-01-01
    • 2014-08-06
    • 2015-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多