下面是我的代码
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。关于我可能做错了什么的任何想法?谢谢。
最佳答案
您正在尝试将其强制转换为(SanityAutomationAvailabilityMain),并且获得了classcastexception,那么无论您尝试强制转换的值是哪种类型,都与SanityAutomationAvailabilityMain不兼容。