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

您没有登录

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

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 调试EJB遇到一点问题,大家看看
dingwm





发贴: 7
积分: 0
于 2005-05-07 12:22 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
MYECLIPSE+JBOSS4
写了个EJB
测试时遇到问题 请各位大侠看看
客户端代码:
/*
* Created on 2005-5-6
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.bjb.helloworld.test;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.bjb.helloworld.ejb.*;
import com.bjb.helloworld.interfaces.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import org.jnp.interfaces.NamingContextFactory;
/**
* @author cclx
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class HelloTestClient {

  public static void main(String[] args) throws Exception {
    Context ctx=getInitialContext();
    Object obj=ctx.lookup(HelloWorldHome.JNDI_NAME);
    HelloWorldHome helloworldhome=(HelloWorldHome)PortableRemoteObject.narrow
    (obj,HelloWorldHome.class);
    HelloWorld helloworld=helloworldhome.create();
    System.out.println(helloworld.helloWorld());
  }
  private static Context getInitialContext() throws Exception{
    String url="t3://127.0.0.1:7001";
    String user="cclx";
    String password="cclx";
    Properties properties=null;
    
    properties=new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY,
        "org.jnp.interfaces.NamingContextFactory");
    properties.put(Context.PROVIDER_URL,url);
    if(user!=null){
      properties.put(Context.SECURITY_PRINCIPAL,user);
      properties.put(Context.SECURITY_CREDENTIALS,
          password==null? "" : password);
    }
    return new InitialContext(properties);
  }
}

错误
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
  at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
  at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
  at javax.naming.InitialContext.init(InitialContext.java:219)
  at javax.naming.InitialContext.<init>(InitialContext.java:195)
  at com.bjb.helloworld.test.HelloTestClient.getInitialContext(HelloTestClient.java:45)
  at com.bjb.helloworld.test.HelloTestClient.main(HelloTestClient.java:23)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
  at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:219)
  at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
  at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
  ... 5 more
Exception in thread "main"




话题树型展开
人气 标题 作者 字数 发贴时间
6839 调试EJB遇到一点问题,大家看看 dingwm 3096 2005-05-07 12:22
5190 Re:调试EJB遇到一点问题,大家看看 wangaman 84 2005-05-09 13:43
5432 Re:调试EJB遇到一点问题,大家看看 dingwm 19 2005-05-09 15:06

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