• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Accessing remote EJBs

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the following error in accessing a remote EJB.
com.ibm.rmi.iiop.CDRInputStream$1
When I deploy the same EJB in my machine and give the provider URL
as iiop://localhost:900/ I am able to access the bean.
Any pointers?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be because of two reasons - ujc.jar is not included in the classpath of the system and secondly the jdk being used must be IBM's jdk (NOT SUN's).
It should work alright now.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have included ujc.jar in my classpath and I am using IBM's jdk too..but still i am getting the error
java.lang.ClassCastException: com.ibm.rmi.iiop.CDRInputStream$1
My client code is as follows
.............
try {
System.out.println("1");
Properties properties = new Properties();
System.out.println("2");
properties.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:900");
properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
System.out.println("3");
System.out.println(properties.get(javax.naming.Context.PROVIDER_URL));
System.out.println(properties.get(javax.naming.Context.INITIAL_CONTEXT_FACTORY));
Context ctx = new InitialContext(properties);
System.out.println("4");

TestEnvHome home = (TestEnvHome)ctx.lookup("TestEnvHome") ;
System.out.println("5");
if (home == null)
{
System.out.println("no Home");
}
else
{
System.out.println("Got Home");
}
System.out.println("6");
TestEnv test = home.create();
................
The output I get is
1
2
3
iiop://localhost:900
com.ibm.ejs.ns.jndi.CNInitialContextFactory
4
generalExceptionjava.lang.ClassCastException: com.ibm.rmi.iiop.CDRInputStream$1
Any pointers?
[This message has been edited by Jansi (edited June 25, 2001).]
[This message has been edited by Jansi (edited June 25, 2001).]
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Krithika,
If your AS and Client are on different machines, the Provider URL has to point to your AS machine.In other words localhost in the IIOP URL (iiop://localhost:900) must be replaced by the name of the machine.I am assuming that 900 is the default port number of that machine.If not, you need to change that too.
Hope this helps,
Sandeep
 
PN Subramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try doing these things
- Classpath settings :
ujc.jar;ejs.jar;Deployed<beanName>.jar
- lookup method returns an Object object - i.e it needs to be narrowed to the Home object using PortableRemoteObject method
- The PROVIDER_URL can be localhost only if the AS and client are in the same physical system - always better giving the IP address of the server.

Hope this solves your problem.Do respond if you have any further problems.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.ClassCastException
at com.ibm.ejs.ns.jndi.CNContextImpl.isContextLocalCheck(CNContextImpl.java:1252)
at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:746)
at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:584)
at javax.naming.InitialContext.lookup(InitialContext.java:349)
at Test.main(Test.java:23)
Thats the exception I get at lookup(). I am using localhost:900 since the server is on the same machine. I am also pretty sure the bean is deployed as I can see it in the Admin Console. Funny thing is if I do a lookup for an un-deployed bean, it gives me NameNotFoundException, which is good. So, I think its finding the bean, but having some problems in between. Any body have any suggestions? Also, I had to add couple of other jar files to runtime classpath besides ejs and ujc, like iioprt.jar and rmiorb.jar.... thnx in advance
 
Krithika Venugopal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulu Khan,
Please check if your run time classpath includes the client EJB jar or deployed jar file name.
Regards,
Krithika
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, even i am getting the same class cast exception
java.lang.ClassCastException
at com.ibm.ejs.ns.jndi.CNContextImpl.isContextLocalCheck(CNContextImpl.java:1252)
at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:746)
at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:584)
at javax.naming.InitialContext.lookup(InitialContext.java:349)
at Test.main(Test.java:23)
and all the ejb jar's are in m system's classpath. i tried to run my client using both sun and ibm's JDK's but it didnt work and i tried with both
objHubHome = (Chi3_EJBHome)ic.lookup("bgc/system/chi3proxy/Chi3_EJB");
and using narrow
objHubHome = (Chi3_EJBHome)javax.rmi.PortableRemoteObject.narrow((org.omg.CORBA.Object)Obj,Chi3_EJBHome.class);
TIA
Amol.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!