EJB 2.1 ClasscastException

时间:2012-06-19 10:59:40

标签: java ejb ejb-2.x

以下是我的代码

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。有什么想法我可能做错了吗?感谢。

1 个答案:

答案 0 :(得分:1)

您正在尝试转换为(SanityAutomationAvailabilityMain)并获得classcastexception,无论您尝试投射的值是什么类型,都与SanityAutomationAvailabilityMain不兼容。