0

I have EJB module that I want to make RESTFULL api.

I do not have any war files. Only EJB.jar file which has been deployed on glassfish server.

Following is my SessionBean class.

@Stateless
@LocalBean
public class TestSessionBean {

@GET
@Path("/test")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getObjects(@QueryParam("city") String city) {
    try {

        JSONObject jSONObject = new JSONObject();

        jSONObject.put(city, "test");

        return jSONObject;
    } catch (JSONException e) {
        e.printStackTrace();
        return null;
    }
}
}

My ejb module name as TestEJB. I am using JEE6. I tried to get resource from googling. but did not get any idea. I went Inject a EJB into JAX-RS (RESTfull service) and so on. But could not get any usefull resources.

Note: I heard from one of my friend that it is possible in EJB3 so I tried to do.

I do not know is it possible or not please kindly guide me.

Community
  • 1
  • 1
Yubaraj
  • 3,800
  • 7
  • 39
  • 57

1 Answers1

0

Well, specification says only that "A JAX-RS application is packaged as a Web application in a .war file. ", and nothing (or at least I cannot find) about using it in standalone ejb module.

  • Actually I heard in ejb3 it is possible so I tried to do and posted question here. – Yubaraj Jul 16 '14 at 03:52
  • Although it is possible to implement stateless of singleton EJBs as JAX-RS classes, but as @Guest noted you'll have to [package bean in war](http://java.boot.by/ocewsd6-guide/ch04.html). – Arunas Junevicius Jul 18 '14 at 08:51