wood burning stoves 2.0*
The moose likes Websphere and the fly likes ServiceUnavailable Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "ServiceUnavailable Exception" Watch "ServiceUnavailable Exception" New topic
Author

ServiceUnavailable Exception

Jay S
Greenhorn

Joined: Jan 09, 2001
Posts: 13
Hi all,
I am trying to run this sample code from ibm website as i just started using websphere appserver single server edition. i am getting the following exception when i run this code..can someone help me trace the problem. how do i make sure my port no is correct i know my admin is running on 900. please help
D:\misc_Code>java jndiDir / localhost 900
InitialContext(): javax.naming.ServiceUnavailableException: NULL returned when r
esolving initial reference=NameService
[Names]
Exception in thread "P=697968:O=0:CT" java.lang.NullPointerException
at jndiDir.main(jndiDir.java:79)
thanks
Jay
the following code is for jndiDir.java
/*
(c) Copyright IBM Corp. 2001 All rights reserved.
This sample program is owned by International Business Machines Corporation or
one of its subsidiaries ("IBM") and is copyrighted and licensed, not sold.
You may copy, modify, and distribute this sample program in any form without
payment to IBM, for any purpose including developing, using, marketing or
distributing programs that include or are derivative works of the sample program.
The sample program is provided to you on an "AS IS" basis, without warranty of
any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. Some jurisdictions do not allow for the exclusion or
limitation of implied warranties, so the above limitations or exclusions may not
apply to you. IBM shall not be liable for any damages you suffer as a result of using,
modifying or distributing the sample program or its derivatives.
Each copy of any portion of this sample program or any derivative work, must
include the above copyright notice and disclaimer of warranty.
*/
/*
This is a very simple JNDI directory program. It connects to the defined JNDI directory service, and
returns a list and a list of bindings served by that directory.
Usage: jndiDir <searchTerm> {<jndiHost>|localhost} {<jndiPort>|900}
To see the entire tree, use "/" as a search term. In a WebSphere environment, the Administrative Server
must be running in order to have the naming service running.
*/
//import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.Properties;
public class jndiDir
{
public static void main(String[] args)
{
String searchTerm = "/";
String hostName = "localhost";
String portName = "900";
InitialContext ctx = null;
if (args.length == 0)
{
System.out.println("java jndiDir <searchTerm> {<hostName>|localhost} {<hostPort>|900}");
return;
}
if (args.length > 0)
searchTerm = args[0];
if (args.length > 1)
hostName = args[1];
if (args.length > 2)
portName = args[2];
try
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");
p.put(Context.PROVIDER_URL, "iiop://" + hostName + ":" + portName);
ctx = new InitialContext(p);
}
catch (NamingException ne)
{
System.err.println("InitialContext(): " + ne.toString());
}
try
{
System.out.println("\n[Names]");
NamingEnumeration names = ctx.list(searchTerm);
while (names.hasMore())
{
NameClassPair fred = (NameClassPair) names.next();
System.out.println(fred.toString() + "\n");
}
}
catch (NamingException ne)
{
System.err.println("in list(): " + ne.toString());
}
try
{
System.out.println("\n[Bindings]");
NamingEnumeration bindings = ctx.listBindings(searchTerm);
while (bindings.hasMore())
{
NameClassPair barney = (NameClassPair) bindings.next();
System.out.println(barney.toString() + "\n");
}
}
catch (NamingException ne)
{
System.err.println("listBindings(): " + ne.toString());
}
}
}
richs
Greenhorn

Joined: Jul 16, 2002
Posts: 2
i'm seeing this same problem.
any resolution to this? i'm trying my own java client which MUST run outside of the websphere app developer app in a test harness, but can't get the initial context. man weblogic, jboss, everything was a walk in the park compared to this beast for doing simple stuff.
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
// "com.ibm.ejbs.ns.jndi.CNInitialContextFactory");
p.put(Context.PROVIDER_URL, "iiop://localhost:900");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServiceUnavailable Exception
 
Similar Threads
JNDI Lookup help in websphere 4.0
Problem in JNDI look up in ejb 3.0
cannot find my entity bean
JMS Temporary Topic/Queue
Looking up DataSource