Search code examples
javarestjakarta-eenetbeansejb

Share an EJB application into a rest service


(Sorry for my english, that not my first language, but I will try to be the more clear possible).

I have to make an application based on Java EJB that can communicate with other projects through RMI for some services. But I also want to make some other services - that allow to proceed business functions on my entities - available through an REST interface. And there is where I am lost.

I created several projects on Netbeans :

  • exampleApp which is composed of modules :

    • exampleApp-ejb
    • exampleApp-ear
    • exampleApp-web
  • exampleAppShared (for my RMI service)

For the moment, my services look like :

@Stateless
public class ServicesClient implements ServicesClientLocal {

@EJB
private GestionClientLocal gestionClient;

//code refering to business functions
}

My RMI part functions well. But I don't know how to make my services available through an REST services. Should I create another project ?

Maybe I did search badly but I didn't find some answers here or on internet about this case...

Thanks in advance for who will take some time to answer to my (idiot) question...


Solution

  • Finally I found !

    I just need to create with netbeans the REST webservice :

    • right click on the package you want to create your webservice
    • new
    • RestFul webservices from patterns

    Just click the first screen and then choose the name of the webservice. Then you can do a call of an enterprise bean.