I have this problem in my code, where I cannot submit a signup form in jsp. Here are the code intervening in the signup operation.

User.java

@Entity 
@Table(name = "user", catalog = "spring_abc", uniqueConstraints = {@UniqueConstraint(columnNames = "email"),
 @UniqueConstraint(columnNames = "username")})
 public class User implements java.io.Serializable {

public static final String ROLE_ADMIN = "admin";
public static final String ROLE_MEMBER = "member";


private static final long serialVersionUID = 7376961072110620611L;
private Integer id;
private Long commentCount;
private Date createAt;
private String description;
@Email(message = "Entrez le format de l'email correct")
private String email;

private long number;

private String password;

public void setDepartement(String departement) {
    this.departement = departement;
}

private long points;

private String role;

@Size(max = 60, message = "Pas plus de soixante caractères")
private String signature;

private Long topicCount;

@Size(max = 60, message = "Pas plus de soixante caractères")
private String twitter;

private Date updateAt;

@Pattern(regexp = "^(?!_)(?!.*?_$)[A-Za-z0-9|_]{3,9}", message = "Nom d'utilisateur, ne peut pas commencer ou se terminer par un trait de soulignement")
private String username;

private Set<Follow> followsForFollowerId = new HashSet<Follow>(0);
private Set<Notification> notifications = new HashSet<Notification>(0);
private Set<Topic> topics = new HashSet<Topic>(0);
private Set<Comment> comments = new HashSet<Comment>(0);
private Set<Focus> focuses = new HashSet<Focus>(0);
private Set<Collection> collections = new HashSet<Collection>(0);
private Set<Follow> followsForFollowingId = new HashSet<Follow>(0);
private Set<Comment> likeComments = new HashSet<Comment>();

The methode signup the service Part.

@Transactional
public User signup(User user, String password1, Errors errors) {
    if (errors.hasErrors()) {
        return null;
    }
    String username = user.getUsername();
    String password = user.getPassword();
    String email = user.getEmail();

    if (userRepo.findOneByUsername(username) != null) {
        errors.rejectValue("username", "username", "Nom d'utilisateur déjà enregistré");
    } else if (userRepo.findOneByEmail(email) != null) {
        errors.rejectValue("email", "email", "E-mail est déjà enregistré");
    } else if (!password.equals(password1)) {
        errors.rejectValue("password", "password", "Les mots de passe ne se correspondent pas");
    }
    if (errors.hasErrors()) {
        return null;
    }

    user.setPassword(EncryptUtil.encryptUsernameAndPassword(username, password));

    user.setCreateAt(new Date());
    return userRepo.save(user);
}

Controller Account.java

@RequestMapping(value = "/signup", method = RequestMethod.POST)
public String singupAction(@Validated User user,
                           Errors erros,
                           String password1,
                           RedirectAttributes attributese,
                           HttpServletRequest request) {
    User signinUser = userServ.signup(user, password1, erros);

    if (erros.hasErrors()) {
        attributese.addFlashAttribute("user", user);
        attributese.addFlashAttribute("error", erros.getAllErrors());
        return "redirect:/account/signup";
    }


    request.getSession().setAttribute("user", signinUser);
    attributese.addFlashAttribute("msg", "Vous êtes inscrit avec succès");

    return "redirect:/";
} 

Signup.jsp, The problem appears when i try to validate information.

<form action="${x}/account/signup" data-toggle="validator" role="form" method="POST">
<input class="form-control" data-error="S'il vous plaît entrer une adresse email valide" placeholder="E-mail" type="email" id="email" name="email" value="${user.email}" />
 <input class="form-control" id="username" data-error="Entre 6 et 18 caractères" pattern="^[_A-z0-9]{6,18}$" placeholder="Votre username" type="text" name="username" value="${user.username}"   />
 <input class="form-control" data-minlength="6" type="password" name="password" id="password" placeholder="Mot de passe" data-error="Entre 6 et 18 caractères" />
 <input type="submit" class="btn btn-info btn-block" value="S'inscrire">

The stack I'm getting doesn't make any sense to me. It doesn't point out the problem

org.apache.jasper.JasperException: javax.el.ELException: java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public"
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)

Caused by: javax.el.ELException: java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public"
at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:742)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:470)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257)
1

There are 1 answers

1
ScanQR On

You need to add getters and setters in your entity for each field.

e.g. private long number;

Should have defined following in your entity.

public long getNumber(){ return this.number;}
public void setNumber(long number){ this.number = number; }

from your stacktrace it is clear that it is trying to access fields with public getter method but it couldn't find it so thrown exception.