jersey

Jersey 1.19 Test configuration - mock classes

做~自己de王妃 提交于 2019-12-11 04:47:44
问题 I want to test my REST service with: <dependency> <groupId>com.sun.jersey.jersey-test-framework</groupId> <artifactId>jersey-test-framework-grizzly2</artifactId> <version>1.19</version> <scope>test</scope> </dependency> I have configuration class: public class MyServiceTest extends JerseyTest { @Override protected int getPort(int defaultPort) { return 8080; } public static class AppConfig extends DefaultResourceConfig { public AppConfig() { super(MyService.class); } } @Override public

My first web client giving “MessageBodyWriter not found for media type…” (JSON)

强颜欢笑 提交于 2019-12-11 04:43:50
问题 I'll give you the short story first. If I, in Eclipse, export my jar file with jar files (the Runnable Jar wizard and select "Package required libraries...") instead of "Extract required libraries", every thing works, but it is excruciatingly slow to get going. If I build my jar with the extracting method the code will cause an eventual org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json I'm not using Maven. I

Debugging Jersey Unmarshalling Error - Bad Request syntactically incorrect

邮差的信 提交于 2019-12-11 04:35:55
问题 I am building a REST Webservice with the help of Jersey on Glassfish. Now I am struggeling with my custom input Source for my searchQuerys. If have a search Method: @POST @Path("search") @Consumes({"application/xml", "application/json"}) @Produces({"application/xml", "application/json"}) public List<Index> search(SearchQuery searchqry) { ... } And the Class SearchQuery: @XmlRootElement public class SearchQuery implements Serializable { private static final long serialVersionUID = 1L; public

SQL Query using Hibernate in a Restful Web Service [duplicate]

情到浓时终转凉″ 提交于 2019-12-11 04:35:13
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: SQL Query with MySQL I implement a Rest Web Service (JAX-RS) using Jersey in Java. I use hibernate to fetch the data from MySQL database. With this query: (Select distinct deliverable.id from Task as t where t.project.id= :id And t.user.username = :name order by t.id desc") .setMaxResults(3) .setLong("id", projectId) .setString("name", username) .list(); I have a right result which is : [275,51,286]. This is the

@XmlInverseReference - invalid token in json in a bidirectional JPA relationship

佐手、 提交于 2019-12-11 04:33:33
问题 I have cyclic issues with a 2 way JPA relationship using Jersey. I am trying to solve the cyclic dependency with @XmlElement and @XmlInverseReference, and while getting closer - my json wont parse as it seems to be introducing an invalid "close bracket". My entities look as below: @Entity(name = "PR_GPT") @Table @XmlRootElement @PersistenceUnit(unitName = "graps-jpa") public class PrGPT { @ManyToOne(optional=false) @JoinColumn(name="THERAPY_AREA") @XmlInverseReference(mappedBy="gpts")

Marshalling of Object with CDATA using Jersey Framework

落爺英雄遲暮 提交于 2019-12-11 04:29:30
问题 i want to marshal my object using CDATA block. i can do this with creating marshaller and setting property for CharacterEscapeHandler(http://stackoverflow.com/questions/14193944/jaxb-marshalling-unmarshalling-with-cdata). but in Jersey marshalling is done by jersey. so how can i tell jersey to marshal object with CDATA. i have following service @GET @Path("/getdata") @Produces(MediaType.TEXT_XML) public HelloBean getData() throws Exception { HelloBean h1 = new HelloBean(); h1.setName("kshitij

swagger - empty listing with no API

懵懂的女人 提交于 2019-12-11 04:28:14
问题 I am trying to use swagger in order to document my Rest APIs. I am developing a Tomcat/Spring server and the rest apis are developed using Jersey. I following swagger guide and added the required data to my web.xml: <servlet> <servlet-name>resources</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.wordnik.swagger.jersey.listing;app.servlet.resources

JSON Serialization of pojos with child objects

旧城冷巷雨未停 提交于 2019-12-11 04:16:48
问题 Let's say I have a restful webservice with the following interfaces: GET /some/parent This will return something like [ { urn: "/some/parent/1", name: "parent1", children: [ "/some/child1", "/some/child2" ] }, { urn: "/some/parent/2", name: "parent2", children: [ "/some/child3", "/some/child4" ] } ] and, i've got GET /some/parent/{id} that return something like this: { urn: /some/parent/1, name: parent1, children: [ { urn: "/some/child1", name: "child1" }, { urn: "/some/child2", name: "child2

Spring Profile Based Jersey Rest Service publish

不打扰是莪最后的温柔 提交于 2019-12-11 04:16:02
问题 It is possible to publish jersey rest service based on spring profile? lets say as following example, how can I publish RegisterServices1 when using profile1 ? public class ApiGWRestApplicationConfig extends ResourceConfig { public ApiGWRestApplicationConfig() { register(RegisterServicesApiGWInterface.class); } } @Service @Profile("profile1") @Path(SystemConstants.REST_REGISTER) public class RegisterServices1 implements RegisterServicesApiGWInterface { } @Service @Profile("profile2") @Path

@Valid not throwing exception

↘锁芯ラ 提交于 2019-12-11 03:54:51
问题 I'm trying to validate my JPA Entity with @Valid like this: public static void persist(@Valid Object o) It worked fine for a while but now it stopped working and I'm not sure why. I tried to do it manually inside the persist method, and it works as expected: ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<Object>> constraintViolations = validator.validate(o); if (!constraintViolations.isEmpty()) {