Boa noite, estou tendo problemas numa aplicação REST. Está gerando o seguinte erro:
The method received in the request-line is known by the origin server but not supported by the target resource.
O Método esta vindo por POST, segue o código:
package br.com.festivalRest.rest.authentication;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.Response;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.codehaus.jackson.map.ObjectMapper;
import br.com.festivalRest.bd.conexao.Conexao;
import br.com.festivalRest.jdbc.JDBCAuthenticationDAO;
import br.com.festivalRest.objetos.User;
@Path("authenticationRest")
public class AuthenticationRest extends UtilRest {
public AuthenticationRest(){
}
@POST
@Path("/foundUser")
@Consumes("application/*")
public Response foundUser(String contatoParam){
System.out.println(contatoParam);
try{
User user = new ObjectMapper().readValue(contatoParam, User.class);
Conexao conec = new Conexao();
Connection conexao = conec.abrirConexao();
JDBCAuthenticationDAO jdbcAuthentication = new JDBCAuthenticationDAO(conexao);
jdbcAuthentication.foundUser(user);
conec.fecharConexao();
return this.buildResponse("OK");
}catch(Exception e){
e.printStackTrace();
return this.buildErrorResponse("Falha");
}
}
}
function foundUser(){
$.ajax({
type: "POST",
url: "rest/authenticationRest/foundUser",
data: $("#authentication").serialize(),
success:function(date){
alert("Teste");
},error(err){
console.log(err);
alert("Erro ao processar a requisição " + err.responseText);
}
});
}
package br.com.festivalRest.jdbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import br.com.festivalRest.rest.jdbcinterface.FestivalDAO;
import br.com.festivalRest.objetos.User;
public class JDBCAuthenticationDAO implements FestivalDAO {
private Connection conexao;
public JDBCAuthenticationDAO(Connection conexao){
this.conexao = conexao;
}
public boolean foundUser(User user){
boolean checkUser = false;
String comando = "select * from usuarios where login = ? and senha = ?";
PreparedStatement p;
ResultSet rs = null;
try{
p = this.conexao.prepareStatement(comando);
p.setString(1, user.getLogin());
p.setString(1, user.getSenha());
rs = p.executeQuery();
if(rs.next()){
checkUser = true;
}
} catch(Exception e){
e.printStackTrace();
}
return checkUser;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Festival</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>br.com.festivalRest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>