【发布时间】:2014-08-14 16:20:19
【问题描述】:
在 weblogic (10.2) 上运行我的 EJB3 应用程序时出现异常
javax.ejb.EJBException: nested exception is: java.rmi.UnmarshalException: Method not
found: 'helloWorld(Ljava.lang.Long;Ljava.util.List;)'
我创建了一个方法作为有效方法的精确副本。然而这种方法 没用。
我的业务接口有以下定义
public abstract interface MySession {
// .. some other methods here, which works fine
/**
* Returns .... something
*
* @param theId ...
*
* @throws MyException If ...something happens
*
* @ejb.interface-method
*/
public String helloWorld(Long theId, List<String>list) throws MyException;
我的 Bean 实现类
@Stateless(mappedName="ejb.TaxSession")
@Remote(TaxSession.class)
public class MySessionEJB implements MySession {
@javax.persistence.PersistenceContext(unitName="myDS")
private EntityManager m_SCSentityManager ;
//.. some methods that work ... (defined in a same fashion as the bad one ..
/**
* Returns tax details from tblDiscreteTaxcollected by BillID
*
* @param theId ...
*
* @throws MyException If something wrong..
*
* @ejb.interface-method
*/
public String helloWorld(Long theId, List<String>list) throws MyException{
String returnValue = "Hello world !!" ;
return returnValue ;
}
}
这是一个客户端代码(JUnit 4):
@Test
public final void taxesByWtns() {
System.out.println("Test taxation started...");
long theId= 1111222;
List<String> theList= new ArrayList<String>();
theList.add("test1");
theList.add("test2");
theList.add("test3");
try {
System.out.println(getTaxSession().helloWorld(theId, theList));
} catch (MyException e) {
System.out.println("EXCEPTION HAS OCCURED !!") ;
e.printStackTrace();
} catch (NamingException e) {
System.out.println("EXCEPTION HAS OCCURED !!") ;
e.printStackTrace();
}
}
我检查了 ear 文件,发现有那个方法。在此之前,我的方法在第一个参数中使用“long”而不是“Long”,而在 ear 文件中,我只能看到第二个参数。我收集到它与序列化有关..所以我改为 Long - 现在两个参数都出现了(在 ear 文件中)。但是,仍然出现“找不到方法..”的异常..
陷阱在哪里? (按照类似帖子中的建议,我安装、更新和重新安装了几次部署 - 无济于事:()
谢谢
【问题讨论】: