Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 有人熟悉jboss么? (javax.naming.NoInitialContextException)
TopCool

Miracle

CJSDN高级会员


发贴: 253
积分: 10
于 2003-06-09 17:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我有一个问题,ejb部署上去了
可是客户端(调试用的)运行有问题

源码:
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import javax.naming.*;

import org.jboss.docs.interest.Interest;
import org.jboss.docs.interest.InterestHome;

/** This simple application tests the 'Interest' Enterprise JavaBean which is
implemented in the package 'org.jboss.docs.interest'. For this to work, the
Bean must be deployed on an EJB server.
*/
class InterestClient
{
/** This method does all the work. It creates an instance of the Interest EJB on
the EJB server, and calls its `calculateCompoundInterest()' method, then prints
the result of the calculation.
*/
public static void main(String[] args)
{
// Enclosing the whole process in a single `try' block is not an ideal way
// to do exception handling, but I don't want to clutter the program up
// with catch blocks
try
{
// Get a naming context
     Properties properties = new Properties();
     properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
     properties.put(Context.PROVIDER_URL,"jnp://localhost:1099");
     //properties.put(Context.PROVIDER_URL_PKGS,"org.jboss.naming:org.jnp.interfaces");

InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");

// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("java:comp/env/ejb/Interest");
System.out.println("Got reference");

// Get a reference from this to the Bean's Home interface
InterestHome home = (InterestHome)
PortableRemoteObject.narrow(ref, InterestHome.class);

// Create an Interest object from the Home interface
Interest interest = home.create();

// call the calculateCompoundInterest() method to do the calculation
System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}

运行结果:D:\Temp\jboss\testejb>java InterestClient
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]

who can tell me why? thanks~


why edited on 2003-06-27 20:26


话题树型展开
人气 标题 作者 字数 发贴时间
13834 有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 2652 2003-06-09 17:53
12252 Re:有人熟悉jboss么? ww77721 53 2003-06-09 17:55
12897 Re:有人熟悉jboss TopCool 261 2003-06-11 12:01
12314 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) ww77721 229 2003-06-11 12:15
13060 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 151 2003-06-11 12:37
12989 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 203 2003-06-11 12:41
12051 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) jhlqab 136 2003-06-28 00:52
12165 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) jhlqab 27 2003-06-28 01:13
13320 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 939 2003-06-10 14:30
12012 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) ww77721 63 2003-06-10 15:17
12897 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 654 2003-06-10 15:34
12098 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) ww77721 866 2003-06-10 15:56
12954 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 971 2003-06-10 16:09
12095 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) ww77721 256 2003-06-10 17:58
13097 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 1143 2003-06-11 09:06
12057 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) ww77721 307 2003-06-11 09:25
13480 Re:有人熟悉jboss么? (javax.naming.NoInitialContextException) TopCool 4730 2003-06-11 11:59

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923