【问题标题】:javax.ejb.EJBException: nested exception is: java.rmi.UnmarshalException: Method not found: 'helloWorld(Ljava.lang.Long;Ljava.util.List;)'javax.ejb.EJBException:嵌套异常是:java.rmi.UnmarshalException:找不到方法:'helloWorld(Ljava.lang.Long;Ljava.util.List;)'
【发布时间】: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 文件中)。但是,仍然出现“找不到方法..”的异常..

陷阱在哪里? (按照类似帖子中的建议,我安装、更新和重新安装了几次部署 - 无济于事:()

谢谢

【问题讨论】:

    标签: java weblogic ejb-3.0


    【解决方案1】:

    可能是 MyException 类型的问题。确保在客户端和服务器端有可用的 MyException 类型,并且它满足远程调用(可序列化)的要求。

    另一个问题是远程接口的类型是 TaxSession 而不是 MySession。

    @Stateless(mappedName="ejb.TaxSession") @Remote(TaxSession.class) --> not MySession

    但是

     public  class MySessionEJB implements MySession
    

    你确定你提供了正确的远程接口,它拥有声明的方法 在 MySession 界面中。检查 EJB 部署输出的服务器日志。

    【讨论】:

    • 谢谢...到处都是TaxSession,我只是在这里更改了帖子的名称...但是在实际项目中该帐户一切正常。我将看看 MyException 案例..,它在客户端可用.. 虽然......在同一个接口/Ejb 我有其他方法,它们工作正常并且具有相同的签名..这很奇怪..
    【解决方案2】:

    我解决了这个问题。以下是详细信息,如果有人遇到同样的问题

    在我的代码中,我使用了泛型!!

    public String helloWorld(Long theId, List<String>list) throws MyException{}
    

    有一次,我删除了它 - 它开始正常工作。 不知道它背后的理论概念是什么,但它确实有效!

    【讨论】:

    • 有谁知道这可能是什么原因?我又遇到了同样的问题,但现在 - 没有泛型
    猜你喜欢
    • 2011-12-11
    • 2012-12-13
    • 2018-06-15
    • 1970-01-01
    • 2019-09-28
    • 2020-02-15
    • 1970-01-01
    • 2017-07-30
    • 2016-06-20
    相关资源
    最近更新 更多