• 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

Calling EJB from Java client

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends:
Actually i'm working with an IBM WebSphere Application Server on
Windows NT. I already had deployed entity beans and session beans
in an EJB container. In my servlets I used them without troubles.
But when i tried to call them in a Java application (within Visual Age for Java) i got this error message :
Uncaught exception java.lang.NoClassDefFoundError: javax.naming.InitialContext
This is my application code :
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
import javax.naming.*;
class HelloClient {
public HelloClient() {
super();
}
public static void main(java.lang.String[] args) {
try {
Properties props = new Properties();
props.put(Context.PROVIDER_URL,"iiop:///");props.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
Context ctx = new InitialContext(props);
HelloHome home = (HelloHome) ctx.lookup("com/wiley/compbooks/ecommerce/Hello");
Hello hello = home.create();
System.out.println(hello.hello());
hello.remove();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Thanks for your help
Jorge
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jorge
Make sure you put all the required classes/packages in the project class path.
Thanks
Konda Balabbigari
 
Jorge Chata
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Konda:
Yes. i have been including some package (jars) in the classpath
of my application and I ive got anothers error messages. I would like to know what packages are needed for that an application
can invoke EJB from IBM WebSphere 3.5.3. successfully
Thanks for your help
Jorge
 
Konda Balabbigari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jorge
1. Your current working project. ex: DemoEjb
2. IBM EJB Tools
3. IBM Enterprise Extension Libraries
4. IBM WebSphere Test Environment
Here is my client program:
package ejb.demo;
import java.util.*;
import javax.ejb.*;
import java.rmi.*;
import javax.naming.*;

public class Test {
public static void main(String args[]) {

try {
Properties props = new Properties();
props.put(Context.PROVIDER_URL,"iiop://mac23:900");
props.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
Context ctx = new InitialContext(props);
DemoHome home = (DemoHome) ctx.lookup("ejb/demo/Demo");
Demo demo = home.create();
System.out.println(demo.hello());
demo.remove();
} catch (Exception e) {
e.printStackTrace();
}

}

}
Thanks
Konda Balabbigari
Author: www.javacaps.com
Sun Certified Programmer
IBM WebSphere Certified
[This message has been edited by Konda Balabbigari (edited September 05, 2001).]
[This message has been edited by Konda Balabbigari (edited September 05, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic