简体   繁体   English

javax.ejb.EJBException:嵌套异常是:java.rmi.UnmarshalException:找不到方法:'helloWorld(Ljava.lang.Long; Ljava.util.List;)'

[英]javax.ejb.EJBException: nested exception is: java.rmi.UnmarshalException: Method not found: 'helloWorld(Ljava.lang.Long;Ljava.util.List;)'

Getting the exception while running my EJB3 application on weblogic (10.2) 在Weblogic上运行EJB3应用程序时获取异常(10.2)

javax.ejb.EJBException: nested exception is: java.rmi.UnmarshalException: Method not 
found: 'helloWorld(Ljava.lang.Long;Ljava.util.List;)'

I created a method as exact copy of what is there that works. 我创建了一个方法,作为那里工作的精确副本。 However this very method didn't work. 但是,这种方法不起作用。

My Business Interface has the following definition 我的业务界面具有以下定义

  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;

My Bean implementation class 我的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 ;
  }

 }

And here is a client code (JUnit 4): 这是一个客户端代码(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();
}
}

I check the ear file, and see that method is there. 我检查了ear文件,然后看到了该方法。 Before this, my method had "long" instead of "Long" in a first parameter, and in ear file, I could only see 2nd parameter. 在此之前,我的方法在第一个参数中使用“ long”而不是“ Long”,并且在ear文件中,我只能看到第二个参数。 I gathered it has something to do with serialization.. so I changed to Long - and now both parameters appear (in ear file). 我收集到它与序列化有关..因此我更改为Long-现在两个参数都出现在(ear文件中)。 However, exception abot "Method Not found.." still comes up.. 但是,仍然出现异常提示“方法未找到..”。

Where is the pitfall? 陷阱在哪里? (I installed, updated and re-installed the deployment few times, as suggested in the similar post - to no avail :( ) (按照类似的帖子中的建议,我几次安装,更新并重新安装了部署-无济于事:()

Thanks 谢谢

Could be a problem with the MyException type. MyException类型可能有问题。 Be sure to have the MyException type available at client and server side and that it meets the requirenments for remote invocations (Serializable). 确保在客户端和服务器端都具有MyException类型,并且该类型符合远程调用的要求(可序列化)。

Another problem is that the remote interface is of type TaxSession and not MySession. 另一个问题是远程接口的类型为TaxSession,而不是MySession。

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

but

 public  class MySessionEJB implements MySession

Are you sure that you provide the right remote interface which owns the method declared within the MySession interface. 是否确定提供正确的远程接口,该接口拥有MySession接口中声明的方法。 Check the server logs for EJB deployment outputs. 检查服务器日志中的EJB部署输出。

I solved the issue. 我解决了这个问题。 Here are details, if someone should run into the same problem 如果有人遇到同样的问题,这里是详细信息

In my code, I used generics !! 在我的代码中,我使用了泛型!

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

Once, I removed that - it started working OK. 一次,我删除了它-它开始正常工作。 Don't know what is the theoretical concept behind it, but it worked !! 不知道它背后的理论概念是什么,但是它起作用了!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在EJB 3中使用appclient jar的异常:javax.ejb.EJBException:java.rmi.MarshalException: - Exception in using appclient jar in EJB 3 :javax.ejb.EJBException: java.rmi.MarshalException: javax.ejb.EJBException:java.rmi.MarshalException - javax.ejb.EJBException: java.rmi.MarshalException java.rmi.UnmarshalException: 解组参数错误; 嵌套异常是:java.lang.ClassNotFoundException: ServicesTableau - java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: ServicesTableau Java Wildfly javax.ejb.EJBException - Java Wildfly javax.ejb.EJBException Java企业应用程序-javax.ejb.EJBException - Java enterprise application - javax.ejb.EJBException java.lang.ClassCastException:[Ljava.lang.Long; 不能强制转换为java.lang.Long - java.lang.ClassCastException: [Ljava.lang.Long; cannot be cast to java.lang.Long java:ClassCastException - [Ljava.lang.Long; 无法强制转换为java.lang.Long - java: ClassCastException - [Ljava.lang.Long; cannot be cast to java.lang.Long 线程“main”中的异常 javax.ejb.EJBException: java.io.StreamCorruptedException: 读取对象时发现意外字节 - Exception in thread "main" javax.ejb.EJBException: java.io.StreamCorruptedException: Unexpected byte found when reading an object Glassfish javax.ejb.EJBException - Glassfish javax.ejb.EJBException 调用ejb方法时出现“ javax.ejb.EJBException:错误解组参数java.io.EOFException” - Got “javax.ejb.EJBException: error unmarshalling arguments java.io.EOFException” when calling an ejb method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM