I am using Java EE 6, this is the first time using jax-rs and I have this resource class but I do not have any idea why my session is not retrieved when accessing the service. Login works fine and principal can be retrieved in other parts of the application.
@Path("/countries")
@Stateless
public class CountryResource {
@Resource
SessionContext ctx;
@EJB
private CityBean cityBean;
@Path("/countryid/{countryid}")
@GET
@Produces("application/xml")
public String getCountryByPk(@PathParam("countryid") Long tlCountryId){
if(ctx != null){
System.out.println(ctx.getCallerPrincipal());
}
String country;
...
return country;
}
This output to anonymous though I have logged in successfully. Before I tried using SessionContext I was trying to make the @RolesAllowed work but did not progress too. I also have the JaxRsActivator class. Anything I need to know about jax-rs pertaining to sessions?
@ApplicationPath("/rest")
public class JaxRsActivator extends Application {
}