jersey

Request header field Access-Control-Allow-Methods is not allowed by Access-Control-Allow-Headers in preflight response

蹲街弑〆低调 提交于 2020-01-30 08:56:26
问题 I'm using Angular in the frontend and Jersey for backend. I am getting an exception when I execute my PUT request. This is the Angular code: const header=new Headers({'Content-Type':'application/x-www-form-urlencoded'}); header.append("Access-Control-Allow-Methods", "POST"); header.append("Access-Control-Allow-Headers","Access-Control-Allow-Origin"); return this.http.post('http://localhost:8080',home,{headers: header}) .pipe(map((response: Response)=>{return response.json();})); This is my

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map

五迷三道 提交于 2020-01-30 01:39:12
问题 I am trying to deploy my first rest application using jersey 2.17 . I am using Maven, GlassFish 3.1.2.2 for deployment. Application runs in eclipse (tomcat), but gives following error when deploying through glassfish admin console. Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchMethodError: javax.ws.rs.core

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map

孤者浪人 提交于 2020-01-30 01:39:11
问题 I am trying to deploy my first rest application using jersey 2.17 . I am using Maven, GlassFish 3.1.2.2 for deployment. Application runs in eclipse (tomcat), but gives following error when deploying through glassfish admin console. Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchMethodError: javax.ws.rs.core

How to retrieve data from database using webservices (JAX - RS) in eclipse using Java

情到浓时终转凉″ 提交于 2020-01-29 05:21:29
问题 I have done inserting a record into database but I don't know how to retrieve it. My code is: Account.java: package com.fetch; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Id; public class Account implements Serializable { @Id private long id; @Column(name="NAME") private String name; public Account() { } public Account(int id, String name) { this.id = id; this.name = name; } public long getId() { return id; } public void setId(long id) { this.id = id

Java unmarshilling JSON data containg abstract type

二次信任 提交于 2020-01-28 10:46:06
问题 We are using Jersey/Jackson to unmarshall JSON data to java DTOs. One of my DTO is an abstract class, and i would like to unmarshall the JSON data to one of his extended DTO. For example, assuming i have these DTOs : public abstract class AnimalDTO{} public class DogDTO extends AnimalDTO{} public class CatDTO extends AnimalDTO{} I would like to unmarshall this JSON data: {Zoo: {Animals:[{"type"="DogDTO", "code"="001", "name"="chihuahua"}, {"type"="CatDTO", "code"="002", "name"="felix"}]}} As

jackson - MessageBodyWriter Not Found when returning a JSON POJO from a GET Api

空扰寡人 提交于 2020-01-25 11:56:10
问题 I was trying to return a simple json response using jackson. @GET @Produces(MediaType.APPLICATION_JSON) public FMSResponseInfo test(){ System.out.println("Entered the function"); FMSResponseInfo fmsResponseInfo = new FMSResponseInfo(); List<SearchDetailsDTO> searchDetailsDtoList = new ArrayList<>(); for (int i = 0; i < 5; i++) { SearchDetailsDTO searchDetailsDto = new SearchDetailsDTO(); searchDetailsDto.setBarcode("barcode" + i); searchDetailsDto.setDocNo("docNo" + i); searchDetailsDto

How to authenticate and redirect a user to his 'own' page in Jersey REST service

白昼怎懂夜的黑 提交于 2020-01-25 06:04:16
问题 How to authenticate and redirect a user to his own page i.e to www.mysite.com/"user's email". I am using the following algo which is not working... userDB in User class: Map<String,String> userdata=new HashMap<String,String>(); First my login process form : @Path("/login") @POST @Produces(MediaType.TEXT_HTML) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void login( @FormParam("email") String emailc, @FormParam("password") String pass, @Context HttpServletResponse servletResponse )

How to authenticate and redirect a user to his 'own' page in Jersey REST service

岁酱吖の 提交于 2020-01-25 06:03:06
问题 How to authenticate and redirect a user to his own page i.e to www.mysite.com/"user's email". I am using the following algo which is not working... userDB in User class: Map<String,String> userdata=new HashMap<String,String>(); First my login process form : @Path("/login") @POST @Produces(MediaType.TEXT_HTML) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void login( @FormParam("email") String emailc, @FormParam("password") String pass, @Context HttpServletResponse servletResponse )

MAVEN BUILD FAILURE - Could not resolve dependencies for project XYZ

只谈情不闲聊 提交于 2020-01-25 02:56:48
问题 I am integrating jersey and spring, for which I have following dependencies, but I am unable to build due to following error: My POM file: <dependencies> <!-- Jersey --> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.8</version> </dependency> <!-- Spring 3 dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.0.5.RELEASE</version> </dependency> <dependency> <groupId>org

ImageIO.read returns null on byte array

我的梦境 提交于 2020-01-24 20:43:13
问题 Here is my code. I get a blob from my database. Which is returned to me like this: java.io.BufferedInputStream@16e31e37. Now im trying to display the image from my servlet in the browser however my BufferedImage image is always null. I dubugged it and notice my blob length is always 34.. Not matter the image. @Path("/photo" ) public class DisplayPhoto { @GET @Path("{id}") @Produces("image/*") public Response post(@PathParam("id") String id) throws IOException { Connection con = connection();