jersey

Jboss error: The ResourceConfig instance does not contain any root resource classes

可紊 提交于 2019-12-07 04:44:23
问题 I know this is a general question and it is already answered but those answers are not helping for this case. I am getting this error in only Jboss7.1 final release not in Tomcat(working fine with tomcat version 7) (checked with the same WAR file) com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes. com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99) com.sun.jersey.server.impl

jersey.api.client.WebResource - how to debug/log the request headers

无人久伴 提交于 2019-12-07 04:38:43
问题 I am using jersey to generate http requests and I would like to be able to see the request before it is sent (for debugging purposes). For example: WebResource resource = client.resource(url); resource.header("aa", "bb"); resource.getHeaders(); // Error: how can I do it? thanks 回答1: You can use LoggingFilter, as shown here 回答2: You need to add init-params and then implement ContainerRequestFilter Put it in your web.xml Please note that com.az.jersey.server.AuthFilter is your class that has

Jersey 2.*. Custom InjectionResolver and “A HTTP GET method … should not consume any entity”

旧城冷巷雨未停 提交于 2019-12-07 04:38:03
问题 I have followed Michal's guide from his answer to this question [1] on implementing custom annotation for injecting arbitrary things into resource methods. This (gist) [2] contains a minimalistic testbed adapted from the jersey-quickstart-grizzly2 archetype. I will refer to it in the following text. I encountered a few problems: My resolver is parametrized type (or at least it would make things much more cleaner, in my opinion) and thus I can not bind it in my binder the way Michal suggests.

how to get path param from ContainerRequestContext

主宰稳场 提交于 2019-12-07 04:37:58
问题 I want to apply authorization filter for my REST API endpoint, and the filter need path parameter to do the filtering. here is my endpoint and code: endpoint: curl --url 'localhost:80/reports/resources/org/12345/product/111 ' --request GET --header 'Authorization: <token here>' resource code: @Path("/resources") public class MyResource extends AbstractResource { ... @GET @Path("/org/{orgId}/product/{productId}") @Produces(MediaType.APPLICATION_JSON) @RoleAuthenticated public Response

Pass List to RESTful webservice

六月ゝ 毕业季﹏ 提交于 2019-12-07 04:06:58
问题 Is there a way to pass a list to RESTFul web service method in Jersey? Something like @PathParam("list") List list? 回答1: I found out that the best way to send a list via POST from the client to a REST service is by using the @FormParam . If you add a parameter twice or more times to the form, it will result into a list on the server's side. Using the @FormParam means on client side you generate a com.sun.jersey.api.representation.Form and add some form parameters like shown below. Then you

JsonMappingException: No suitable constructor found for type — for an external object

╄→尐↘猪︶ㄣ 提交于 2019-12-07 04:00:45
问题 I have an object called GeoJsonPoint from spring framework, and it can't get deserialized by jackson mapper in my integration test. Additionally, I can't add a dummy constructor because it is an external object. So I am stuck. This is my main entity; @Document(collection = "foodTrucks") @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY) public class FoodTruckEntity { @Id private ObjectId id; private String applicant; private Status status; private String[] foodItems; private Double

Setting content type/ encoding in Jersey REST Client

梦想与她 提交于 2019-12-07 03:26:38
问题 HI I have been trying to call REST POST API using jersey REST Client. The API is docs is URL: METHOD: POST Header Info:- X-GWS-APP-NAME: XYZ Accept: application/json or application/xml My Sample Jersey client code is Client client = Client.create(); WebResource resource=client.resource(URL); resource.accept(javax.ws.rs.core.MediaType.APPLICATION_XML); resource.type(javax.ws.rs.core.MediaType.APPLICATION_XML); resource.type("charset=utf-8"); ClientResponse response = resource.post

XMLAdapter for HashMap

ぐ巨炮叔叔 提交于 2019-12-07 03:14:58
问题 I want to convert a list of items inside of my payaload and convert them into a hashmap. Basically, what I have is an Item xml representation which have a list of ItemID. Each ItemID has an idType in it. However, inside my Item class, i want these ItemIDs to be represented as a Map. HashMap<ItemIDType, ItemID> The incoming payload will represent this as a list <Item>... <ItemIDs> <ItemID type="external" id="XYZ"/> <ItemID type="internal" id="20011"/> </ItemIDs> </Item> but I want an adapter

“Access-Control-Allow-Origin:*” has no influence in REST Web Service

此生再无相见时 提交于 2019-12-07 03:09:55
问题 I make an AJAX call from JavaScript client (running on machine A) to Web server (running on machine B). Client tries to access a URL exposed by RESTful Web service (Jersey), and it is blocked with error: Origin http://localhost/ is not allowed by Access-Control-Allow-Origin In server I added 2 header parameters that allow access to any client. However it didn't help: @Context private HttpServletResponse servlerResponse; @POST @Path("testme") public void test(){ servlerResponse.addHeader(

Can't Deserialize JSON in Java Servlet

拈花ヽ惹草 提交于 2019-12-07 02:49:17
问题 My endpoint can't make sense of incoming JSON. Here's the endpoint: import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.hibernate.Query; import org.hibernate.Session; import org.json.JSONObject; ... @POST @Path("/{department}/{team}")