jboss3.2下部署并测试ejb不成功,请各位帮帮忙

03-10-27 chfchf
我是j2ee新手,在JBOSS里弄了个ejb,在客户端测试(服务器和客户端是一台机器),却报错,我把我做的过程下来,望高手们帮我看看是怎么回事:

1.我用的是jboss3.2版本,在classpath里加了%JBOSS_HOME%\client\jboss-j2ee.jar;%JBOSS_HOME%\client\jboss-client.jar;%JBOSS_HOME%\client\jboss-jnp.jar;

2.把打包后的jar文件Example.jar部署到%JBOSS_HOME%\server\default\deploy下面成功;

3.客户端的代码如下:

package examples;

import javax.rmi.PortableRemoteObject;

import javax.naming.*;

import java.util.Properties;

import java.util.Hashtable;

import examples.ExampleHome;

import examples.Example;

public class ExampleClient

{

public ExampleClient()

{

super();

}

public static void main(String[] args)

{

try

{

System.out.println("step1..");

Properties props =new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

props.put(Context.PROVIDER_URL,"localhost:1099");

System.out.println("step2..");

InitialContext ctx = new InitialContext(props);

System.out.println("start ejb client test");

//Example是我在jboss.xml中定义的jndi,它对应的ejb-name是Example

Object obj=ctx.lookup("Example");

ExampleHome home = (ExampleHome)PortableRemoteObject.narrow(obj,ExampleHome.class);

Example example = home.create();

System.out.println(example.example());

example.remove();

}

catch(Exception e)

{

e.printStackTrace();

}

}

}

4.运行客户端

C:\myejb\examples>java examples.ExampleClient

报错如下:

step1...

step2...

Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Log

ger

at org.jnp.interfaces.NamingContext.<clinit>(NamingContext.java:103)

at org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingConte

xtFactory.java:41)

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6

62)

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 examples.ExampleClient.main(ExampleClient.java:26)

弄了很久,没弄出来,请大家一定要帮帮我看看。.........

猜你喜欢