wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Problem getting InitialContext from WebLogic Server 7.0 from simple java client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problem getting InitialContext from WebLogic Server 7.0 from simple java client" Watch "Problem getting InitialContext from WebLogic Server 7.0 from simple java client" New topic
Author

Problem getting InitialContext from WebLogic Server 7.0 from simple java client

Simon Kelly
Greenhorn

Joined: Oct 02, 2002
Posts: 11
I am having problems acquiring an InitialContext from Weblogic 7.0 Server from a simple java client. The following is the stack trace of the error followed by the InitialContext code. I have set the JAVA_HOME to use the jdk provided with WebLogic and WebLogic.jar is in the classpath. Can anyone help me with this? I would be very grateful.
TRACE:
C:\beanloader\package1<java package1.TestBeanLoader
<Oct 3, 2002 11:24:16 AM MDT< <Warning< <net< <000900< <Could not open connectio
n
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
at java.net.Socket.connect(Socket.java:425)
at java.net.Socket.connect(Socket.java:375)
at java.net.Socket.<init<(Socket.java:290)
at java.net.Socket.<init<(Socket.java:146)
at weblogic.net.http.HttpClient.openServer(HttpClient.java:214)
at weblogic.net.http.HttpClient.openServer(HttpClient.java:276)
at weblogic.net.http.HttpClient.<init<(HttpClient.java:127)
at weblogic.net.http.HttpClient.New(HttpClient.java:169)
at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:11
1)
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.
java:281)
at weblogic.rjvm.http.HTTPClientJVMConnection.connect(HTTPClientJVMConne
ction.java:218)
at weblogic.rjvm.http.HTTPClientJVMConnection.createConnection(HTTPClien
tJVMConnection.java:114)
at weblogic.rjvm.Protocol.createConnection(Protocol.java:234)
at weblogic.rjvm.ConnectionManager.findOrCreateConnection(ConnectionMana
ger.java:1269)
at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:418)
at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:300)
at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java
:233)
at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:190)
at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:196
)
at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:162)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:262)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
tialContextFactoryDelegate.java:323)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
tialContextFactoryDelegate.java:221)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialCont
extFactory.java:149)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
62)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init<(InitialContext.java:195)
at package1.TestBeanLoader.init(TestBeanLoader.java:113)
at package1.TestBeanLoader.runTest(TestBeanLoader.java:42)
at package1.TestBeanLoader.main(TestBeanLoader.java:136)
<
NamingException caught : null
javax.naming.CommunicationException. Root exception is java.net.ConnectExceptio
n: http://localhost:7001: Destination unreachable; nested exception is:
java.net.ConnectException: Tried all: '1' addresses, but could not conne
ct over HTTP to server: 'localhost', port: '7001'; No available router to destin
ation
at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:173)
at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:262)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
tialContextFactoryDelegate.java:323)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
tialContextFactoryDelegate.java:221)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialCont
extFactory.java:149)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
62)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init<(InitialContext.java:195)
at package1.TestBeanLoader.init(TestBeanLoader.java:113)
at package1.TestBeanLoader.runTest(TestBeanLoader.java:42)
at package1.TestBeanLoader.main(TestBeanLoader.java:136)
Failed on InitialContext
Exception during execution
java.lang.NullPointerException
at package1.TestBeanLoader.runTest(TestBeanLoader.java:56)
at package1.TestBeanLoader.main(TestBeanLoader.java:136)
CODE:
Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");

env.put(Context.PROVIDER_URL,
//"t3://localhost:7001"); -- same error
"http://localhost:7001");
env.put(Context.SECURITY_PRINCIPAL,"xyz");
env.put(Context.SECURITY_CREDENTIALS,"xyz");
ctx = new InitialContext(env);
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
What port is your server running on? Should say in the logs when the server starts. Like this:

<Oct 3, 2002 1:31:12 PM MDT> <Notice> <WebLogicServer> <000354> <Thread "ListenThread.Default" listening on port 7001>
Make sure it is 7001 or you change the port number in the InitialContext properties.
I assume the server is running on the same machine where your client is running, otherwise you'd need to replace "localhost" with the hostname or IP address of the server.
Try 127.0.0.1 rather than localhost? Nah.
Make sure the server is up. Logs should have something like:
<Oct 3, 2002 1:31:12 PM MDT> <Notice> <WebLogicServer> <000365> <Server state changed to RUNNING>
<Oct 3, 2002 1:31:12 PM MDT> <Notice> <WebLogicServer> <000360> <Server started in RUNNING mode>
Until you see that, it's not listening for connections.
Simon Kelly
Greenhorn

Joined: Oct 02, 2002
Posts: 11
Thanks for the response Dave. Unfortunately I still can't figure out the problem. Everything you mentioned checks out ok! The only thing I can think of is a jar from the weblogic library might be missing from the classpath. I have only so far included weblogic.jar. Do you know of any others that might be required.
Regards,
Simon Kelly.
Originally posted by Dave Landers:
What port is your server running on? Should say in the logs when the server starts. Like this:

<Oct 3, 2002 1:31:12 PM MDT> <Notice> <WebLogicServer> <000354> <Thread "ListenThread.Default" listening on port 7001>
Make sure it is 7001 or you change the port number in the InitialContext properties.
I assume the server is running on the same machine where your client is running, otherwise you'd need to replace "localhost" with the hostname or IP address of the server.
Try 127.0.0.1 rather than localhost? Nah.
Make sure the server is up. Logs should have something like:
<Oct 3, 2002 1:31:12 PM MDT> <Notice> <WebLogicServer> <000365> <Server state changed to RUNNING>
<Oct 3, 2002 1:31:12 PM MDT> <Notice> <WebLogicServer> <000360> <Server started in RUNNING mode>
Until you see that, it's not listening for connections.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16160
    
  21

Got any firewalls between client and server?


Customer surveys are for companies who didn't pay proper attention to begin with.
Simon Kelly
Greenhorn

Joined: Oct 02, 2002
Posts: 11
Same machine thanks Tim!
Originally posted by Tim Holloway:
Got any firewalls between client and server?
Eric Ma
Greenhorn

Joined: Nov 21, 2001
Posts: 16
When you created the domain using the domain wizard, it asked you to specify a server listen address. Did you leave it blank? If yes, you can use t3://localhost:7001; otherwise you have to use the exact name of the address you typed in.
Simon Kelly
Greenhorn

Joined: Oct 02, 2002
Posts: 11
Thanks, that seems to have solved it!
Originally posted by Eric Ma:
When you created the domain using the domain wizard, it asked you to specify a server listen address. Did you leave it blank? If yes, you can use t3://localhost:7001; otherwise you have to use the exact name of the address you typed in.
 
Consider Paul's rocket mass heater.
 
subject: Problem getting InitialContext from WebLogic Server 7.0 from simple java client