jersey

When to use @Singleton in a Jersey resource

十年热恋 提交于 2019-12-13 11:59:09
问题 I have a Jersey resource that access the database. Basically it opens a database connection in the initialization of the resource. Performs queries on the resource's methods. I have observed that when I do not use @Singleton, the database is being open at each request. And we know opening a connection is really expensive right? So my question is, should I specify that the resource be singleton or is it really better to keep it at per request especially when the resource is connecting to the

Jersey: org.glassfish.jersey.server.mvc cannot be resolved

你离开我真会死。 提交于 2019-12-13 08:14:16
问题 I want to use Jersey MVC in my project. I've never used Jersey MVC before. I'm working in: Eclipse (Version: Neon.1a Release (4.6.1)) , using: Jersey 2.25.1 Apache Tomcat 7.0.76. Here's the example I'm trying to run: Hello.java MyApp.java NewFile.jsp I have downloaded jersey 2.25.1 from here and added all jar files in Here's how I call my web service: The underlined import line tells: So this is the problem I want to solve. Because I have not found any information related to this problem I

Java RESTful API - JSON repsonse doesn't return some fields of an Object

橙三吉。 提交于 2019-12-13 08:05:50
问题 I am a newbie when it comes to Java RESTful API's. My current problem is that the JSON response is not returning some fields. Here is what I mean; I have some JSON code which will be used to create a user profile. { "fName": "fUser", "sName": "sUser", "username": "helloUser" } I send this code to the appropriate POST method and afterwards I am expecting a JSON response. This is what I expect the response to be; { "id": "003629d7-90ea-4139-9752-c9a8a21306f6", "fName": "fUser", "sName": "sUser"

Jersey REST web service with Hibernate causes NoSuchMethodError on JBoss EAP 6.4

。_饼干妹妹 提交于 2019-12-13 07:39:51
问题 I'm trying to create a very simple Jersey REST webservice project with Hibernate 5. The problem is that when I debloy the WAR-file to JBoss EAP 6.4, I'm getting following exception: "The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V" When running the project as a Java Application on Eclipse, Hibernate works perfectly.

Url max length when using rest (jersey)

跟風遠走 提交于 2019-12-13 06:55:37
问题 if I ask a (rest) service to give me data with an url like this http://example.com/?userid=1,2,3,4(...) there's a url size limit, meaning I am limited in how many userids I can send over to the server. So far so clear, but if I call this url from a jersey client to a jersy rest service, it seems like I have no limit. So is there a url limit for jersey as well? Thanks 回答1: The limit would be defined by your servlet container. For example, this describes setting the limit in tomcat 回答2: The

JPA : Not able to persist record due to incorrect values being passed from client to server

谁都会走 提交于 2019-12-13 06:23:51
问题 I have the following Entity relationship Emp Entity @Entity @Table(name = "EMP", schema = "SCOTT" ) @XmlRootElement @NamedQueries({ @NamedQuery(name = "Emp.findAllEmployees", query = "select e from Emp e left join fetch e.deptNo order by e.empno desc") }) public class Emp implements java.io.Serializable { @Id @Column(name = "EMPNO", unique = true, nullable = false, precision = 4, scale = 0) private short empno; @ManyToOne @JoinColumn(name = "DEPTNO", referencedColumnName = "DEPTNO") private

How to find the togglz url when integrating with spring-boot and jersey

最后都变了- 提交于 2019-12-13 06:22:37
问题 My application based on spring-boot and jersey. I have configured togglz in my application. I can successfully launch my web application but running gradle bootRun. From the output during the startup, I am able to see below log message. But I am not able to access http://localhost:8080/togglz. My application root path is "/" which is managed by jersey. It seems that spring-mvc works well with togglz but failed to access it when integrating with jersey. What should I do in order to let jersey

Uploading a file in Jersey without using multipart

安稳与你 提交于 2019-12-13 06:13:03
问题 I run a web service where I convert a file from one file format into another. The conversion logic is already functioning but now, I want to query this logic via Jersey. Whenever file upload via Jersey is addressed in tutorials / questions, people describe how to do this using multipart form data. I do however simply want to send and return a single file and skip the overhead of sending multiple parts. (The webservice is triggered by another machine which I control so there is no HTML form

Missing dependency for method

 ̄綄美尐妖づ 提交于 2019-12-13 05:59:05
问题 I am running REST Web Service and after adding some new Web Services I got some errors. Why do I get these errors? SEVERE: The following errors and warnings have been detected with resource and/or provider classes: SEVERE: Missing dependency for method public entities.ProyectoHasPersona service.ProyectoHasPersonaRESTFacade.find(entities.ProyectoHasPersonaPK) at parameter at index 0 SEVERE: Method, public entities.ProyectoHasPersona service.ProyectoHasPersonaRESTFacade.find(entities

Jersey http client: put request with custom Content-Length

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:19:49
问题 A want to put data from InputStream, but Jersey can not detect data length automatically and not preset Content-Length header. Response destinationResponse = responseWebTarget .request() .header(HEADER_X_AUTH_TOKEN, cmd.getOptionValue("dat")) .put(Entity.entity(inputStream, MediaType.APPLICATION_OCTET_STREAM)) result is: INFO: 2 * Sending client request on thread main 2 > PUT http://192.168.1.10:8080/v1/AUTH_system/08138784704e2/test 2 > Content-Type: application/octet-stream 2 > X-Auth-Token