When trying to access the repository com.sun.faces.context.AjaxExceptionHandlerImpl handlePartialResponseError

1

Well, I'm having a problem here, and I can not solve it. I already searched the forums, but I also did not see any solutions. Does anyone give this help please?

The error happens when I try to save the form with the user data. I thought I could be sending the null user object, but I have already verified that it is not this.

I have checked many times to see if I have not forgotten to initialize some instance or object variable, but I did not find anything wrong either.

Stracktrace indicates that the error is at line 27, in the call serviceUser.addUser (user);

Caused by: java.lang.NullPointerException
    at br.com.jamming.controller.RegisterUserMB.save(RegisterUserMB.java:27)

Does anyone know what can be happening? Thanks in advance for your availability.

MagagedBean:

@ManagedBean
@RequestScope
public class RegisterUserMB {

    @Autowired
    private UserService userService;

    private User user = new User();

    private String confirmPw;

    public String save() {
        userService.addUser(user);
        return "";          
    }

Service:

@Service
public class UserService {

    @Autowired
    UserRepository<User> userRepository;

    @Transactional
    public boolean addUser(User user) {
        return userRepository.save(user) != null;
    }

Repository:

public interface UserRepository<U> extends CrudRepository<User, Long> {


}

xhtml:

<h:form>
                    <h:panelGrid columns="2" style="border:none">
                        <p:inputText id="name" value="#{registerUserMB.profileUser.name}" placeholder="Name"  /> 
                        <p:inputText id="surname" value="#{registerUserMB.profileUser.surname}" placeholder="Surname" />
                    </h:panelGrid>
                    <h:panelGrid>
                        <p:inputText id="mail" value="#{registerUserMB.user.mail}" placeholder="E-mail" size="46" />    
                    </h:panelGrid>
                    <h:panelGrid columns="2">
                        <p:password id="password" value="#{registerUserMB.user.password}" feedback="true" inline="true" placeholder="Password" match="PasswordConf" />
                        <p:password id="PasswordConf" value="#{registerUserMB.confirmPw}"  placeholder="Password confirmation"/>
                        <p:calendar id="brithday" value="#{registerUserMB.profileUser.dateOfBrithday}" placeholder="Brithday" /><h:outputLabel value="" />
                        <p:inputText id="cellphone" value="#{registerUserMB.user.cellphone}" placeholder="Cellphone"/>
                    </h:panelGrid>
                    <p:commandButton value="Save" actionListener="#{registerUserMB.save}"/>
                    </h:form>

Thank you !!

    
asked by anonymous 14.08.2018 / 20:13

0 answers