jax-rs

Class not found when using JAX-RS with Eclipse and Glassfish

拟墨画扇 提交于 2019-12-19 07:48:29
问题 I am using Eclipse Luna (versions 4.4.2) and Glassfish 4 to build a REST web-app using JAX-RS. The following piece of code, which is just a very simple post to the REST api that was previously working just fine, has started throw a very strange error: @POST public Response addToWatchlist(WatchlistEntry watchlistentry) { return Response.ok(watchlist_service.addToWatchlist(watchlistentry).toString()).build(); } The error is below: Warning: StandardWrapperValve[Jersey Web Application]: Servlet

Is it okay to use same resource name for both get and post rest api

江枫思渺然 提交于 2019-12-19 05:35:16
问题 Sometime back I developed a Restful service in Java with only 1 GET resource. It was accessed like this: GET http://localhost:8080/my-project/customers/transactions This GET request returns all the customer transactions. Now, I have another project request where they want to insert customer transactions in a different schema in same database. I thought instead of creating other service I could enhance this service since underlying database is same and it's about customer transactions. So, I

Is it okay to use same resource name for both get and post rest api

核能气质少年 提交于 2019-12-19 05:35:10
问题 Sometime back I developed a Restful service in Java with only 1 GET resource. It was accessed like this: GET http://localhost:8080/my-project/customers/transactions This GET request returns all the customer transactions. Now, I have another project request where they want to insert customer transactions in a different schema in same database. I thought instead of creating other service I could enhance this service since underlying database is same and it's about customer transactions. So, I

Jersey: Can I add a cookie in ContainerResponseFilter?

旧时模样 提交于 2019-12-19 05:34:57
问题 I have a ContainerResponseFilter and I tried to set a cookie in it as follows: @Override public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException { String cookieName = "ExampleCookie"; String cookieValue = "SomeData"; logger.info("Setting cookie " + cookieName + " with value " + cookieValue + " into cookies " + JsonUtils.objectToJson(containerResponseContext.getCookies())); containerResponseContext.getCookies()

Is there any way to know which parameter is being parsed in a Jersey @__Param fromString handler?

隐身守侯 提交于 2019-12-19 05:21:25
问题 The API I'm working with has decided to accept UUIDs as Base32 encoded strings, instead of the standard hexadecimal, dash separated format that UUID.fromString() expects. This means that I can't simply write @QueryParam UUID myUuid as a method parameter, as the conversion would fail. I'm working around this by writing a custom object with a different fromString converter to be used with the Jersey @QueryString and @FormParam annotations. I would like to be able to access the context of the

JAX-WS MTOM Sample Code

时光总嘲笑我的痴心妄想 提交于 2019-12-19 04:04:38
问题 I'm looking for a simple, working sample MTOM sample code (service + client) either using JAX-WS RI or Axis2-based. I googled the word only to find snippets and codes that don't simply work! I want to send PDF attachments to the requesting web service client. 回答1: looks like i asked the Question a little early :) Here is a sample jax-ws code with MTOM .. i cud manage on my own.. Heard and read that even with axis2 + mtom there are some issues..documentation too is really bad in axis2. Also

how to disable Jersey from weblogic 12.2.1

拜拜、爱过 提交于 2019-12-19 03:48:04
问题 Weblogic 12.2.1 has Jersey 2.21.1 inside as implementation of JAX-RS 2.0,but we would like to use Jersey 2.5.1 or Jersey of the latest version. General way to solve the conflict is to define classes in configuration file to load classes from application. But when you upgrade weblogic or Jersey, you have to look into the class conflict and make changes to configuration, is there a convenient way to disable Jersey from weblogic? 回答1: You need to include the jersey files in the web-inf lib of

Enabling OAuth1 Support on a Jersey Jax-rs web service

别等时光非礼了梦想. 提交于 2019-12-19 03:24:36
问题 I'd like to enable OAuth1 Provider support on my restful web service. Jersey supports this as described here Jersey OAuth1 Provider support. I've been trying to register it as so: public ApplicationConfig(){ super(); addRestResourceClasses(getMyResourceClasses()); register(new OAuth1ServerFeature(new DefaultOAuth1Provider(),"/oauth/access_token","/oauth/request_token")); } But, when I register the OAuth1ServerFeature, I get a 404 when trying to access my resources. Can't seem to find any

Hosting Static Content and JAX-RS Services Under the Same Root Context

心已入冬 提交于 2019-12-19 03:18:07
问题 We have multiple Java web apps packaged as WARs all packaged in an EAR. Our RESTful services are built using JAX-RS and in version specific WARs. We'd like to add static content for each of these version specific WARs, but use the root context (of the WAR) for both the static content and the RESTful service API calls, such that all of the following URLs will work: {hostname}/v1/swagger.yaml <-- Static Content describing the v1 API {hostname}/v1/orders/{uid} <-- JAX-RS RESTful API (v1)

Jersey custom SecurityContext on EJB jax-rs resource

安稳与你 提交于 2019-12-18 17:11:54
问题 I am trying to implement my own ContainerRequestFilter and configure SecurityContext . It works well on jax-rs resources but EJB jax-rs throws javax.ejb.AccessLocalException Only relevant thing I found is 4 years old and the workaround doesn't seem pretty. https://java.net/projects/jersey/lists/users/archive/2010-05/message/265 My custom SecurityContext: @Provider @PreMatching public class SecurityFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext