狂汗,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中了
请问各位大虾问题出在那儿,谢谢先


...全文
88 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dygs 2005-03-10
  • 打赏
  • 举报
回复
谢谢各位,现在给分
ejb2 2005-03-10
  • 打赏
  • 举报
回复
你运行该文件时出了问题

Exception in thread "main" java.lang.NoClassDefFoundError:HelloClient(wrong name:sample/HelloClient)

意思是说,找不到Main函数,找不到sample.HelloClient.

有几种可能:1,你没有将"."加到类路径下.2,你运行该程序时所在的文件夹有问题.
tibhar 2005-03-10
  • 打赏
  • 举报
回复
看看包文件夹有没有问题
zdnetchina 2005-03-09
  • 打赏
  • 举报
回复
把url贴出来
dygs 2005-03-09
  • 打赏
  • 举报
回复
up
h_q_l 2005-03-09
  • 打赏
  • 举报
回复
你有没有将hellohome.class和hello.class复制相应的目录中
或者是环境没有配置好

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧