From: Noushad A. <nou...@gm...> - 2016-02-29 13:29:46
|
I have created a standalone application using NettyJaxrsServer. In one scenario I want to get the IP of the request coming to the server. How do to do that.? I have the pom here with dependency <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-netty</artifactId> <version>3.0.10.Final</version></dependency> I have created the NettyJaxrsServer using the following code. public void createServer() { server = new NettyJaxrsServer(); server.setDeployment(getDeployment()); server.setPort(configuration.getPort()); server.setSecurityDomain(null); server.setRootResourcePath(configuration.getResourceRootPath()); } public ResteasyDeployment getDeployment() { final ResteasyDeployment dp = new ResteasyDeployment(); final Collection<Object> controllers = new ArrayList<Object>(); controllers.add(ctx.getBean(TestIP.class)); dp.getResources().addAll(controllers); return dp;} and my webservice class @Path("/test")@Componentpublic class TestIP { @GET @Path("/pingIp") @Produces(MediaType.APPLICATION_JSON) public String getAd( @Context HttpServletRequest servletRequest) { return servletRequest.getRemoteAddr(); } } while Encountering servletRequest.getRemoteAddr(); it throws the org.jboss.resteasy.spi.LoggableFailure Exception. Please some body healp me to find out what I am doing wrong here. Thanks in advance..! |