• Post Reply Bookmark Topic Watch Topic
  • New Topic

Create EJB from J2SE console app

 
Stephen Hanley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I it possible to remotely call a bean method from a J2SE console App?

The two are running on the same server.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen,
You could use a J2EE application client or make remote EJB calls by looking up the initial context.
 
Stephen Hanley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Thanks for your reply.

That's the approach I had thought I would be able to take. It's obviously not as easy as it seems. The following is a snippet of the code i was trying:


ie.spraoi.jambo.stateful.MessageManagerHome.JNDI_NAME is my MessageManagerBean stateful session bean's home interface. Eclipse is underlining red and saying it cannot resolve it?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen,
Sounds like a compiler error. Check you have a jar with the EJB stubs and skeletons in your classpath.
 
Stephen Hanley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Thanks again for your help.

I was just discussing this with a colleague on the phone.

I am new to J2EE, RMI-IIOP, JNDI and the rest.

Do you mean I have to have the files in the folder 'ejbsrc' available to my console app?

Do I have to import my EJB Module (.jar) into the consoles class path or is that overkill?

(Or am I just out of my depth? :eek

Kind regards,

Stephen Hanley.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen,
You aren't out of your depth Either of those is a viable solution.

If you are just testing, either of those options is fine. I recommend putting the ejb jar in your classpath (option #2.) It's overkill, but it's also the easiest. And it is generally a good practice not to include the source where it isn't needed.

If you are actually distributing this console app to others, you will want to create a jar with just the stubs and skeletons. That way callers won't have access to all your business logic.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!