title: JBoss Login Web Application error - Failed to parse request.: java.lang.IllegalArgumentException: Illegal character in query
body: <p>I'm trying to develop a login system, and I've followed Ticketmonster's structure. The menu container in main.html will be filled in only after log-in, and the content is filled with the login template, where the router immediately renders the login view, and the template is applied. Upon Clicking the sign in button, an Ajax request is created and sent to its service.</p>
  
  <ul>
  <li>This is the login function in the login view:</li>
  </ul>
  
  <p>` </p>
  
  <pre><code>login:function(){
  
    var username = $("#username");
    var password = $("#password");
  
    var userLoginRequest = {username:username.val(), password:password.val()};
  
    $.ajax({url: (config.baseUrl + "rest/users"),
            data:JSON.stringify(userLoginRequest),
            type:"GET",
            dataType:"json",
            contentType:"application/json",
            success:function (userId) {
              alert(userId);
            }}).error(function (error) {
      if (error.status == 400 || error.status == 409) {
        var errors = $.parseJSON(error.responseText).errors;
        _.each(errors, function (errorMessage) {
          $("#error").empty().append(errorMessage);
        });
      } else {
        $("#error").empty().append("An error has occurred!");
      }
    });
  
  }
  </code></pre>
  
  <ul>
  <li>This is the service. Changing to @Consumes leads to the same outcome.</li>
  </ul>
  
  <p>` </p>
  
  <pre><code>@GET
  @Produces(MediaType.APPLICATION_JSON)
  public Response authenticateUser(UserLoginRequest userLoginRequest){
    User user = serviceUtility.getUserFromUsername(userLoginRequest.getUsername());
  
    if (user == null){
      return serviceUtility.badRequestResponse("No users with this username exist!");
    } else if (!user.getPassword().equals(userLoginRequest.getPassword())) {
      return serviceUtility.badRequestResponse("Incorrect Password!");
    } else {
      return Response.ok().entity(user.getId()).type(MediaType.APPLICATION_JSON_TYPE).build();
    }
  }
  </code></pre>
  
  <ul>
  <li>This is the server error. Upon some research, I thought may be it's
  an escape string issue, but I don't see that applied in TicketMonster
  code, or discussed in the tutorial.</li>
  </ul>
  
  <p>WARN  [org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher] (http-localhost/127.0.0.1:8180-6) Failed to parse request.: java.lang.IllegalArgumentException: Illegal character in query at index 38: localhost:8180/MCC2/rest/users?{%22username%22:%22wakas%22,%22password%22:%22Password%22}&amp;_=1426754780833
      at java.net.URI.create(URI.java:859) [rt.jar:1.7.0_03]
      ...</p>
  
  <ul>
  <li>This is the error on Firebug</li>
  </ul>
  
  <p>GET localhost:8180/MCC2/rest/users?{%22usernam...2,%22password%22:%22Password%22}&amp;<em>=1426757495550
  400 Bad Request
  19ms<br>
  jquery-2.0.3.js (line 7845)
  "NetworkError: 400 Bad Request - localhost:8180/MCC2/rest/users?{%22username%22:%22User%20Name%22,%22password%22:%22Password%22}&amp;</em>=1426757495550"
  users?{...7495550
  SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data login.js (line 49, col 41)
  var errors = $.parseJSON(error.responseText).errors;</p>
  
  <ul>
  <li>Switching the Ajax request's type, and the annotation on the service
  to POST, gives no error on server, but the following error in Firebug.</li>
  </ul>
  
  <p>POST localhost:8180/MCC2/rest/users
  405 Method Not Allowed
  8ms 
  jquery-2.0.3.js (line 7845)
  "NetworkError: 405 Method Not Allowed - localhost:8180/MCC2/rest/users"</p>
  
  <ul>
  <li>I've placed a break point at the start of the service, and in all
  cases, the service is never entered.</li>
  </ul>
  
  <p><strong>Update:</strong>
  Although I wrote this post with the GET request, I feel it should be a POST request, in which case the issue would be the reason for the Firebug error.</p>
  
  <p>Also, I'm getting the following error when deploying my Application:
  Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: User, for columns: [org.hibernate.mapping.Column(userListIds)]</p>
  
  <p>Here is User (exclusing the setters and getters):</p>
  
  <p>` </p>
  
  <pre><code>@SuppressWarnings("serial")
  @Entity
  public class User implements Serializable {
  
  @Id
  @GeneratedValue
  private Long id;
  
  @NotNull
  @Size(min = 5, max = 16)
  @Pattern(regexp = "[a-zA-Z0-9_]*", message = "Must only contain small and capital letters, numbers, and underscore!")
  @Column(unique=true)
  private String username;
  
  @NotNull
  @Size(min = 5, max = 16)
  private String password;
  
  @NotNull
  @Size(min = 1, max = 25)
  @Pattern(regexp = "[^0-9]*", message = "Must not contain numbers")
  private String firstName;
  
  @NotNull
  @Size(min = 1, max = 25)
  @Pattern(regexp = "[^0-9]*", message = "Must not contain numbers")
  private String lastName;
  
  @NotNull
  @Column(unique = true)
  @NotEmpty
  @Email(message = "Not a valid email format")
  private String email;
  
  @Size(min = 10, max = 12)
  @Digits(fraction = 0, integer = 12)
  private String phoneNumber;
  
  @Size(min = 1, max = 300)
  private String description;
  
  //  @NotNull &lt;--commented since we don't have a setter
  private Date creationDate = new Date();
  
  @NotNull
  private Role role = Role.MEMBER;
  
  @NotNull
  private boolean enabled = true;
  
  private Set&lt;Long&gt; userListIds = new HashSet&lt;Long&gt;();
  
  public void addUserToUserlist(Long newUserId){
      userListIds.add(newUserId);
  }
  
  public void removeUserFromUserlist(Long newUserId){
      userListIds.remove(newUserId);
  }
  
  public Set&lt;Long&gt; getUserListIds() {
      return userListIds;
  }
  
  public void setUserListIds(Set&lt;Long&gt; userListIds) {
      this.userListIds = userListIds;
  }
  
  public String getUsername() {
      return username;
  }
  
  public void setUsername(String username) {
      this.username = username;
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public String getDescription() {
      return description;
  }
  
  public void setDescription(String description) {
      this.description = description;
  }
  
  public Date getCreationDate() {
      return creationDate;
  }
  
  //  public void setCreationDate(Date creationDate) {
  //      this.creationDate = creationDate;
  //  }
  
  public Role getRole() {
      return role;
  }
  
  public void setRole(Role role) {
      this.role = role;
  }
  
  public boolean isEnabled() {
      return enabled;
  }
  
  public void setEnabled(boolean enabled) {
      this.enabled = enabled;
  }
  
  public Long getId() {
      return id;
  }
  
  public void setId(Long id) {
      this.id = id;
  }
  
  public String getFirstName() {
      return firstName;
  }
  
  public void setFirstName(String name) {
      this.firstName = name;
  }
  
  public String getLastName() {
      return lastName;
  }
  
  public void setLastName(String lastName) {
      this.lastName = lastName;
  }
  
  public String getEmail() {
      return email;
  }
  
  public void setEmail(String email) {
      this.email = email;
  }
  
  public String getPhoneNumber() {
      return phoneNumber;
  }
  
  public void setPhoneNumber(String phoneNumber) {
      this.phoneNumber = phoneNumber;
  }
  
  @Override
  public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((id == null) ? 0 : id.hashCode());
      return result;
  }
  
  @Override
  public boolean equals(Object obj) {
      if (this == obj)
          return true;
      if (obj == null)
          return false;
      if (getClass() != obj.getClass())
          return false;
      User other = (User) obj;
      if (id == null) {
          if (other.id != null)
              return false;
      } else if (!id.equals(other.id))
          return false;
      return true;
  }
  
  @Override
  public String toString() {
      return "User [username=" + username + ", firstName=" + firstName
              + ", lastName=" + lastName + ", email=" + email
              + ", phoneNumber=" + phoneNumber + ", creationDate="
              + creationDate + ", role=" + role + ", enabled=" + enabled
              + "]";
  }
  
  }
  </code></pre>