无法捕获COMM_FAILURE异常(java)

时间:2011-05-11 12:52:11

标签: java ejb corba

我正在与EJB通信一个独立的应用程序,如果没有打开持有EJB的服务器,我会收到类似这样的COMM_FAILURE:

May 11, 2011 9:42:50 AM com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No
        at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:3431)
      ...
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at app.comercio.system.RemoteBeans.lookupProducts(RemoteBeans.java:33)
    at app.comercio.system.Controller.sendSpec(Controller.java:86)
    at app.comercio.view.Main.sendSpec(Main.java:175)
    at app.comercio.view.Main.main(Main.java:54)

我尝试在main上捕获此异常,并将其抛给sendSpec,sendSpec和lookupProducts,但是我不知道这是否有效,因为InitialContext.lookup只抛出NamingException。 有没有办法捕捉这个例外?

1 个答案:

答案 0 :(得分:2)

这是一个运行时异常,因此它不会被声明为抛出,但您仍然可以像任何异常一样捕获它并处理它

   extended byjava.lang.Throwable
      extended byjava.lang.Exception
         extended byjava.lang.RuntimeException
              extended byorg.omg.CORBA.SystemException
                  extended byorg.omg.CORBA.COMM_FAILURE