File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling EJB from standalone java program

 
Manoj Gundawar
Ranch Hand
Posts: 169
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have developed EJB in WSAD. I can call it from standalone java, only if this java project is developed under WSAD and run under same JRE. But I need to find out how to run it in different jre's (using Sun's java instead of IBM's)
I could not find much help on this one. Any suggestions? (or related links would do)
Thanks,
Manoj
 
Leandro Melo
Ranch Hand
Posts: 401
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I might be saying sutff that you already know, but... just ignore it if so.

If you can access your ejb from a java program under wsad it means that both your java client and you ejb (and server) configuration are fine.
The only reason i see for that not working on projects outside wsad (in fact, in other jvm) is that might be looking for local interfaces. You can access local interfaces only from the same jvm.
 
Brian Tinnel
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never been able to get a client program to access WebSphere without using the JVM shipped with WebSphere. I too, would be interested in learning how to do that with Sun's JVM.
 
Manoj Gundawar
Ranch Hand
Posts: 169
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leandro,
Thanks for reply.
But I didnt get what you ment by "You can access local interfaces only from the same jvm" I have put the ejb jar in the classpath of the standalone client , so that client gets all the required classes. (this jar has local interface,home interface, stub and skeleton classes)

As this was not happening (call to ejb), I created a Servlet which does exactly same process as EJB and now I call this servlet from the Standalone Java Client. But the performance is not good. I am not sure if I use the
EJB instead, performance will improve. Any idea?

Thanks,
Manoj
 
SivaKumar Kumar
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An EJB can be built with a local / remote interface

The local interface is used when you access the EJB from within the same JVM as your Application server. ie your servlet accessing the EJB. This is done for performance improvement.

The remote interface is used when you access the EJB from another JVM. ie your client accessing the EJB.

I have not used IBM's JVM but I wouldn't think there will be any difference in accessing a SUN JVM.
 
SivaKumar Kumar
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though you have put the ejb jar in the classpath it will still be a remote call to the EJB on the JVM running the Application server.

The "EJB jar" file contains the stubs you need to connect to the Application server that has the EJB's.

You may also want to check that you are able to connect to the JVM containing the EJB's. ie your JNDI entries are correct.

you need at least the following JNDI entries (this is for Weblogic)
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://<host>:<port>
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic