Two Laptop Bag*
The moose likes EJB and other Java EE Technologies and the fly likes calling EJB from normal java program 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 » Java » EJB and other Java EE Technologies
Bookmark "calling EJB from normal java program" Watch "calling EJB from normal java program" New topic

calling EJB from normal java program

Yog Ananth

Joined: Dec 28, 2004
Posts: 27
I am calling ejb through my java program i am getting following error,help me for solving this. I imported all the jars i given jndi name correctly, i am trying this through IBM wsad.

My JNDI name ejb/example/SampleHome

i am getting error for this line

Object ref = ctx.lookup("ejb/example/SampleHome");

javax.naming.NamingException: The JNDI operation "lookup"on the context "localhost/nodes/localhost/servers/server1" with the name "ejb/example/SampleHome" failed. Please get the root cause Throwable contained in this NamingException for more information. Root exception is java.lang.NoClassDefFoundError: com/ibm/ejs/jts/jts/CurrentFactory
Frank Ertl
Ranch Hand

Joined: Apr 25, 2005
Posts: 59
This looks like your classpath is not setup correctly. Try to include the jar where the missing class "com/ibm/ejs/jts/jts/CurrentFactory" is located in the classpath.
Yog Ananth

Joined: Dec 28, 2004
Posts: 27
Please clarify my doubt is it possible to call an ejb from normal java program, i am using simple java program in main i am calling ejb, i am having ejb references.
clive jordan
Ranch Hand

Joined: Apr 27, 2005
Posts: 39

Yes, you can call EJBs from a plain and simple java program, whether is is on the same machine, or a different one.
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Well, it's possible to call EJB's from Java program, that's true, but whether or not the resulting program is "normal" is a different story... In order to use an EJB client you have to have a fairly large number of WebSphere JAR files on your classpath. Go to the WebSphere InfoCenter and look for "thin client" to find out more about this -- or alternatively go search the posts in the WebSphere Section on what JAR files you need to invoke an EJB -- it's a common question...


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Yog Ananth

Joined: Dec 28, 2004
Posts: 27

Thank for your helpful tips , in client i am using the same machine, i am trying to connect EJB also in the same machine. I am able to call from servlet to EJB but i am unable to do in normal java program.
david lightman
Ranch Hand

Joined: Nov 03, 2004
Posts: 82
I am trying to do the exact same thing Using WSAD 5.1 on my wintel thinkpad. I created a simple stateless session bean with remote and local interfaces. I am able to use the UTC to test the SLSB perfectly, but trying to create a normal java prgram to call it is proving to be very tough, even though posts indicate this should not be. Are you using the Sun JRE to run your client against the WSAD (IBM jre)?
I agree. Here's the link:
subject: calling EJB from normal java program
Similar Threads
In which jar the CurrentFactory is found?
Geting exeption in JNDI
EJB application runs as WebSphere Application client, fails as JavaApplication
java.lang. NoClassDefFoundError: com/ibm/ejs/ jts/ jts/CurrentFactory
remote ejb client with websphere