java.lang.reflect.UndeclaredThrowableException

时间:2014-06-10 10:10:15

标签: java jboss ejb

在我的ejb客户端代码中

package client;

import com.homeif.HelloWorldHome;
import com.remoteif.HelloWorld;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.awt.image.LookupOp;
import java.util.Properties;

public class HelloClient {
    public static void main(String args[]) {
        try {
            Context initialContext = new InitialContext();
            Object object = initialContext.lookup("HelloWorldBean");
            System.out.println("Object:-"+object);
            HelloWorldHome home =
                    (HelloWorldHome) PortableRemoteObject.narrow(object,
                            HelloWorldHome.class);

            HelloWorld myHelloWorld = home.create();

            String message = myHelloWorld.sayHello();
            System.out.println(message);
        } catch (Exception e) {
            System.err.println(" Error : " + e);
            System.exit(2);
        }

    }
}

我收到以下错误     

 java.lang.Exception: java.lang.NoSuchMethodError: org.jboss.remoting.Version.getDefaultVersion()

它在以下一行

    HelloWorldHome home =(HelloWorldHome) PortableRemoteObject.narrow(object,                           HelloWorldHome.class);

为什么会这样?我该如何解决这个问题?

我使用的jar是jboss-remoting-1.4.1.final.jar。但是其中的Version类并不包含函数getDefaultVersion。有人可以告诉我这个jar文件吗?

1 个答案:

答案 0 :(得分:0)

我添加了jboss-remoting-4.2.2.GA.jar。这解决了问题