问题描述
Oracle的javaee6CTS测试的interop测试中(EJBstatefulSessionbean相关),ObjectInputStream.readObject()时抛出ClassNotFoundException异常。该classa是存在的,且在client端有相应jar的引用。哪位高手帮忙分析一下可能的原因吧,多谢!#环境:OS:LinuxVI:WebOTX产品RI:glassfish3jdk:1.7//Errortracejava.lang.ClassNotFoundException:com.sun.ts.tests.interop.ejb.session.stateful.handletest.TestBeanatjava.net.URLClassLoader$1.run(URLClassLoader.java:366)atjava.net.URLClassLoader$1.run(URLClassLoader.java:355)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.net.URLClassLoader.findClass(URLClassLoader.java:354)atjava.lang.ClassLoader.loadClass(ClassLoader.java:425)atjava.lang.ClassLoader.loadClass(ClassLoader.java:358)atjava.lang.Class.forName0(NativeMethod)atjava.lang.Class.forName(Class.java:270)atjava.io.ObjectInputStream.resolveProxyClass(ObjectInputStream.java:697)atjava.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1558)atjava.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)atjava.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)atjava.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:370)//Client代码片段ObjectInputStreamis=null;ObjectOutputStreamos=null;try{//createEJBinstancelogMsg("CreateEJBinstance");beanRef=(TestBean)beanHome.create(props);logMsg("pingobject");intpingCount=beanRef.ping(1);logMsg("gethandleforobject");Handlehandle=beanRef.getHandle();logMsg("writeobjectoutputstreamtobytearray");ByteArrayOutputStreambaos=newByteArrayOutputStream();os=newObjectOutputStream(baos);os.writeObject(handle);logMsg("readobjectoutputstreamfrombytearray");byte[]b=baos.toByteArray();ByteArrayInputStreambais=newByteArrayInputStream(b);is=newObjectInputStream(bais);HandledeserializedHandle=(Handle)is.readObject();//throwClassNotFoundExceptionlogMsg("createobjectreferencefromdeserializedhandle");EJBObjectejbObject=deserializedHandle.getEJBObject();TestBeanbeanRef2=(TestBean)PortableRemoteObject.narrow(ejbObject,TestBean.class);booleanpass=true;if(!beanRef.isIdentical(beanRef2)){logErr("beanreferencesnotequal-unexpected");pass=false;}elselogMsg("beanreferencesequal-expected");logMsg("pingobjectviadeserializedobjectreference");intping2Count=beanRef2.ping(0);if(ping2Count!=pingCount&&pingCount!=1){logMsg("pingcount:expected"+pingCount+",received"+ping2Count);pass=false;}if(!pass)thrownewFault("test2failed");beanRef2.remove();}catch(Exceptione){thrownewFault("test2failed",e);}finally{try{logMsg("closingobjectstreams");if(is!=null)is.close();if(os!=null)os.close();}catch(Exceptione){}}