关于jboss应用applet中调用ejb的问题。

06-02-12 fxwolf

有那位朋友做过applet中成功调用ejb的代码吗?

我在applet中调用session bean的时候系统报 classformaterror 错误。

那位高人那给我指点一下吗?

applet 部分代码为:

Properties prop = new Properties();

prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,

"org.jnp.interfaces.NamingContextFactory");

prop.setProperty(Context.PROVIDER_URL, getCodeBase().getHost());

try {

home = (testHome) PortableRemoteObject.narrow(

new InitialContext(prop).lookup("ejb/testBean"),

testHome.class);//this row report error.

bean = home.create();

} catch (NamingException e) {

e.printStackTrace();

} catch (ClassCastException e) {

e.printStackTrace();

} catch (RemoteException e) {

e.printStackTrace();

} catch (CreateException e) {

e.printStackTrace();

}

错误提示:

java.lang.ClassFormatError: Truncated class file

at java.lang.ClassLoader.defineClass1(Native Method)

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

at java.security.SecureClassLoader.defineClass(Unknown Source)

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

at java.net.URLClassLoader.access$100(Unknown Source)

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 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 sun.rmi.server.LoaderHandler.loadClass(Unknown Source)

at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)

at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)

at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)

at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)

at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)

at java.io.ObjectInputStream.readClassDesc(Unknown Source)

at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

at java.io.ObjectInputStream.readObject0(Unknown Source)

at java.io.ObjectInputStream.defaultReadFields(Unknown Source)

at java.io.ObjectInputStream.readSerialData(Unknown Source)

at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

at java.io.ObjectInputStream.readObject0(Unknown Source)

at java.io.ObjectInputStream.readObject(Unknown Source)

at java.rmi.MarshalledObject.get(Unknown Source)

at

org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)

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

at finance.gcontroller.LogonApplet.getDBEJBean(Unknown Source)

at finance.gcontroller.LogonApplet.init(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

我不知道出现这个错误的原因是代码不对还是配置文件或jar包不对。

at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)

错误提示中的这行好像包包含在rt.jar包中,而applet 属性中archive 参数并没有包含这个包。

希望高人指点。

谢谢。

fxwolf
2006-02-13 08:41

请问有没有朋友能帮我一下啊?谢谢。