狂汗,ejb最简单的示例无法运行
dygs 2005-03-09 04:09:44 照网上的文章介绍做了个hello例子
在jboss4.0.1上部署成功,可是客户程序无法运行.
客户(HelloClient.java)代码:
package sample;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
public class HelloClient
{
public static void main(String[] args)
{
try
{
Properties p=new Properties();
p.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
p.setProperty("java.naming.provider.url", "localhost:1099");
InitialContext jndiContext = new InitialContext(p);
System.out.println("Got context");
// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("Hello");
System.out.println("Got reference");
// Get a reference from this to the Bean's Home interface
HelloHome home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(ref, HelloHome.class);
// Create an Hello object from the Home interface
Hello hello = home.create();
// call the hello() method
System.out.println(hello.hello());
hello.remove();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
编译能通过,可是运行报错
Exception in thread "main" java.lang.NoClassDefFoundError:HelloClient(wrong name:sample/HelloClient)
at java.lang.ClassLoader.defineClass0(Native Method)
还有许多at 就不一一写了
我把jboss/client下的一些.jar文件的路径已经加到classpath中了
请问各位大虾问题出在那儿,谢谢先