JNDI - StreamCorruptedException [unexpected block data]
geoffpowdrell Nov 1, 2005 9:12 PMHi,
I have a standard java project which has Junit Test case in it. The Junit test case is setting up the JNDI environment, and then I do a lookup on my object. I have found that by including the jnp-client.jar and the jboss-common-client.jar I have eliminated a series of exceptions. I have looked at my my JNDI tree and have seen the object that I am looking up; so I don't get the NameNotFoundException, I'm passed that.
What I get is this, this is my stack trace....
javax.naming.CommunicationException [Root exception is java.io.StreamCorruptedException: unexpected block data]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:707)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(Unknown Source)
at RegisterTest.testRegister(RegisterTest.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.io.StreamCorruptedException: unexpected block data
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.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)
... 20 more
Here is my code .....
import gov.qiris.service.HelloWorld;
import java.util.Hashtable;
import java.util.Properties;
import javax.naming.InitialContext;
import junit.framework.TestCase;
public class RegisterTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();
}
public static Hashtable getDefaultJNDI() {
Properties p = new Properties();
p.setProperty(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
p.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
p.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
return p;
}
// test register functionality.
public void testRegister() {
try {
InitialContext initialContext = new InitialContext(getDefaultJNDI());
String s = HelloWorld.class.getName();
Object obj = initialContext.lookup(s);
System.out.println("success");
}
catch (Exception e) {
e.printStackTrace();
}
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
HelloWorld is a Session Bean interface and lives in a middle tier project. It is an interface to my remote Session Bean instance.
Any ideas anyone ?
thanks Geoff