Error while running client code in EJB

吃可爱长大的小学妹 提交于 2019-12-11 18:53:52

问题


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();    }
}
}

回答1:


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



来源:https://stackoverflow.com/questions/23639876/error-while-running-client-code-in-ejb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!