为了账号安全,请及时绑定邮箱和手机立即绑定

java.lang.ClassNotFoundException: org.glassfish

java.lang.ClassNotFoundException: org.glassfish

MM们 2023-02-23 14:48:22
我的 springbootapp 中有一个处理程序类,它对传入的 REST 请求执行一些验证并将 BadRequestException 抛回控制器类。但不是控制器捕获 BadRequestException,而是捕获异常并抛出java.lang.ClassNotFoundException:org.glassfish.jersey.internal.RuntimeDelegateImpl我花了一些时间四处寻找解决方案,但似乎没有找到任何解决方案。这是我在处理程序中的验证代码    private void validateSignUpRequest(String phone) {    if(StringUtils.isEmpty(phone))        throw new BadRequestException("Phone Number can't be empty");}这是控制器@PostMapping(path = "/users/sign-up")public ResponseEntity<UserData> signUpUser(@RequestBody Users user) {    UserData userData = null;    HttpStatus httpStatus = null;    boolean flag = false;    try {        userData = userHandler.fetchByPhone(user.getPhoneNumber());        if (userData == null) {            flag = userHandler.saveUser(user);            httpStatus = HttpStatus.CREATED;        } else {            userData = UserData.failureResponse("User Already Exist");            httpStatus = HttpStatus.CONFLICT;        }    }catch(BadRequestException e) {        userData = UserData.failureResponse(e.getMessage());        httpStatus = HttpStatus.BAD_REQUEST;    }    catch (Exception e) {        userData = UserData.failureResponse(e.getMessage());        httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;    }    return new ResponseEntity<>(userData,httpStatus);}
查看完整描述

1 回答

?
四季花海

TA贡献1811条经验 获得超5个赞

此类https://github.com/jersey/jersey/blob/master/core-common/src/main/java/org/glassfish/jersey/internal/RuntimeDelegateImpl.java在 jersey-common 下。

你缺少jersey-common https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common

    <dependency>
       <groupId>org.glassfish.jersey.core</groupId>
       <artifactId>jersey-common</artifactId>
       <version>.....</version>
    </dependency>


查看完整回答
反对 回复 2023-02-23
  • 1 回答
  • 0 关注
  • 435 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信