jersey

JSON not generated in using Jersey

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:50:37
问题 I'm using the latest version of Jersey to implement some REST sample services. Do you have any clue why when I generate the following HTTP request using Fiddler,I get: 500 Internal Server Error MessageBodyWriter not found for media type={application/json, q=1000}, type=class java.util.ArrayList, genericType=java.util.ArrayList<com.example.Todo> HTTP request: GET http://localhost:8080/RestProject/rest/todos/1 HTTP/1.1 Connection: close Accept: application/json User-Agent: Mozilla/5.0 (Windows

How do I programmatically configure Jersey to use Jackson for JSON (de)serialization?

谁都会走 提交于 2019-12-11 03:38:53
问题 I'm using Jersey together with Grizzly to create a JSON web service. I initialize it as follows: final ResourceConfig rc = new PackagesResourceConfig("amplify.api.resources"); rc.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); return GrizzlyServerFactory.createHttpServer(BASE_URI, rc); I have no web.xml file. I noticed that Jersey was mapping single element lists to be "element" rather than "[element]" as I would expect. It seems that apparently this is because Jersey uses

Why is my Jersey JAX-RS server throwing a IllegalStateException about not being in RequestScope?

柔情痞子 提交于 2019-12-11 03:35:19
问题 I've been looking at this one for too long and found the solution and wanted to provide feedback for any other intrepid JAX-RS adventurers that follow. Error: java.lang.IllegalStateException: Not inside a request scope. at com.google.common.base.Preconditions.checkState(Preconditions.java:149) at org.glassfish.jersey.process.internal.RequestScope.current(RequestScope.java:226) at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:154) at org.jvnet.hk2.internal

Consuming JSON requests using Jersey and Jackson

喜你入骨 提交于 2019-12-11 03:20:32
问题 Im developing a basic Jersey WebService which will accept JSON request and send back data in JSON. I have also developed a basic test client to send requests and get response back as a Java Standalone program. Im able to successfully send and get response for GET and POST requests (text/html), but when I send JSON data Im getting below error. It appears to be tied to Jackson translation. Im not using maven. Jersey Service : import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws

Logging in CXF and RestEasy clients

限于喜欢 提交于 2019-12-11 03:17:11
问题 this week I was trying Jersey, CXF and RestEasy clients (using JSON) as a standalone application(testing purposes), and I notice something. In Jersey I can enable logs with one line of code: Client client = Client.create(); client.addFilter(new LoggingFilter(System.out)); WebResource webResource = client.resource("http://localhost:8080/IT1/MB1"); .... String output = response.getEntity(String.class); .... Using the LoggingFilter, I get interesting information about the request and/or response

How can I bind a factory to a annotation-qualified injection point?

情到浓时终转凉″ 提交于 2019-12-11 03:06:15
问题 I asked and got an answer how to bind a named injection point. And I don't know how to bind a factory to a qualified injection point. class SomeResource { @Inject @Some // is a @Qualifier, of course. private MyType qualified; } I prepared a factory class SomeFactory extends Factory<MyType> { } And I stuck on creating a binder for that class SomeBinder extends AbstractBinder { @Override protected void configure() { // @@? } } I actually want to know how to use ServiceBindingBuilder#qualifiedBy

JsonTypeInfo does not serialize when using Jackson with Jersey

半世苍凉 提交于 2019-12-11 02:58:55
问题 I annotated a JAXB class with JsonTypeInfo so that I could serialize polymorphic classes easily. However, the annotation does not show up when serialized by Jersey. To be more specific, it shows up when using ObjectMapper but not as a return type from a resource. I am very confused right now as this seems to be a problem with Jersey => Jackson interaction. To debug things, I used the jsonfromjaxb example from the jersey-samples to localize my problem. I added the following to the Flights

how do i solve the XMLStreamException

喜你入骨 提交于 2019-12-11 02:58:32
问题 I am using REST web service and i need to parse the XML that is build using the jaxb. I get the following exception. Please help me solve this issue thank in advance java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamException com.sun.xml.bind.v2.runtime.JAXBContextImpl.createMarshaller(JAXBContextImpl.java:686) com.sun.xml.bind.v2.runtime.JAXBContextImpl.createMarshaller(JAXBContextImpl.java:116) com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider

Jersey linking support with Google App Engine issue

[亡魂溺海] 提交于 2019-12-11 02:56:41
问题 I didn't manage to use the Jersey linking support with Google App Engine, I'm getting these exceptions when trying to access the application : Caused by: javax.el.ELException: Could not find expression factory class ... Caused by: java.lang.ClassNotFoundException: de.odysseus.el.ExpressionFactoryImpl As specified in the documentation, I put this in the Jersey servlet section of the web.xml : <init-param> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name> <param

How to apply interceptors and filters to restful services on Weblogic 12c

徘徊边缘 提交于 2019-12-11 02:48:26
问题 I understand that Weblogic 12c v12.2.1 uses Jersey as a JAX-RS implementation. So I followed the instructions on this page but I haven't succeeded to declare an interceptor whether by using name binding or dynamic binding (i.e. more info in the mentioned link) My application is working normally because I can actually call the restful services, but I can't apply filters or interceptors, they are never involved in the process. I didn't edit web.xml at all, all I have is an javax.ws.rs.core