Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB 3.1 as RESTFul webservice  RSS feed

 
Claude Moore
Ranch Hand
Posts: 891
8
IBM DB2 Java Netbeans IDE
  • 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
Ranch Hand
Posts: 891
8
IBM DB2 Java Netbeans IDE
  • 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....
 
Sujeeth Pakala
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
Ranch Hand
Posts: 891
8
IBM DB2 Java Netbeans IDE
  • 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).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!