在EJB中运行客户端代码时出错 [英] Error while running client code in EJB

查看:190
本文介绍了在EJB中运行客户端代码时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


线程主线程中的异常java.lang.NoClassDefFoundError:
weblogic / kernel / KernelStatus在
weblogic.jndi.Environment。(Environment.java:78)at
weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
在javax.naming。在
下的InitialContext.init(InitialContext.java:223)
javax.naming.InitialContext。(InitialContext.java:197)at
User.main(User.java:21)


我添加了 wlfullclient.jar ,服务器的远程接口jar,我也看到了我看到添加的文章 wlclient.jar weblogic.jar ,但也有相同的错误。



帮助高度赞赏。



客户端代码:

  import com.amdocs.Stateful。*; 
import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class User
{
public static void main(String args []){
Hashtable< String,String> ht = new Hashtable< String,String>();

ht.put(InitialContext.INITIAL_CONTEXT_FACTORY,weblogic.jndi.WLInitialContextFactory); //你必须从根位置开始搜索JNDI树
// JNDI注册表树是正常的维护为二进制树,JNDi通常是二叉树,顶端有根节点

ht.put(InitialContext.PROVIDER_URL,t3:// localhost:7001); //注册地址
try {
System.out.println(Hello);
InitialContext ic = new InitialContext(ht); //开始搜索wrt我们在ht中设置什么,它的构造函数只使用HashTable

System.out.println(Hello2);
MyCartRemote ref =(MyCartRemote)ic.lookup(MyCartBeanJNDI#com.amdocs.Stateful.MyCartRemote);
ref.add(嗨);
ref.add(Jeetendra);

MyCartRemote ref1 =(MyCartRemote)ic.lookup(MyCartBeanJNDI#com.amdocs.Stateful.MyCartRemote);
ref1.add(嗨);
ref1.add(Subhash);
ref1.add(Ghai);

System.out.println(Object 1 data:+ ref.show());
System.out.println(Object 2 data:+ ref1.show());
}
catch(NamingException e){e.printStackTrace();
}
}


解决方案

尝试从引导条目部分中删除WebLogic系统库。当我遇到相同的错误时,它对我有用。


Getting error while running client code in EJB:

Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus at weblogic.jndi.Environment.(Environment.java:78) at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.(InitialContext.java:197) at User.main(User.java:21)

I added wlfullclient.jar, server's Remote interface jar, also I saw article in which I saw to add wlclient.jar and weblogic.jar but then also got same error.

Help highly appreciated.

Client code:

import com.amdocs.Stateful.*;
import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class User 
{
public static void main(String args[]){
Hashtable<String,String> ht = new Hashtable<String,String>();

ht.put(InitialContext.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");// you have to start from root location to search for JNDI tree
//JNDI registry tree is normally maintained as Binary tree, JNDi is normally binary tree which have root node at top

ht.put(InitialContext.PROVIDER_URL,"t3://localhost:7001"); // address of registry
try{
    System.out.println("Hello");
    InitialContext ic = new InitialContext(ht); // start searching wrt what we set in ht , it's constructor takes HashTable only

    System.out.println("Hello2");
    MyCartRemote ref=(MyCartRemote)ic.lookup("MyCartBeanJNDI#com.amdocs.Stateful.MyCartRemote");
    ref.add("Hi");
    ref.add("Jeetendra");

    MyCartRemote ref1=(MyCartRemote)ic.lookup("MyCartBeanJNDI#com.amdocs.Stateful.MyCartRemote");
    ref1.add("Hi");
    ref1.add("Subhash");
    ref1.add("Ghai");

    System.out.println("Object 1 data: "+ref.show());
    System.out.println("Object 2 data: "+ref1.show());
}
catch (NamingException e){      e.printStackTrace();    }
}
}

解决方案

Try removing WebLogic System Libraries from the Bootstrap Entries section. It worked for me when i got the same error.

这篇关于在EJB中运行客户端代码时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆