【 在 spring80 (spring) 的大作中提到: 】
: 我写了个客户端来调用发布在weblogic中的一个sessionbean,然后将这个客户端在axis中发布成服务,发布没有问题,但是我调用的时候返回了错误信息,如下:
: [faultString=java.lang.IllegalAccessException: Class org.apache.axis.providers.java.JavaProvider can not access a member of class helloworld.HelloWorldClient with modifiers ""
: 不知道是什么原因。
调试了很久,还是不行。大家看一下我发布的这个服务:
ackage helloworld;
//import ejb.learnweblogic.examples.BaseClient;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class HelloWorldClient {
public Context ctx;
public String url="t3://localhost:7001";
public HelloWorldHome home=null;
public HelloWorld hw=null;
//*************************************
public Object narrow(Object o, Class c) {
return PortableRemoteObject.narrow(o, c);
}
public Context getInitialContext()
throws NamingException
{
if (ctx == null) {
try {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, url);
ctx = new InitialContext(p);
} catch (NamingException ne) {
System.err.println("** Unable to connect to the server at:"
+url);
ne.printStackTrace();
throw ne;
}
}
return ctx;
}
//*************************************
HelloWorldClient()
throws NamingException
{
ctx = getInitialContext();
}
public void runClient()
throws Exception
{
System.out.println("begin");
try {
Object h = ctx.lookup("HelloWorldEJB");
home = (HelloWorldHome)
PortableRemoteObject.narrow(h, HelloWorldHome.class);
} catch (NamingException ne) {
System.err.println("Unable to lookup the HelloWorld EJB.");
System.err.println("Please make sure that the bean has been deployed"+
", and the client's classpath has been set correctly.");
throw ne;
}
System.out.println("1111111111111111111");
try {
hw = home.create();
System.out.println("Say Hello to EJB.");
String ejbSays = hw.helloWorld();
System.out.println("The EJB said: "+ejbSays);
} catch (Exception e) {
System.err.println("Received an unexpected exception " + e+ " while using the HelloWorldEJB.");
throw e; }
System.out.println("22222222222222222222222222");
}
public static void main(String[] argv)
throws Exception
{ HelloWorldClient hwc = new HelloWorldClient();
hwc.runClient(); }
}
我考虑了一下,是不是因为在soap服务器中,用的是reflect机制来调用的服务,但是程序中的 HelloWorldHome home ; HelloWorld hw (这两个分别是我要调用的Sessionbean的本地接口,和远程接口)是有weblogic远程发送过来的对象来赋值的,所以是却由不同的class loader加载,所以不能被访问到。
呵呵,j2ee不是很懂,表述有误请见量。希望各位高手帮忙解决一下。
下面是HelloWorldHome home ; HelloWorld hw :
package helloworld;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface HelloWorldHome extends EJBHome {
public HelloWorld create()
throws CreateException, RemoteException;
}
package helloworld;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface HelloWorld extends EJBObject {
public String helloWorld()
throws RemoteException;
}
--
FROM 202.197.125.*