Spring JMX 集成问题

Spring JMX Integration Issue

我有一个 java class 如下所示,

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>

如果出现异常,它工作正常,我得到一个 return 值 1。但是如果文件存在,我得到一个运行时异常,比如。

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

请帮帮我

添加一个 catch (RuntimeException e) catch 块并打印堆栈跟踪,以便您了解潜在的问题所在。