jersey-2.0

tomcat gives http404 error when used to test jersey java web service

喜你入骨 提交于 2019-12-12 03:31:43
问题 I have a jersey java dynamic web project...a web service which i think is laid out correctly (hoping im wrong though). This web service runs off tomcat8.5 server on my win 10 laptop. When Tomcat is manually started in services I can hit its home page at localhost:8081. When i run my web service in eclipse i am denied with http 404 error 'request resource isnt available'. I cant even hit the localhost:8081 the same way i can when i start it manually and i cant see it started in 'services'..

Provider io.swagger.scala.converter.SwaggerScalaModelConverter could not be instantiated

泄露秘密 提交于 2019-12-12 02:26:13
问题 When trying to incorporate swagger into my API I'm running into some issues. My API is using Jersey 2.22 and the language is Scala. I've added the following dependencies to my pom: <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> <version>1.5.12</version> </dependency> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-scala-module_2.11</artifactId> <version>1.0.3</version> </dependency> My plugin is configured as follows: <plugin> <groupId

Cross-context request forwarding in tomcat results in java.lang.ClassCastException: org.glassfish.jersey.message.internal.TracingLogger

青春壹個敷衍的年華 提交于 2019-12-12 02:14:20
问题 I am trying to forward a request from one webapp (using Jersey 2.10) to another (" myWebapp ") by using RequestDispatcher.forward(request, response). Both webapps reside in /tomcat/webapps. In the context.xml I set <Context crossContext="true"> . @GET @Path("") public Response getTest( @Context ServletContext context, @Context HttpServletRequest request, @Context HttpServletResponse response) throws Exception { ServletContext fCtx = context.getContext("/myWebapp"); System.out.println("ctx: "

Jersey 2 ApplicationEventListener onEvent() not called

扶醉桌前 提交于 2019-12-12 01:23:22
问题 The ApplicationEventListener#onEvent is never called. What could be wrong here.The resource config class is used and i am able to call APIs. <servlet> <servlet-name>MyApplication</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com.MyApplication</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>MyApplication</servlet-name> <url-pattern>/*</url-pattern> <

Jersey2 ContainerRequestFilter not executing before autentication

♀尐吖头ヾ 提交于 2019-12-12 01:17:28
问题 I am trying to get security working with my jersey2 web app. I register RolesAllowedDynamicFeature and my Request filter with AUTHENTICATION priority in my ResourceConfig packages("example.jersey"); register(MyRequestFilter.class, Priorities.AUTHENTICATION); register(RolesAllowedDynamicFeature.class); I added @RolesAllowed to the method @RolesAllowed("quinn") @GET @Path("/") public Response getIt(@Context UriInfo uriInfo) { return Response.ok().entity(service.get()).build(); } In my request

Jersey 2.x Custom Injection annotation NULL

徘徊边缘 提交于 2019-12-12 00:18:51
问题 I'm following the 22.1. Implementing Custom Injection Provider paragraph https://jersey.java.net/documentation/latest/user-guide.html#deployment I defined my classes as below: public class PrincipalConfig extends ResourceConfig { public PrincipalConfig() { packages("com.vex.klopotest.secured,com.klopotek.klas.auth.injection"); register(new MyBinder()); } } Where MyBinder is : Public class MyBinder extends AbstractBinder implements Factory<KasPrincipal> { @Override protected void configure() {

Running Java EE 7 on Tomcat 7 in Netbeans

青春壹個敷衍的年華 提交于 2019-12-11 21:36:27
问题 I'm not able to run a Java EE 7 webapp on tomcat 7 while in Eclipse using the same tomcat server it works. I can find my tomcat 7 server if I change the following in my pom.xml: <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> If i change it to 6.0 it works fine in Netbeans but the problem is I'm using Jersey for my Rest API and at client side I use: new Gson().fromJson(resp.readEntity(String.class),

Best practice for enabling a user to only change the data he owns on JAX-RS and Jersey

▼魔方 西西 提交于 2019-12-11 17:22:30
问题 Here and here are good examples of best practices on dealing with REST token-based authentication. But in my case I am worried about one user using his own token to modify another user's data. The problem arises when we just verify if a user has a valid token and if positive, then execute any operation the user asked for. Of course the most simple way to defeat this is to check if the authorized user id is the same as the one in the Request JSON (e.g. user_id ). But this is tedious (all

Is it possible to possible to achieve with Jersey a polymorphic deserialisation of json payloads on POST resources

核能气质少年 提交于 2019-12-11 16:56:19
问题 I'd like a endpoint to accept on a single verb and path a json payload that varies by a tiny bit and that can be mapped to different objects. The variation is usually on the field value like the grant_type in the OAuth world. I scrapped stackoverflow and google on this, I found this among other JAX-RS polymorphic POST request: how should I write my JSON? Polymorphism in JSON, Jersey and Jackson But those question don't seem to be relevant to me, jackson deserialisation alone works fine for

Camel-Jersey Integration

余生颓废 提交于 2019-12-11 13:38:49
问题 I have a requirement to use Jersey 2 as the Rest interface. I need to adapt this to an existing system which has used CXF to pass in SOAP requests. I know I should use CXF-RS but... it's not what the client wants. I am auto-generating a WADL from a XML model and using that to autogenerate the resource classes (using CXF, but behind the scenes so to speak), so I really don't want to call a producer template from within the resource class. So, I have thought that I could wrap the REST resource