在EJB中运行客户端代码时出错

时间:2014-05-13 19:25:36

标签: ejb ejb-3.0 noclassdeffounderror

在EJB中运行客户端代码时出错:

  

线程中的异常"主线程" java.lang.NoClassDefFoundError:   weblogic / kernel / KernelStatus at   weblogic.jndi.Environment。(Environment.java:78)at   weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)     在   javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)     在   javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)     在javax.naming.InitialContext.init(InitialContext.java:223)at   javax.naming.InitialContext。(InitialContext.java:197)at   User.main(User.java:21)

我添加了wlfullclient.jar,服务器的远程接口jar,我也看到了文章中我添加了wlclient.jarweblogic.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");// 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 个答案:

答案 0 :(得分:2)

尝试从Bootstrap条目部分删除WebLogic System Libraries。当我遇到同样的错误时,它对我有用。