jersey

How to list all registered JAX-RS Entity Providers in Jersey

浪子不回头ぞ 提交于 2019-12-09 13:11:12
问题 Let's suppose i have simple jersey app with embedded jetty Demo project on github and essential code below. Back in the days with jersey1 i had log messages: мая 07, 2016 5:05:50 AM com.sun.jersey.api.core.PackagesResourceConfig init INFO: Scanning for root resource and provider classes in the packages: ru.varren мая 07, 2016 5:05:50 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses INFO: Root resource classes found: class ru.varren.MyResource мая 07, 2016 5:05:50 AM com.sun.jersey

Jersey URL forwarding

廉价感情. 提交于 2019-12-09 11:40:20
问题 Inside a Jersey REST method I would like to forward to an another website. How can I achieve that? @Path("/") public class News { @GET @Produces(MediaType.TEXT_HTML) @Path("go/{news_id}") public String getForwardNews( @PathParam("news_id") String id) throws Exception { //how can I make here a forward to "http://somesite.com/news/id" (not redirect)? return ""; } } EDIT: I'm getting the No thread local value in scope for proxy of class $Proxy78 error when trying to do something like this:

Jersey / ServletContext and resource loading on startup

女生的网名这么多〃 提交于 2019-12-09 10:15:51
问题 I'm kind of new in web development with Java. I am developing a web service and I've chosen REST / Jersey for it. I want to init some stuff on startup of the service and to keep them all along the life of the service. First question : Is the constructor of the Jersey Servlet a good place to do that ? Basically, what I want to do is to load a config.ini file located in my WEB-INF directory. Following this help, I understand I need a ServletContext to load my file as a resource. However, it is

How to configure welcome file (HTML/JSP) in Jersey container

无人久伴 提交于 2019-12-09 10:01:37
问题 I have a Jersey RESTful web service project. I have configured the Jersey container in the web.xml and everything works fine. In the same project, I have introduced one HTML page and included in the <welcome-file-list> to handle some other non-REST request. But when I am accessing the URL, the welcome file is not displayed. After I commented the Jersey container configuration in web.xml and deployed the application, this time I am able to access the welcome file. Am using Tomcat 7, JDK 7,

'Already Connected' exception trying to do POST request using Jersey Client API

前提是你 提交于 2019-12-09 07:57:21
问题 I'm creating integration tests for a JAX-RS/Jersey Webservice deployed on Tomcat 8 using arquillian. I am trying to do a POST request like that: E dummy = dummyFactory.manufacturePojo(getSubClassType()); dummy.setId(null); Client client = ClientBuilder.newClient(); WebTarget target = client.target(BASE_URI).path("bandeira"); Response response = target.request(MediaType.APPLICATION_JSON) .header(HttpHeaders.AUTHORIZATION, CHAVE_TESTE) .header(HttpHeaders.CONTENT_TYPE, "application/json") .post

Jersey REST Webservice is not working in Struts 2

大憨熊 提交于 2019-12-09 07:20:19
问题 I have created an application Struts2 with Jersey REST webservice, the Struts2 application is working fine but the rest webservice is not working, when execute the URL http://localhost:8080/SAMPLE/resources/users/name/manu I am getting There is no Action mapped for namespace /resources/users/name and action name manu. - [unknown location] Does the version of Struts causes any issues, since I am using Struts 2.1.6 ? Can anyone please tell me some solution for this web.xml : <?xml version="1.0"

Marshal/Un marshal List objects in Jersey JAX-RS using JAXB

不问归期 提交于 2019-12-09 07:16:17
问题 Good Morning. Today morning when I am going through Jersey Entity providers MessageBodyReader s and MessageBodyWriter s I came across the following problem. I want to write a resource method and client that returns a list of custom objects and media type is application/xml . So I would like to use JAXB (I am new to JAXB). I was able to achieve this by writing my own extended MessageBodyReader and MessageBodyWriter . But I am afraid of the way I am following. Just look at the way I implemented

What Jersey version do I need to download for JDK 1.9?

陌路散爱 提交于 2019-12-09 06:12:18
问题 I am using jdk 1.9. I am trying to bring up a simple ReST service. Created the project using the maven archetype: jersey-quickstart-webapp . Then I went ahead and modified the pom.xml and web.xml. My maven config is as shown below: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>restWebService<

How to do Rest Authentication with JAX-RS

六眼飞鱼酱① 提交于 2019-12-09 06:01:11
问题 I am looking for some pointers on how to secure my rest root resource @Path("/employee") public class EmployeeResource { @GET @Produces("text/html") public String get( @QueryParam("name") String empname, @QueryParam("sn") String sn) { // Return a data back. } } I have read post's regarding basic authetication and OAuth, I know the concept but i am looking for ways on how to implement it in code. Thanks 回答1: Declare an interceptor: <bean id="securityInterceptor" class="AuthenticatorInterceptor

Jersey Producing media type conflict

偶尔善良 提交于 2019-12-09 05:10:51
问题 I'm trying out Jersey at the moment, followed this link to set up a web service in netbeans. I have my entities classes and my REST classes. It works to add, edit, delete, request objects (in this case Users objects) from a javafx2 client. However, now I try to add a new method to my webservice for some simple authentication. First I added a new named query (Users.login) in the Users.java file: @NamedQueries({ @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"), @NamedQuery