You need to make the bean a managed resource so that it has the right to inject. At a minimal level, add @RequestScopedto the JAX-RS SIB to make it suitable for injection.
Another alternative annotation is @ManagedBean. The fact is that Jersey will not address the desired goal of the injection if the parent bean is not in a controlled context
import javax.enterprise.context.RequestScoped
@RequestScoped
@Path("room")
public class RoomService {
@Inject
GameController gc;
public RoomService() {}
@Path("create")
@GET
@Produces("application/json")
public String create() {
Room r = new Room();
gc.addRoom(r);
return r.toJson();
}
}
EDIT: beans.xml WEB-INF. beans.xml :
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
EDIT: JIRA @RequestScoped @ManagedBean