0

I posted this question yesterday, and that was solved. It's now seeing the values from the Rest client; however, it always return 500 internal server error and NullPointerException for all the calls I have made. What can I do to get past this?

Error

web - 2019-09-29 14:36:11,814 [http-nio-8081-exec-1] DEBUG o.b.w.c.RegistrationController - Registering user account with information: UserDto [firstName=Kehinde, lastName=Adeoya, username=ken4ward, password=o201115@...Adel, matchingPassword=o201115@...Adel, email=kadeoya@oltega.com, isUsing2FA=false, role=ROLE_ADMIN]
web - 2019-09-29 14:36:11,823 [http-nio-8081-exec-1] ERROR o.b.w.c.e.RestResponseEntityExceptionHandler - 500 Status Code
j.l.NullPointerException: null
    at o.b.s.UserService.save(UserService.java:81)
    at o.b.w.c.RegistrationController.registerUserAccount(RegistrationController.java:86)
    at j.i.r.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
    at j.i.r.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at j.i.r.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    ... 75 frames truncated

This is what I sent from the Rest client:

{
    "firstName": "Kehinde",
    "lastName": "Adeoya",
    "username": "ken4ward",
    "email": "kadeoya@oltega.com",
    "password": "o201115@Adel",
    "matchingPassword": "o201115@Adel",
    "statusName": "ROLE_ADMIN"
}

This is the service layer at which it returns violation error (UserService)

public User save(UserDto user) {
            Set<ConstraintViolation<UserDto>> violations = validator.validate(user);
            if (violations.size() > 0) {
                throw new BadRequestException();
            }
............

This is the controller

@RequestMapping(value = "/registration", method = RequestMethod.POST )
    @ResponseBody
    public User registerUserAccount(final UserDto accountDto, final HttpServletRequest request) {
        final User registered = userInterface.save(accountDto);
        eventPublisher.publishEvent(new OnRegistrationCompleteEvent(registered, request.getLocale(), getAppUrl(request)));
        return registered;
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
ken4ward
  • 2,246
  • 5
  • 49
  • 89
  • what line is (UserService.java:81)? – pL4Gu33 Sep 29 '19 at 17:29
  • It is on the constraint validation line - ``` Set> violations = validator.validate(user);``` – ken4ward Sep 29 '19 at 22:04
  • Is `validator` null? – mvmn Sep 29 '19 at 22:28
  • I think that is what the error is reading but I’m seeing the values passed when the userDto is logged – ken4ward Sep 29 '19 at 22:37
  • In your old thread you have the same exception anyway?.... can you please check your validator with debugging or a simple system.out.... i think when it is really this line there are not many other options. Or can you show us the whole userservice class. – pL4Gu33 Sep 30 '19 at 17:47

0 Answers0