How can I inject an EJB from an other application on the same GlassFish Server?

后端 未结 3 1298
Happy的楠姐
Happy的楠姐 2021-01-01 04:29

I have two applications running on my local glassfish server. One to rent bicylces and one to buy train tickets. I now wanted to call a remote ejb from the train application

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 05:13

    You should have a FahrradService-EJB jar, and an FahrradService-client jar (names are examples, just have the two jars). Your IDE would have generated both for you if you created an EJB using Jave EE plugins/tooling.

    Your EBJ jar and the client jar will both be packaged with one of the applications. Deployment of the application will establish the EJB, so it can be referenced, looked up, injected, etc.

    Your client jar will be packaged in any other application that wants to use the EJB via @EJB or lookup.

    Assuming both applications are to be deployed to the same app-server instance, it should be just about that simple.

提交回复
热议问题