从RESTful Web服务调用函数时的NoClassDefFoundError

时间:2013-04-12 14:54:18

标签: rest jax-rs noclassdeffounderror

我正在尝试在java中创建一个RESTful Web服务,允许使用Yubikey进行身份验证。 我正在修改我在尝试学习REST时完成的现有教程。

我正在尝试从javax.ws.rs.core.Response函数中调用验证函数,但是继续从导入的yubikey jar中获取包的错误。

我从构建路径导入了这些jar - >库 - >添加外部罐子

将表单发布到RESTful网址时出现以下错误:

java.lang.NoClassDefFoundError:com / yubico / client / v2 / exceptions / YubicoValidationException

package de.vogella.jersey.todo.resources;


import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

import com.yubico.client.v2.exceptions.YubicoValidationException;
import com.yubico.client.v2.exceptions.YubicoValidationFailure;
import de.vogella.jersey.todo.resources.Validate;

@Path("/test")
public class Test {

@POST
public Response testCred(@FormParam("username") String username,
          @FormParam("password") String password,
          @FormParam("otp") String otp) throws YubicoValidationException, YubicoValidationFailure {
    int client_id = 11095; 
    boolean status;
    status = Validate.validate(otp, client_id);

    return Response.status(200)
        .entity("validation status: : " + status + ", for client " + otp)
        .build();

    }

}

验证类如下:

package de.vogella.jersey.todo.resources;

import com.yubico.client.v2.YubicoClient;
import com.yubico.client.v2.YubicoResponse;
import com.yubico.client.v2.YubicoResponseStatus;
import com.yubico.client.v2.exceptions.YubicoValidationException;
import com.yubico.client.v2.exceptions.YubicoValidationFailure;


public class Validate {

 public static boolean validate(String otp, int client_id) throws YubicoValidationException, YubicoValidationFailure {
        YubicoClient client = YubicoClient.getClient(client_id);
        YubicoResponse response = client.verify(otp);
        if(response != null && response.getStatus() == YubicoResponseStatus.OK) {
          return true;
        }
        return false;
     }

}

0 个答案:

没有答案