0

下面是我的代码

Properties localProperties = new Properties();
      localProperties.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
      localProperties.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
      localProperties.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
      localProperties.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
      localProperties.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
      InitialContext localInitialContext = new InitialContext(localProperties);
      SanityAutomationAvailabilityMain localSanityAutomationAvailabilityMain = (SanityAutomationAvailabilityMain)localInitialContext.lookup("ejb/com/cw/wad/sanity/ejb/session/interfaces/SanityAutomationAvailabilityMain");

我用上面的代码得到了一个classcastexception。关于我可能做错了什么的任何想法?谢谢。

4

1 回答 1

1

您正在尝试转换为 (SanityAutomationAvailabilityMain) 并且您得到一个类转换异常,那么无论您尝试转换的值是什么类型,都与 SanityAutomationAvailabilityMain 不兼容。

于 2012-06-19T12:40:45.207 回答