jersey

How to get the remote IP in a ContainerRequestFilter

ぐ巨炮叔叔 提交于 2019-12-11 02:46:59
问题 I have this class and wants to log the rest-requests: public class RequestFilter implements ContainerRequestFilter { private static final Logger LOG = LoggerFactory.getLogger(RequestFilter.class); @Override public void filter(ContainerRequestContext requestContext) throws IOException { LOG.info("REST-Request from '{}' for '{}'", "XXX", requestContext.getUriInfo().getPath()); // ... and do some auth stuff (not relevant for this question) } } How do do I get the remote IP of the request? TIA!

Java JPA FetchType.EAGER does not work

我是研究僧i 提交于 2019-12-11 02:25:57
问题 I'm making an application in Java EE (Jersey) with JPA where I have a problem with the uninitialized entities. I have 3 entities Car, Owner, House where the car can have multiple owners and owners can have multiple houses. When i return (entityManager.find) Car then owner is initialized. When i return House then Owner is initialized, but Car is not. I would like to be able to call something like House.getOwner().getCar().getId(). Now I must call find on House and then call find on Owner to

Using Single Jersey REST class for multiple PATH

前提是你 提交于 2019-12-11 02:22:49
问题 I have started developing REST services using JAX-RS. Using Jersey is pretty straightforward however one difference which I come across using Spring MVC and Jersey REST classes is, Spring supports having to ignore the Root Path element and have individual path mappings at Method Level. So if there is a Upload / Download Functionality, I may not want to have 2 classes one with upload and one with download which Jersey asks me to do now because there could be only 1 Root Path at class level

NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getOsgiRegistryInstance()Lcom/sun/jersey/core/osgi/OsgiRegistry;

陌路散爱 提交于 2019-12-11 02:17:26
问题 It seems I have a dependency conflict that I'm unsure how to resolve. I'm attempting to implement Swagger into my application. I've included my pom as well as the stack trace. If I can include anything else to better describe the problem, please let me know. I'm unsure how to begin debugging this... Exception in thread "main" java.lang.NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getOsgiRegistryInstance()Lcom/sun/jersey/core/osgi/OsgiRegistry; at com.sun.jersey.spi

How to integrate Swagger no config setup with Jersey 2

核能气质少年 提交于 2019-12-11 02:04:33
问题 I'm trying to do a barebones Swagger setup with a Jersey 2 project hosted on Tomcat 8.5. I first generated the jersey project with the following snippet from the Jersey getting started guide (https://jersey.github.io/documentation/latest/getting-started.html): mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=com.example -DartifactId=simple-service-webapp -Dpackage=com.example \

Passing Two Objects in Rest Api using Jersey

回眸只為那壹抹淺笑 提交于 2019-12-11 02:01:34
问题 I have written a Restful web service API, which is accepting two different Object, Is it possible to call this api using Jersey client. I am not able to call this using Jersey client. Is this a limitation of Rest API that we can not pass multiple objects to a method. import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @Path("/hello") public class TimePassService { @POST @Path("/post") @Consumes

What is a ContextResolver and Provider in Jersey?

夙愿已清 提交于 2019-12-11 01:54:27
问题 What is a ContextResolver in Jersey and what is a Provider ? What is the difference between the two? I am using Genson with Jersey. Genson is auto-registered when Jersey finds the Genson JAR on the classpath. The Genson JAR's WEB-INF/services directory contains a file called "org.glassfish.jersey.internal.spi.AutoDiscoverable". Following that AutoDiscoverable path, by default Genson/Jersey auto-registers a the following class: @Provider @Consumes({MediaType.APPLICATION_JSON, "text/json",

How can I disable annoying warning/hint in NetBeans 8.1

那年仲夏 提交于 2019-12-11 01:27:36
问题 I am working with Java and Jersey in NetBeans and all my endpoints are flagged with the following hint: "Convert Method To Asynchronous" This hint really pollutes the right-hand gutter where I usually look for code changes/errors. There is nothing in preferences -> editor -> hints that seems to affect this hint. Cheers 回答1: You can use the @SupressWarning annotation, or, by hovering the mouse-pointer over the warning, there are options to disable for instance (auto-generates @SupressWarning )

HTTP Status 405 - Method Not Allowed Error on Invoking a DELETE method using WebServices

允我心安 提交于 2019-12-11 00:52:23
问题 I am trying to delete a "Contact" from the "Contacts" table using the following @DELETE method (using Jersey Framework (JAX-RS implementation) @DELETE @Path("/delete/{contact}") public String deleteContact(@PathParam("contact") String name) throws ClassNotFoundException, SQLException { String response = DAOaccess.deleteContact(name); return response; } And the following url is used to invoke the webservice from the browser: /contacts/delete/contactname But HTTP Status 405 - Method Not Allowed

Getting 404 trying to render a JSP from Jersey 2

孤街醉人 提交于 2019-12-11 00:42:29
问题 I'm trying to make a simple example of a web application using Jersey 2 and JSP, and to deploy it on Glassfish 4. However, I keep getting 404 errors trying to access my only resource. First, the project structure: Here are the important classes and files: web.xml I'm setting Jersey as a filter, instead of a servlet, because I read it needs to be defined that way in order to make it work with JSP. <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org