jersey

What is happening inside applicationContext.xml

拥有回忆 提交于 2019-12-13 02:46:54
问题 Will someone please explain what the following applicationContext.xml file is doing? For greater context, I get it from http://persistentdesigns.com/wp/jersey-spring-and-jpa/. Some of my questions (not exhaustive, since I really don't understand much): For id="dataSource" is dataSource a keyword or is it the name of the datasource I am to use? For example, if the name of my datasource is actuall learningRestDS, do I replace dataSource with learningRestDS ? Why is the datasource class name org

How to implement a custom ViewProcessor<T> (jax-rs)?

馋奶兔 提交于 2019-12-13 02:35:30
问题 Looking at the article here, there is an example of how to use a TemplateProcessor to resolve JSP views using Jersey. Apparently this class has been deprecated now and replaced by ViewProcessor<T>. I am somewhat confused about how to implement either (preferably the newer one since it isn't deprecated); what goes in as the template argument? How can I implement one to simply resolve jsps in /WebContent/WEB-INF/views/* and also evaluate the expression language of the returned view? The other

PowerMock fails with JerseyTest

拜拜、爱过 提交于 2019-12-13 02:25:34
问题 We're writing unit tests for a Jersey Java REST service using PowerMock. We have to use PowerMock because we use numerous static methods in a legacy system. We're using PowerMock with EasyMock. Whenever we try to inherit from JerseyTest, the whole framework fails. It's a gradle based project, and the pertinent build.gradle lines are below. testCompile 'junit:junit:4.12' testCompile group: 'org.easymock', name: 'easymock', version: '3.5.1' testCompile group: 'org.easymock', name:

JAXB / Jackson handling arrays

安稳与你 提交于 2019-12-13 01:28:38
问题 I'm currently writing a Jersey REST interface for a web application. What I want is the ability to be able to serialize a JSON and XML request to the same object however I'm having trouble getting the Jersey (i.e. JAXB / Jackson) to consume the XML and JSON in the format I want. The XML structure looks like so: <?xml version="1.0" encoding="UTF-8" ?> <message> <buckets> <bucket> <channels> <channel>Test A</channel> <channel>Test B</channel> </channels> <text>This is sample text</text> <

Basic Authentication at Grizzly Server

烂漫一生 提交于 2019-12-13 00:20:51
问题 I am using Jersey Grizzly and want to implement Basic Authentication to Grizzly. I create my grizzly server as follows: ResourceConfig rc = new PackagesResourceConfig("com.abc.de"); GrizzlyServerFactory.createHttpServer(BASE_URI, rc); at another class I have something like: @GET @Produces("text/plain") @Path("/description") public String getDescription() { String description = "probeDescription"; return description; } I don't know the difference and main concepts of jersey and grizzly. What

Jersey constructor with parameters

妖精的绣舞 提交于 2019-12-12 23:13:07
问题 I want to use a DAO in my RESTful service developed with Jersey, so the DAO implementation should be injected via the constructor of the service: @Path("eventscheduler) public class EventSchedulerService { private IEventSchedulerDao dao; public EventSchedulerService(IEventSchedulerDao dao) { this.dao = dao; } } However, I know Jersey expects a default constructor to setup everything correctly. I have been trying to figure out how to do this for a while but surprisingly this seems to be an

JBoss6 with REST client (jersey-client)

◇◆丶佛笑我妖孽 提交于 2019-12-12 23:06:24
问题 I want to consume a REST service in my web app (.war with 6.0.0.Final), but have problems adding jersey-client libs: <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.9.1</version> <type>jar</type> <scope>compile</scope> </dependency> With this configuration I get the following error during JBoss startup: 08:11:28,297 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web]. [localhost].[/test]] Exception starting filter Resteasy: java.lang

Jackson JSON date format serialization based on condition

一曲冷凌霜 提交于 2019-12-12 22:15:44
问题 I am using Mule 3.5.2 and I have a REST service that send and receives JSON messages. The service is for both Norway and Sweden. All dates are send as strings, but Sweden and Norway have different formats. I know by the URL which country calls our service. I am using custom date serializers and deserializers. I can kind of cheat when receiving JSON message, the formats are different enough that in my custom deserializer I can try one format. If that fails I just try the other. However: How do

How to handle jersey and tomcat errors consistently?

和自甴很熟 提交于 2019-12-12 20:48:30
问题 I have implemented some (REST) service with jersey. If there is a bad request jersey handles the error and answers with some JSON content. There is an ExceptionMapper that should catch everything: public class MyExceptionMapper implements ExceptionMapper<Throwable> But if there is an invalid HTTP request - e.g. invalid content type - tomcat handles the exception before jersey has a chance to do so. The resulting response is some ugly tomcat HTML error page instead of the desired JSON. I know

Latest Jersey example does not work

痴心易碎 提交于 2019-12-12 19:17:28
问题 I have isntalled the latest version of jersey (Bundle-Version: 2.13.0) and the examples for that version. Then I tried (for testing Restful services - \examples\helloworld-pure-jax-rs\src\main\java\org\glassfish\jersey\examples) the Hello World example in Eclipse. The result ist this: "Hello World" Jersey Example Application Exception in thread "main" java.lang.IllegalArgumentException: No container provider supports the type interface com.sun.net.httpserver.HttpHandler at org.glassfish