Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling EJB from normal java program

 
Yog Ananth
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Yog Ananth
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic