• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Geting exeption in JNDI

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am caling a Enity Bean through a simple java class.i developed all the code in the WSAD5.0 and deploed it in the test enviorment of the WSAD5.0 using WSA4.0 server.
when i am calling the EJB through java class i am getting the following error
javax.naming.ServiceUnavailableException: Caught exception when resolving initial reference=NameService. Root exception is org.omg.CORBA.TRANSIENT: Connection refused: connect:host=192.168.100.84,port=2809 minor code: 4942F301 completed: No
at com.ibm.CORBA.transport.TransportConnectionBase.connect(TransportConnectionBase.java:300)
at com.ibm.rmi.transport.TCPTransport.getConnection(TCPTransport.java:177)
at com.ibm.rmi.iiop.TransportManager.get(TransportManager.java:82)
at com.ibm.rmi.iiop.GIOPImpl.createRequest(GIOPImpl.java:131)
at com.ibm.rmi.iiop.GIOPImpl.createRequest(GIOPImpl.java:99)
at com.ibm.CORBA.iiop.ClientDelegate._createRequest(ClientDelegate.java:2360)
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1263)
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1167)
at com.ibm.rmi.corba.InitialNamingClient.resolve(InitialNamingClient.java:255)
at com.ibm.rmi.corba.InitialNamingClient.cachedInitialReferences(InitialNamingClient.java:333)
at com.ibm.rmi.corba.InitialNamingClient.resolve_initial_references(InitialNamingClient.java:241)
at com.ibm.rmi.corba.InitialReferenceClient.resolve_initial_references(InitialReferenceClient.java:175)
at com.ibm.rmi.corba.ORB.resolve_initial_references(ORB.java:3073)
at com.ibm.rmi.iiop.ORB.resolve_initial_references(ORB.java:527)
at com.ibm.CORBA.iiop.ORB.resolve_initial_references(ORB.java:2883)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getCosRootContext(WsnInitCtxFactory.java:437)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:363)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:229)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:98)
at com.ibm.ws.naming.util.WsnInitCtx.<init>(WsnInitCtx.java:79)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContext(WsnInitCtxFactory.java:137)
at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:80)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:255)
at javax.naming.InitialContext.init(InitialContext.java:231)
at javax.naming.InitialContext.<init>(InitialContext.java:187)
at testpack.Client.main(Client.java:31)
my client program is like this:-----------
public class Client {
public static void main(String[] args) {
try{
InitialContext ctx=new InitialContext();
Object ob=ctx.lookup("jndi");
SampleHome ahome = (SampleHome)ob;
Sample aRemote = ahome.create("1004","doot",28);
}
catch(Exception e){
e.printStackTrace();
}
}
}
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless you are running your client inside the applications server, you cannot use this code. I mean you cannot use
InitialContext ctx=new InitialContext();
Object ob=ctx.lookup("jndi");
unless this class is loaded inside the application server.
If you want to use a client that runs outside the application server you have to set up the context for the application server and only then you can use that context.
For a related discussion you can read the "JNDI Appserver problem" topic in this forum. For example, I am using JBoss and inside my test classes I use something like this:
Hashtable JNDIParm = new java.util.Hashtable();
JNDIParm.put(Context.PROVIDER_URL, "localhost");
JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
context = new InitialContext(JNDIParm);
You also have to add the class and JNDI name for the Remote interface you want to get through lookup. For example:
JNDIParm.put("org.pack1.pack2.SessionBeanRemoteHome","Session");

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rohit,
I think you should set up the initial context like:
--------
java.util.Properties props=System.getProperties();
props.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:900");
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
Context ctx=new InitialContext(props);
Object obj=ctx.lookup(" ");//put ur JNDI name inside the quotes
--------
Regards,
Anand Srinivas
 
rohit nabh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anand Srinivas:
hi rohit,
I think you should set up the initial context like:
--------
java.util.Properties props=System.getProperties();
props.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:900");
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
Context ctx=new InitialContext(props);
Object obj=ctx.lookup(" ");//put ur JNDI name inside the quotes
--------
Regards,
Anand Srinivas

 
rohit nabh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anand Srinivas:
hi rohit,
I think you should set up the initial context like:
--------
java.util.Properties props=System.getProperties();
props.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:900");
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
Context ctx=new InitialContext(props);
Object obj=ctx.lookup(" ");//put ur JNDI name inside the quotes
--------
Regards,
Anand Srinivas


hi Anand,
i have to put context factory and url only if my jndi server was on different machine.but i am testing my program on the test enviorment provided by WSAD5.0(was4.0).Means my jndi server was on same machine.
with regards,
rohit
 
Anand Srinivas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rohit,


hi Anand,
i have to put context factory and url only if my jndi server was on different machine.but i am testing my program on the test enviorment provided by WSAD5.0(was4.0).Means my jndi server was on same machine.
with regards,
rohit


I know that it is not necessary to provide those details when the JNDI server is available in the same machine.
But i encountered a similar exception in WSAD 4.0 and I then specified the context factory and url and then it worked.
So give a try and if it still doesn't works, then may be some geeks here can help
-------
Regards,
Anand Srinivas
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rohit nabh:
i have to put context factory and url only if my jndi server was on different machine.


There are other cases, too. Our dev box has two Ethernet cards and thus two IP addresses. So we cannot let it assume "t3://localhost/" (WebLogic) and expect it to guess right. Maybe there are other cases as well?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic