This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

How to write EJB client?  RSS feed

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greeting Ranchers,
This is my first EJB application.
I have to create a web client to the Advice EJB. The idea is to create a simple GetAdvice.jsp and a servlet. The servlet will lookup the advice bean and display the advice. To achieve this I created a j2ee project and added the Advice EJB. Now I created another dynamic web project with the servlet and jsp. In the deployment descriptor I added the ejb-ref name and type as the lookup name and jndi name respectively.
In the service method I'm looking up the enterprise bean.

Context ic = new InitialContext();
Object o = ic.lookup("ejb/Advice");
Advice ad = (Advice) PortableRemoteObject.narrow(o,Advice.class);

I'm using WSAD 5.1. In this way will I be able to retreive the remote bean?
[ February 28, 2007: Message edited by: Naveen Sharma ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Object o = ic.lookup("ejb/Advice");



I guess the lookup should be java:/comp/env/ejb/Advice

Give it a try and let us know if that doesnt work
 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okie, thanks... I'll try it and let you know. Btw I'm still very doubious about all this I mean, we are not making any declarative provisions at the client end expect for ebj-ref tag in the web.xml. Any client I create with the ejb package in the class path will be able to access the ejb? I read somewhere that some client.jar needs to be created. Not sure though
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Any client I create with the ejb package in the class path will be able to access the ejb?



As long as the jndi name is known to the client, any client can always lookup the bean. If however you want to restrict access to some beans to some specific roles then you can do that by securing the EJB.
 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mate... That's a confidence booster, I'll try it and let you know
 
Acetylsalicylic acid is aspirin. This could be handy too:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!