2015年11月18日 | Leave a comment 问题: 老报错 can’t cast to TestBean @Test public void testGreeting() throws Exception { System.out.println("greeting"); String name = "aaa"; EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer(); TestBean instance = (TestBean)container.getContext().lookup("java:global/classes/TestBean"); String expResult = "hello aaa"; String result = instance.greeting(name); assertEquals(expResult, result); container.close(); } 1234567891011 @Test public void testGreeting() throws Exception { System.out.println("greeting"); String name = "aaa"; EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer(); TestBean instance = (TestBean)container.getContext().lookup("java:global/classes/TestBean"); String expResult = "hello aaa"; String result = instance.greeting(name); assertEquals(expResult, result); container.close(); } 解决: 去掉接口 glassfish 的bug?