I'm trying to implement Jersey 2.13 with Apache tomcat 8.0.45 and my continuously getting HTTP status 404. I feel like it is because of Jersey version mismatch with the Apache tomcat 8. I tried with different versions, so far no luck. Following is my code and please help me to sort this issue.
POM.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DMSAPI</groupId>
<artifactId>DMSAPI</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20170516</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.13</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.13</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
UpdateUser.java
package com.dms.dmsapi.api;
import java.util.ArrayList;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import org.json.JSONObject;
import com.dms.dmsapi.controller.DbCon;
@Path("/dms")
public class UpdateUser {
@Path("/update")
@GET
@Produces("application/json")
public Response convertFtoCfromInput(
@QueryParam("callerNumber") String callerNumber,
@QueryParam("agentID") String agentID)
throws Exception {
JSONObject jsonObject = new JSONObject();
DbCon db = new DbCon();
int resultValue = db.updateBookTaxi(callerNumber, agentID);
System.out.println("S insert value is " + resultValue);
if (resultValue == 1) {
jsonObject.put("result", "success");
} else {
jsonObject.put("result", "error");
}
String result = jsonObject.toString();
return Response.status(200).entity(result).build();
}
}
URL - http://localhost:8080/DMSAPI/UpdateUser/dms/update?callerNumber=123&agentID=123
/UpdateUser
in your URL? And why do you use a GET to update something i your database? Get is for... getting. – JB Nizetweb.xml
? – Rishikesh Darandale