请教

03-04-30 carolingian

j2ee部署问题

环境:weblogic 7.0

简单的ejb+application结构:HelloBean,Hello,HelloHome是ejb系列,HelloClient是appl

ication.

在weblogic console中部署了该应用,成功。

jndi里查找也能找到HelloHome。

HelloClient.java代码如下:

package examples;

import javax.naming.Context;

import javax.naming.InitialContext;

import java.util.Properties;

import javax.ejb.*;

/**

* This class is an example of client code which invokes

* methods on a simple stateless session bean.

*/

public class HelloClient {

public static void main(String[] args) throws Exception {

/*

* Setup properties for JNDI initialization.

*

* These properties will be read-in from

* the command-line.

*/

Properties props = System.getProperties();

props.list(System.out);

/*

* Obtain the JNDI initial context.

*

* The initial context is a starting point for

* connecting to a JNDI tree. We choose our JNDI

* driver, the network location of the server, etc

* by passing in the environment properties.

*/

Context ctx = new InitialContext(props);

/*

* Get a reference to the home object - the

* factory for Hello EJB Objects

*/

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

/*

* Home objects are RMI-IIOP objects, and so

* they must be cast into RMI-IIOP objects

* using a special RMI-IIOP cast.

*

* See Appendix X for more details on this.

*/

HelloHome home = (HelloHome)

javax.rmi.PortableRemoteObject.narrow(

obj, HelloHome.class);

/*

* Use the factory to create the Hello EJB Object

*/

Hello hello = home.create();

/*

* Call the hello() method on the EJB object. The

* EJB object will delegate the call to the bean,

* receive the result, and return it to us.

*

* We then print the result to the screen.

*/

System.out.println(hello.hello());

/*

* Done with EJB Object, so remove it.

* The container will destroy the EJB object.

*/

hello.remove();

}

}

运行脚本如下:

java -Djava.security.policy=../java.policy -Djava.naming.factory.initial=weblog

ic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:8001

examples.HelloClient

提示总是:

Exception in thread "main" javax.naming.NoInitialContextException: Cannot insta

n

tiate class: weblogic.jndi.WLInitialContextFactory. Root exception is java.lan

g

.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Unknown Source)

at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)

at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

at javax.naming.InitialContext.init(Unknown Source)

at javax.naming.InitialContext.<init>(Unknown Source)

at examples.HelloClient.main(HelloClient.java:30)

请教这是什么问题。