jersey

Outputting Jersey logging to a file?

我们两清 提交于 2019-12-05 21:52:28
问题 We've added these to our web.xml: <init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value> </init-param> <init-param> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value> </init-param> Which is nice for debugging in my dev environment, but, I can't see any examples on logging these

Jersey REST API: java.lang.NoSuchMethodError: org.glassfish.jersey.message.filtering.EntityFilteringFeature.enabled

蓝咒 提交于 2019-12-05 21:49:32
in REST API using jersey, using Maven. Maven successfully added mox and entity jars. I'm getting below error when trying to get JSON type result. @Produces(MediaType.APPLICATION_JSON) content of pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>in.alonebirddev.acs</groupId> <artifactId>messanger</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>messanger</name>

Missing dependency for field when trying to inject a custom context with Jersey

痞子三分冷 提交于 2019-12-05 21:36:57
问题 I have a custom context: public class MyContext { public String doSomething() {...} } I have created a context resolver: @Provider public class MyContextResolver implements ContextResolver<MyContext> { public MyContext getContext(Class<?> type) { return new MyContext(); } } Now in the resource I try to inject it: @Path("/") public class MyResource { @Context MyContext context; } And I get the following error: SEVERE: Missing dependency for field: com.something.MyContext com.something

jersey 2 + spring 4 + jetty-maven-plugin

余生长醉 提交于 2019-12-05 21:36:36
I am trying to make an example of using jersey 2 + spring 4 + jetty-maven-plugin. But keep getting this error, cannot understand why.. Please give me a hand. WARNING: The Jersey servlet application, named com.joejag.code.orders.restservices.ResourceConfiguration, is not annotated with ApplicationPath and has no servlet mapping. 2015-12-16 19:56:38.746:INFO:/.0-SNAPSHOT:main: Spring WebApplicationInitializers detected on classpath: [org.glassfish.jersey.server.spring.SpringWebApplicationInitializer@2776015d] 2015-12-16 19:56:38.778:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.m

Jersey Inject Weld managed bean into ConstraintValidator

二次信任 提交于 2019-12-05 21:33:12
I've been searching for hours to find a solution for my problem but I can't get it to work. I want to inject my Weld-managed service into a ConstraintValidator that is used to validate a User-Object that is posted to my JAX-RS Rest-Service. Everything is deployed to a glassfish 4.1 server. I have a Service like this @ApplicationScoped public class UserService { } and I want to inject it into a ConstraintValidator like this public class UniqueUserNameValidator implements ConstraintValidator<UniqueUserName, ApiUser> { @Inject private UserService service; @Override public void initialize

Spring promoting request scoped bean to child threads (HttpServletRequest)

馋奶兔 提交于 2019-12-05 20:48:40
问题 I tried a lot of things now but i seem to miss a piece of the puzzle. Here is the story: I have a request scoped bean that reads some SessionContext from the HttpServletRequest. This attribute is set in a filter. So this is working absolutely fine while the code runs on the correct thread. @Component @Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.INTERFACES) public class SessionContextProviderImpl implements SessionContextProvider<SessionContext> { private

Non-resolvable import POM: Could not transfer artifact

徘徊边缘 提交于 2019-12-05 19:50:39
This my pom.xml and the errors I get are: Non-resolvable import POM: Could not transfer artifact org.glassfish.jersey:jersey-bom:pom:2.9 from/to central ( http://repo.maven.apache.org/maven2 ): repo.maven.apache.org @ line 14, column 25: Unknown host repo.maven.apache.org and 'dependencies.dependency.version' for org.glassfish.jersey.containers:jersey-container-grizzly2-http:jar is missing. @ line 25, column 21 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org

Mocking Jersey Client using Mockito

*爱你&永不变心* 提交于 2019-12-05 19:40:53
Hello I am testing Jersey Client 1.19 version using JUnit and Mockito. I am struggling on getting or reading the entity. I don't know how to proceed from there and i am also getting IllegalStateException. Below is the code that i am using to create mock objects for client response. public class MockJerseyClient { private ClientConfiguration clientConfig; private Client client; private WebTarget webTarget; private Invocation.Builder invocationBuilder; private Response response; private RetrieveBillingResponseXMLReader xmlReader; private ResponseBuilder responseBuilder; public MockJerseyClient

Can I use both @Post and @Get on the same method

回眸只為那壹抹淺笑 提交于 2019-12-05 19:39:21
问题 I would like to use both @Post and @Get on the same method like @GET @POST @Path("{mode}") public void paymentFinish(@PathParam("mode") String mode, String s) { logger.debug("Enter PayStatus POST"); logger.debug(mode); } Even I write like this, I got error. What I want is whatever get or post to the sameurl, the same method works. Is it possible? Now I separate two methods, one for get and one for post. 回答1: Unfortunately, only one should be used in order to avoid Jersey exception. But you

Jersey GenericEntity Not Working

≡放荡痞女 提交于 2019-12-05 19:27:12
I am using Jersey's GenericEntity to return a list as json. However I'm getting the exception A message body writer for Java type, class java.util.Arrays$ArrayList, and MIME media type, application/xml, was not found 16-May-2011 11:16:31 com.sun.jersey.spi.container.ContainerResponse traceException SEVERE: Mapped exception to response: 500 (Internal Server Error).... I know this means that Jersey is not setup to map to json properly. Where do I need to give more information to jersey. I am not using Maven. The code that breaks is List<String> list = Arrays.asList("test", "as"); return new