• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

EJB 3.1 as RESTFul webservice

 
Bartender
Posts: 1164
38
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm searching to understand the machinery needed to expose SLSB as RESTFul webservices. If I define and implement a simple EJB inside a Web Application project I just need to:

a) define Local interface and EJB implementation like in the following code:



b) define an extension of javax.rs.core.Application like the following code:



and the whole thing works: when the appserver starts (in this case, it's WebSphere, but I think that's irrelevant), the RESTFul service is exposed, and in RAD I can see a Services/REST entry in my project.

Anyway, I'd like to read your suggestions about exposing as REST services EJBs which are defined inside an EJB 3.1 project: how should I proceed ?
Of course I may define a WrapperBean, inject in it all EJBs whose method I want expose as service, but I'd like to know If there's another solution to this problem.

Thank you for your help.




 
Claude Moore
Bartender
Posts: 1164
38
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid I've written a bunch of nonsense in this post.


Searching more on the web, I found out that it's simply not possible to expose as RESTFul webservices EJBs that are deployed as EJB Project, i.e, arent'part of a WAR project.
That sound reasonable, because EJB in EJB projects are not meant to be accessed via HTTP; indeed, if you try and expose them as JAX-WS webservices, RAD creates a Dynamic
web project as requests router.

So, I think that I'll try and follow a BusinessDelegate pattern implementation, for example like this :




Hope this may help someone else looking for solving similar problems, other suggestions are wellcome (of course !)

By the way: I have again to understand how multithreading invocations are handled....
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Claude

Thanks for posting the problem and solution ;-)

Can't the EJBs are declared in EJB project, package as jar, kept in WEB-INF/lib folder as jar file and access them via HTTP as REST ? This way EJBS can also be accessible via other clients and more reusable. No ?
 
Claude Moore
Bartender
Posts: 1164
38
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you may deploy EJB within a WEB Application and all works, but for personal taste I prefer to keep things separated (EJB modules separated from WAR modules).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!