jersey

Unmarshalling json by reversing the affect of @XmlElement renaming?

情到浓时终转凉″ 提交于 2019-12-12 02:14:16
问题 I have a class defined as follows: public class Contact implements Serializable { private final static long serialVersionUID = 1L; @XmlElement(name = "last-name", required = true) protected String lastName; @XmlElement(name = "first-name", required = true) protected String firstName; @XmlElement(required = true) protected String id; @XmlElement(name = "primary-phone") protected String primaryPhone; @XmlElement(name = "cellular-phone") protected String cellularPhone; } This class is being used

In Neo4j using managed extensions and the SpringInitializerPlugin parameters are no longer injected

情到浓时终转凉″ 提交于 2019-12-12 01:59:26
问题 We had an app running on neo4j 2.1.1 using managed extensions and a SpringInitializerPlugin earlier this year. We have since returned to it and tried to fire it up again. We are now using neo4j 2.1.5 and it seems that the parameters defined in the SpringInitializerPlugin aren't being injected into our resources. We created this simple project which demonstrates the problem. https://github.com/whatsthebeef/neo4j-managed-extensions-test The error we see is this below Can some explain what has

How to inject EJB into ResourceFilterFactory (Jersey)

痴心易碎 提交于 2019-12-12 01:34:12
问题 I cannot seem to get anything injected via @EJB or @Inject into Jersey. When I use @EJB/@Inject in the FilterFactory the field remains null, but injecting into other beans works fine. I can successfully inject using @Context for the FIlterFacory. What am I missing here? public class FilterFactory implements ResourceFilterFactory{ @EJB private MyFilter myFilter ; @Override public List<ResourceFilter> create(AbstractMethod am) { List<ResourceFilter> filters = new ArrayList<ResourceFilter>();

Can you use request scoped @Context variables in a singleton ContextResolver in JAX-RS?

自作多情 提交于 2019-12-12 01:32:47
问题 I'm using Jersey 1.13 with Spring. I've got a ContextResolver defined like so: @Provider public class ThemeSourceContextResolver implements ContextResolver<ThemeSource> { @Context private HttpServletRequest request; @Override public ThemeSource getContext(Class<?> type) { return new DefaultThemeSource(request); } } <bean id="themeSourceContextResolver" scope="singleton" class="com.example.ThemeSourceContextResolver" /> Is the above valid? Specifically, is it "legal" (or does it make sense) to

Do I need to include the Jersey Jars in my EAR on Glassfish4.0 server?

帅比萌擦擦* 提交于 2019-12-12 01:25:56
问题 I am trying to use Firefox poster to test a Jersey restful webservice running on Glassfish 4.0. I am getting a HTTP Server 500 error returned to the Poster output when I return a java class as xml. I do not get an error when I return a String as xml. This makes me wonder if I need to include any of the JAX-RS jars or Jersey jars in my ear on Glassfish. I was thinking these were included in the Glassfish modules so I am not including them in my WEB-INF lib. Here is an example of what works,

java.io.IOException: Premature EOF in REST in java using jersey

霸气de小男生 提交于 2019-12-12 01:25:39
问题 I implement a RESTful Web Service in Java using jersey and run it on Tomcat7 . I have this query to get list of tasks : @GET @Path("/users/{username}/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response taskList(@PathParam("username") String username) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); List<Task> tasks = null; try { tasks = (List<Task>)session.createQuery("from Task as t where t.user

Jersey object's fromString method is not called

微笑、不失礼 提交于 2019-12-12 01:23:51
问题 This is a follow up question to this question: Passing custom type query parameter I got a class which includes this method: public static MyClass fromString(String json) { Gson gson = new Gson(); MyClass user = gson.fromJson(json, MyClass.class); return user; } The full class: public class MyClass { public String name; public PortalNameEnum portalName; public PortalUserTypeEnum portalUserType; public String notes; public MyClass(String name, PortalNameEnum portalName, PortalUserTypeEnum

How to unmarshall JAX-RS Webservice response (JSON Array) correctly?

元气小坏坏 提交于 2019-12-12 01:06:27
问题 I have some problem using Jersey REST webservices. I have the following domain class: @XmlRootElement public class User { private long id; private String email; private String forename; private String role; public User() { // required for JAXB } // + Getters + Setters } and the following resource class: @Produces(MediaType.APPLICATION_JSON) @Path("/users") public class UserService { @GET public User[] getUsers() { User[] users = ... // Users from DB return users; } } If I request that

How can I resolve this java.lang.NoClassDefFoundError: org.json.simple.JSONObject error?

梦想的初衷 提交于 2019-12-12 00:35:09
问题 I'm developing a Web API in Rational Application Developer using the Jersey framework and Tomcat. I'd like to use JSON, but I'm getting the following error: I know this is usually because of a missing jar, so I made sure it was included in my build path: And in my includes: import java.util.ArrayList; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs

Jersey + Guice + Tomcat producing 404 when served with something other than root directory

断了今生、忘了曾经 提交于 2019-12-11 23:32:28
问题 I have a resource that looks like this: @Path("/Resources/Console") public class ConsoleResource { @POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public String post(/* */) { /* */ } } Whenever my JerseyServletModule is configured as follows, the services work: @Override protected void configureServlets() { bind(ConsoleResource.class); bind(MessageBodyReader.class).to(JacksonJsonProvider.class);