• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Kyle, Tony- -ServiceUnavailableException while looking context from Remote host

 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I get the following exception when I try look up context from remote host using Websphere 4.0.The same code is working in WAS3.5. Also i am getting problems with all the EJBs while trying to Run them in WAS4, all of them were made in Visual Age 3.5 and all are giving errors.. Is there any particular way to migrate these EJBs( both CMPS and session beans)..Please help .

javax.naming.ServiceUnavailableException [Root exception is org.omg.CORBA.BAD_PARAM: minor code: 0 completed: No]
The code for looking up is as follows :
Hashtable hash=new Hashtable();
hash.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
hash.put(Context.PROVIDER_URL,"iiop://mc-name:900");
Context ctx=new InitialContext(hash);
Thanks in Advance,
Daman
[ January 23, 2002: Message edited by: daman sidhu ]
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
hash.put(Context.PROVIDER_URL,"iiop://:900"); does not seem to be right.
Try "iiop://remotehostIP:900". Also, make sure you are using the JDK from IBM. IBM has its own ORB related stuff in its JDK.
 
daman sidhu
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes , i have put the provider's ip there, but that is not solving the problem still and i am looking it up from visual age so theres no issue in jdk compatibility problem.Please advice what to do?? The same code works with Websphere 3.5 but in 4.0 i am totally lost in EJB's , GOD knows how IBM guys have implemented them.. i am upgrading my system from 3.5 to 4.0 and i am sick of 4.0 because all the EJBs are giving problems because of the compatibility issues with no proper documentation to help me..
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daman,
you are getting a kinda peculiar error. To be very frank, i haven't worked with ejbs on websphere a lot, but based on my experience with ejbs on weblogic i would advice you to following technique to narrow down the problem.
in fact you can apply this technique to any problem you may face in your life.
it is based on an ancient chinese wisdom which has made them(the chinese) a force to reckon with today. it goes by the name San-Chu, must have heard about it.(making a lot of news these days)
1. catgories your problems into three groups.
in your case it will be, lets see, ejb with 80 percent probability of errors, ejbs with 20 percent probability of error and ejbs of no probability of error!
2. next you narrow down to the ejbs with 80 percent error. give a real nice look to it. why on world is it doing this when it is not supposed to do it. scan through all the non repetitive and antipattern methods and you will discover a pattern in the errors being thrown to you.
3. look real deep these into this patterns you discover. you find the solution lying somewhere outthere.
And yes, this is an iterative process, so if at first you don't think you have reached where you had started out for, just go on repeating the steps.
do inform me when you you are done.
lisa
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by daman sidhu:

The code for looking up is as follows :
Hashtable hash=new Hashtable();
hash.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
hash.put(Context.PROVIDER_URL,"iiop://mc-name:900");
Context ctx=new InitialContext(hash);


Context.INITIAL_CONTEXT_FACTORY is changed in WAS 4.0:
Get an initial context
In general, JNDI clients should assume the correct environment is already configured so there is no need to explicitly set property values and pass them to the InitialContext constructor. However, a JNDI client may need to access a name space other than the one identified in its environment. In this event, it is necessary to explicitly set one or more properties used by the InitialContext constructor. Any property values passed in directly to the InitialContext constructor take precedence over settings of those same properties found elsewhere in the environment.
View the following examples for information on passing property values to the InitialContext constructor:

Get an initial context using JNDI properties found in the current environment:
The current environment includes the Java system properties and properties defined in properties files found in the JNDI client's CLASSPATH. See article Installing files and setting classpaths for information on defining CLASSPATHs.
...
import javax.naming.Context;
import javax.naming.InitialContext;
...
Context initialContext = new InitialContext();
...

Get an initial context by explicitly setting JNDI properties:
...
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
...
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, "iiop://myhost.mycompany.com:900");
Context initialContext = new InitialContext(env);
...

Look up a home for an EJB
The example below shows a lookup of an EJB home. The actual home lookup name is determined by the application's deployment descriptors.
// Get the initial context as shown in the previous example
...
// Look up the home interface using the JNDI name
try {
java.lang.Object ejbHome = initialContext.lookup("java:comp/env/comp/mycompany/accounting");
accountHome = (AccountHome)javax.rmi.PortableRemoteObject.narrow(
(org.omg.CORBA.Object) ejbHome, AccountHome.class);
}
catch (NamingException e) { // Error getting the home interface
...
}

Look up a JavaMail session:
The example below shows a lookup of a JavaMail resource. The actual lookup name is determined by the application's deployment descriptors.
// Get the initial context as shown above
...
Session session = (Session) initialContext.lookup("java:comp/env/mail/MailSession");
 
Tony Chen
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by lisa:

in fact you can apply this technique to any problem you may face in your life.
it is based on an ancient chinese wisdom which has made them(the chinese) a force to reckon with today. it goes by the name San-Chu, must have heard about it.(making a lot of news these days)
lisa


Thanks for your positive comments on us (the chinese)!
[ January 23, 2002: Message edited by: Tony Chen ]
 
author
Posts: 3899
10
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help me out here -- are you by chance trying to look up an EJB deployed in WAS 4.0 from a client running in VAJ 4.0?
Kyle
 
daman sidhu
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Kyle, I am trying to look up EJB's running in WAS4.0 from VAjava 3.5 on a remote machine.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daman,
I guess this could be a problem with the JDK itself.
I would suggest copy the same JDK as on the WAS 4.0 machine onto your remote machine and use this JVM to load your EJB. Am sure this will work.
Let me know about the outcome.
Regards,
honda
 
Kyle Brown
author
Posts: 3899
10
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's the problem. You can't do that. You can't look up an EJB 1.1 EJB running in WebSphere 4.0 from ANY level of VAJ (which only runs the WebSphere 3.5 client software). It won't work. You'll have to either use WSAD or do this at the command line.
Kyle
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm trying to look up an ejb from the command line (with my classpath set to use IBM's JDK - so much for write once IBM) and getting the same error, and doing the following trying to get the initial context:
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");

javax.naming.ServiceUnavailableException: NULL returned when resolving initial reference=NameService
at com.ibm.ws.naming.util.WsnInitCtxFactory.getCosRootContext(WsnInitCtxFactory.java:476)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:361)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:227)
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:135)
at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:80)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:660)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:241)
at javax.naming.InitialContext.init(InitialContext.java:217)
at javax.naming.InitialContext.<init>(InitialContext.java:193)
at DemoClient.getInitialContext(DemoClient.java:59)
at DemoClient.main(DemoClient.java:18)
 
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think IBM issues an efix/fp something for WAS3.5, so EJB client in WAS3.5 can access EJB deployed in WAS4.0. It is the IBM JDK incompatabibility issue.
WAS3.5 is at JDK1.2.2, while WAS4.0 is at 1.3.1(after fp3).
You can find something from IBM WSDD, just don't have the URL in hand.
Don't know how to patch VAJ3.5 to access WAS4.0 EJB, but from a patched WAS3.5 you should be able to do that.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

public class HelloClient
{
public static void main(String[] args)
{
try
{
Properties prop = new Properties();

prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809/");

Context ctx = new InitialContext(prop);

HelloHome home = (HelloHome) ctx.lookup("ejb/com/XXX/dev/HelloHome");

Hello hello = home.create();

System.out.println("Output of hello = [" + hello.hello() + "]");

hello.remove();
}
catch (Exception e)
{
System.out.println("HelloClient failed with Exception: " + e.getMessage() );
e.printStackTrace();
}
}
}

Also,
Please make sure you have following in your classpath for EJB2.0 client for WSAD 5.0:
1. naming.jar
2. namingclient.jar
3. namingserver.jat
4. implfactory.jar
:roll: :roll:
[ January 29, 2003: Message edited by: test ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im tried to access an EJB deployed on WebSphere 5 from Tomcat.
I put
ecutils.jar
naming.jar
namingclient.jar
namingserver.jar
ras.jar
wsexception.jar
in my WEB-INF/lib diretory
but when I try to get InitialContextFactory:
Hashtable p = new Hashtable();
p.put(Context.PROVIDER_URL, "iiop://dbadual:2809");
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
Contextctx = new InitialContext(p);
I returns a ClassNotFoundException:
java.lang.NoClassDefFoundError: javax/ejb/EJBException
But this class is in wsexception.jar
What can be wrong?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic