jersey-2.0

Serialize Java 8 Stream with Jersey

∥☆過路亽.° 提交于 2019-12-01 02:15:10
问题 How can I serialize a Java 8 java.util.Stream<T> with Jersey. I tried to write a MessageBodyWriter , but I need to know how to compose (decorate) existing MessageBodyWriters with a new MessageBodyWriter for my Stream . Stream<String> get(){ return some stream of strings } public <T> class StreamMessageBodyWriter<Stream<T>> implements MessageBodyWriter<Stream<T>> { public void writeTo(.......){ //How can I get the handle to MessageBodyWriter that will write for type T, //so that I can 'collect

Calling SOAP in Jersey

这一生的挚爱 提交于 2019-12-01 01:30:19
I have a requirement from a client which wants to write a wrapper REST web service around a SOAP web service. I am new to both SOAP and REST. Can anyone please let me know If we can call SOAP web service inside a REST web service? If yes, then how to do it in Jersey 2.0? Thanks in advance. Yes There is nothing special about calling a SOAP service from inside a JAX-RS Resouce. Just write a JAX-WS client as described in the Java EE 7 Tutorial . 来源: https://stackoverflow.com/questions/17986498/calling-soap-in-jersey

how to disable Jersey from weblogic 12.2.1

血红的双手。 提交于 2019-11-30 22:40:18
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? user2169241 You need to include the jersey files in the web-inf lib of your project (you can get jersey and dependencies zip file from jersey's website), also add these

Bean Validation 400 errors are returning default error page (html) instead of Response entity (json)

自作多情 提交于 2019-11-30 22:30:38
I have a JUnit testsuite: GrizzlyHttpServerFactory + Jersey + Bean Validation (jersey-container-grizzly2-servlet/jersey-bean-validation ver 2.12, grizzly-http-server ver 2.3.16, hibernate-validator ver 5.0.0.Final) The 400 errors generated by a ValidationException are returning Grizzly's default error page (html) instead of the Bean Validation's Response entity (json). I've tried a ClientResponseFilter and its entityStream also contains the html error page. When I run the system under Tomcat, the ValidationExceptions return a Response with a json-formatted entity. Any ideas on how to configure

Server-sent event does not work with jersey SSE

元气小坏坏 提交于 2019-11-30 21:50:37
I am trying to use JavaScript SSE from Jersey. I have Following code in my resource. I am hosting on Java7 and Tomcat 7. I dont get any error. But I don't see data either on page. I call /broadcast to post data. It does show message. But nothing comes on client. In Firefox, I do see /broadcast event fired multiple times. This is reference I used. https://jersey.java.net/documentation/latest/sse.html package net.jigarshah.dse.tracker; import javax.inject.Singleton; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces;

Jersey 2.x does not support POJO to json?

烂漫一生 提交于 2019-11-30 21:04:02
While i am trying to convert java object to json object by using jersey.i am having an exception. Java code :-(POJO) package org.jersey.media.type; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class MyJaxbBean { public String name; public int age; public MyJaxbBean() {} // JAXB needs this public MyJaxbBean(String name, int age) { this.name = name; this.age = age; } } Resource :- package org.jersey.media.type; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/media") public class MediaResources { @GET @Produces("application/xml")

Calling SOAP in Jersey

大兔子大兔子 提交于 2019-11-30 19:58:13
问题 I have a requirement from a client which wants to write a wrapper REST web service around a SOAP web service. I am new to both SOAP and REST. Can anyone please let me know If we can call SOAP web service inside a REST web service? If yes, then how to do it in Jersey 2.0? Thanks in advance. 回答1: Yes There is nothing special about calling a SOAP service from inside a JAX-RS Resouce. Just write a JAX-WS client as described in the Java EE 7 Tutorial. 来源: https://stackoverflow.com/questions

How to get HK2 ServiceLocator in Jersey 2.12?

对着背影说爱祢 提交于 2019-11-30 19:16:10
I would like to create a singleton instance of a class that is not involved in Jersey as a Resource or Service and yet would like its dependencies injected from the Jersey ServiceLocator. I can register this class manually in my ResourceConfig constructor, the ResourceConfig is then passed in to the Grizzly factory method like so: ResourceConfig resourceConfig = new DeviceServiceApplication(); LOGGER.info("Starting grizzly2..."); return GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, mServiceLocator); The problem that remains is how to get a reference to the Jersey

HK2 Factory invoked prior to Jersey filter when @Context is used for setter/field/constructor injection

泪湿孤枕 提交于 2019-11-30 18:55:42
I've been able to inject into my jersey resource from a filter as per How to inject an object into jersey request context? . This allows me to successfully inject into a method parameter: @GET public Response getTest(@Context MyObject myObject) { // this works However, for setter/field/constructor injection, the HK2 Factory is invoked before the jersey filter, which means the provide() method returns null: @Override public MyObject provide() { // returns null because the filter has not yet run, // and the property has not yet been set return (MyObject)context.getProperty("myObject"); } Is

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

我的未来我决定 提交于 2019-11-30 18:17:58
I am unable to find answer through the following links One Two Three Following is my pom.xml dependency <dependencies> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk</artifactId> <version>1.11.41</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.2</version> <type>jar</type> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> <