File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes problem while creating InitialContext ..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem while creating InitialContext ....." Watch "problem while creating InitialContext ....." New topic
Author

problem while creating InitialContext .....

sathish kannan
Greenhorn

Joined: Jul 11, 2002
Posts: 29
hi guys
i am trying to create InitialContext Object using the code:
Hashtable env = new Hashtable();
InitialContext ic = null;
try
{
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://172.25.150.65:7001");
ic = new InitialContext(env);
}
catch(Exception e){}
and trying to lookup a bean and i am running WebLogic Server.This i am running from a client application,a Java program.
while i am running this application, it is giving the error as :
java.io.StreamCorruptedException: Type code out of range, is 0
at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1280)
at java.io.ObjectInputStream.SkipToEndOfBlockData(ObjectInputStream.java
:1211)
at java.io.ObjectInputStream.inputClassDescriptor (ObjectInputStream.java
:776)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:353)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:978)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
at weblogic.common.internal. ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:110)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
bjectInputStream.java:123)
at weblogic.rjvm.ConnectionManager.readPeerInfo (ConnectionManager.java:6
83)
at weblogic.rjvm.ConnectionManagerClient.handleIdentifyResponse(Connecti
onManagerClient.java:140)
at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:624)
at weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java, Compi
led Code)
at weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java,
Compiled Code)
at weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java,
Compiled Code)
at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:
24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
--------------- nested within: ------------------
weblogic.utils.AssertionError: ***** ASSERTION FAILED ***** - with nested except
ion:
[java.io.StreamCorruptedException: Type code out of range, is 0]
at weblogic.rjvm.ConnectionManager.readPeerInfo(ConnectionManager.java:6
85)
at weblogic.rjvm.ConnectionManagerClient. handleIdentifyResponse( Connecti
onManagerClient.java:140)
at weblogic.rjvm.ConnectionManager. dispatch(ConnectionManager.java:624)
at weblogic.rjvm.t3.T3JVMConnection. dispatch(T3JVMConnection.java, Compi
led Code)
at weblogic.socket.JavaSocketMuxer. processSockets2(JavaSocketMuxer.java,
Compiled Code)
at weblogic.socket.JavaSocketMuxer. processSockets(JavaSocketMuxer.java,
Compiled Code)
at weblogic.socket.SocketReaderRequest. execute(SocketReaderRequest.java:
24)
at weblogic.kernel.ExecuteThread. execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread. run(ExecuteThread.java, Compiled Code)
exp :
[Root exception is java.net.ConnectException: t3://172.25.150.65:7001: Bootstrap
to: 'SG0121SATHISH.snshub.org/172.25.150.65:7001' over: 't3' got an error or ti
med out]javax.naming. CommunicationException
at weblogic.jndi.internal. ExceptionTranslator. toNamingException(Exceptio
nTranslator.java:46)
at weblogic.jndi. WLInitialContextFactoryDelegate. toNamingException(WLIni
tialContextFactoryDelegate.java:568)
at weblogic.jndi. WLInitialContextFactoryDelegate. getInitialContext(WLIni
tialContextFactoryDelegate.java, Compiled Code)
at weblogic.jndi. WLInitialContextFactoryDelegate. getInitialContext(WLIni
tialContextFactoryDelegate.java:211)
at weblogic.jndi. WLInitialContextFactory. getInitialContext(WLInitialCont
extFactory.java:149)
at javax.naming.spi. NamingManager.getInitialContext(NamingManager. java:7
71)
at javax.naming. InitialContext.getDefaultInitCtx ( InitialContext.java:169
)
at javax.naming. InitialContext.<init>(InitialContext.java:146)
at com.sns.trade.eco.co.util. ReadXMLForCOApplication. getInitialContext(R
eadXMLForCOApplication.java:478)
at com.sns.trade.eco.co.util. ReadXMLForCOApplication. createCOSLandCodeSL
Bean(ReadXMLForCOApplication.java:437)
at com.sns.trade.eco.co.util. ReadXMLForCOApplication. endTransaction(Read
XMLForCOApplication.java:417)
at com.sns.trade.eco.co.util. ReadXMLForCOApplication. main(ReadXMLForCOAp
plication.java:499)"
Can u please explain why this error is occuring and it is at the line of creating the InitialContext. ie.,
ic = new InitialContext(env);
thanks in advance
sathish
Jonathan Roberts
Greenhorn

Joined: Aug 23, 2002
Posts: 4
Try
DirContext
instead of initial context
and thus
myContext = new InitialDirContext(env);
Also
dont you need
catch (NamingException e)
{
mstrLastErrorStr = e.toString();
System.out.printlnmstrLastErrorStr);
}
sathish kannan
Greenhorn

Joined: Jul 11, 2002
Posts: 29
ya i got the problem solved
actually the problem i used different version of java while compiling and running the java
anyway thanks a lot
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem while creating InitialContext .....