title: JAX RS Jersey + XML --> HTTP 400 Bad Request
body: <p>@Sikorski 
  /<em>This is my web.xml.</em>/</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;web-app version="3.0" 
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
  
   &lt;display-name&gt;Elite_Prepaid_New&lt;/display-name&gt; 
    &lt;servlet&gt;
  &lt;display-name&gt;JAX-RS REST Servlet&lt;/display-name&gt;
  &lt;servlet-name&gt;JAX-RS REST Servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;
      com.sun.jersey.spi.container.servlet.ServletContainer
  &lt;/servlet-class&gt;
   &lt;init-param&gt;
      &lt;param-name&gt;com.elite_prepaid_new.users&lt;/param-name&gt;
      &lt;param-value&gt;UsersResource&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;JAX-RS REST Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/services/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;welcome-file-list&gt;
  &lt;welcome-file&gt;UserRoles.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt; 
  &lt;/web-app&gt;
  </code></pre>
  
  <p>/<em>This is the server log of tomcat. But it didn't show me any error messges.</em>/</p>
  
  <pre><code>This is the log file from tomcat. But it didn't show me there's any error. 127.0.0.1 - - [15/Jul/2013:11:04:12 -0700] "GET /     HTTP/1.1" 404 951
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:11:04:12 -0700] "GET /Elite_Prepaid_New/ HTTP/1.1" 200 936
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:11:11:56 -0700] "POST /Elite_Prepaid_New/services/transactions/add HTTP/1.1" 400 990
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:13:56:10 -0700] "POST /Elite_Prepaid_New/services/transactions/add HTTP/1.1" 400 990
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:13:56:36 -0700] "POST /Elite_Prepaid_New/services/transactions/add HTTP/1.1" 400 990
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:14:06:36 -0700] "POST /Elite_Prepaid_New/services/transactions/add HTTP/1.1" 400 990
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:14:07:11 -0700] "GET /Elite_Prepaid_New/ HTTP/1.1" 200 936
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:14:07:14 -0700] "GET /Elite_Prepaid_New/ HTTP/1.1" 200 936
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:14:07:14 -0700] "GET /Elite_Prepaid_New/ HTTP/1.1" 200 936
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:14:07:14 -0700] "GET /Elite_Prepaid_New/ HTTP/1.1" 200 936
  0:0:0:0:0:0:0:1 - - [15/Jul/2013:14:07:59 -0700] "POST /Elite_Prepaid_New/services/transactions/add HTTP/1.1" 400 990
  </code></pre>
  
  <p>/<em>This is the updated question with the full stack trace from tomcat</em>/</p>
  
  <pre><code>Jul 15, 2013 11:04:03 AM org.apache.catalina.core.AprLifecycleListener init
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in     production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_09\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs;C:\Program Files\Java\jdk1.7.0_09\bin;C:\Users\Web Developer\AppData\Roaming\npm\;C:\Users\Web Developer\Desktop\eclipse;;.
  Jul 15, 2013 11:04:04 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Elite_Prepaid_New' did not find a matching property.
  Jul 15, 2013 11:04:04 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Restdemo' did not find a matching property.
  Jul 15, 2013 11:04:04 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8080"]
  Jul 15, 2013 11:04:04 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  Jul 15, 2013 11:04:04 AM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 1275 ms
  Jul 15, 2013 11:04:04 AM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Jul 15, 2013 11:04:04 AM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.41
  Jul 15, 2013 11:04:08 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:08 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:08 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:08 AM com.sun.jersey.api.core.servlet.WebAppResourceConfig init
  INFO: Scanning for root resource and provider classes in the Web app resource paths:
    /WEB-INF/lib
    /WEB-INF/classes
  Jul 15, 2013 11:04:08 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Root resource classes found:
    class com.myeclipseide.ws.CustomersResource
  Jul 15, 2013 11:04:08 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Provider classes found:
    class org.codehaus.jackson.jaxrs.JacksonJsonProvider
    class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
    class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
    class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
  Jul 15, 2013 11:04:08 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
  INFO: Initiating Jersey application, version 'Jersey: 1.14 09/09/2012 07:21 PM'
  Jul 15, 2013 11:04:10 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:10 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:10 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:10 AM com.sun.jersey.api.core.servlet.WebAppResourceConfig init
  INFO: Scanning for root resource and provider classes in the Web app resource paths:
  /WEB-INF/lib
  
   /WEB-INF/classes
  Jul 15, 2013 11:04:08 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Root resource classes found:
    class com.myeclipseide.ws.CustomersResource
  Jul 15, 2013 11:04:08 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Provider classes found:
    class org.codehaus.jackson.jaxrs.JacksonJsonProvider
    class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
    class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
    class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
  Jul 15, 2013 11:04:08 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
  INFO: Initiating Jersey application, version 'Jersey: 1.14 09/09/2012 07:21 PM'
  Jul 15, 2013 11:04:10 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:10 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:10 AM org.apache.catalina.startup.TaglibUriRule body
  INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
  Jul 15, 2013 11:04:10 AM com.sun.jersey.api.core.servlet.WebAppResourceConfig init
  INFO: Scanning for root resource and provider classes in the Web app resource paths:
    /WEB-INF/lib
    /WEB-INF/classes
  Jul 15, 2013 11:04:11 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Root resource classes found:
    class com.elite_prepaid_new.users.UsersResource
    class com.elite_prepaid_new.orders.OrdersResource
    class com.elite_prepaid_new.user_roles.UserRolesResource
    class com.elite_prepaid_new.items.ItemsResource
    class com.elite_prepaid_new.live.AddingTransResource
    class com.elite_prepaid_new.items.types.ItemsTypesResource
  Jul 15, 2013 11:04:11 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Provider classes found:
    class org.codehaus.jackson.jaxrs.JacksonJsonProvider
    class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
    class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
    class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
  Jul 15, 2013 11:04:11 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
  INFO: Initiating Jersey application, version 'Jersey: 1.14 09/09/2012 07:21 PM'
  Jul 15, 2013 11:04:11 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Jul 15, 2013 11:04:11 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Jul 15, 2013 11:04:11 AM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 7094 ms
  </code></pre>
  
  <p>I have one issue in sending the request xml from RestClient to Jax Rs.
  I accepted and saved this request with the bean which is a jaxb object.
  But, whenever I made a request, server returns HTTP 400 bad request.</p>
  
  <p>Here is my XML request.</p>
  
  <pre><code>&lt;trans&gt;
    &lt;rechargephone&gt;0990909&lt;/rechargephone&gt;
    &lt;phonetype&gt;GSM&lt;/phonetype&gt;
    &lt;amount&gt;10000&lt;/amount&gt;
    &lt;useracctid&gt;10100100&lt;/useracctid&gt;
    &lt;userpin&gt;111&lt;/userpin&gt;
    &lt;quantity&gt;1&lt;/quantity&gt;
  &lt;/trans&gt;
  </code></pre>
  
  <p>And here is my resource method</p>
  
  <pre><code>public class AddingTransResource {
  
  @POST
  @Path("add")
  @Consumes("application/xml")
  public Message add(Trans trans) {
  
      Trans transaction = new Trans();
  </code></pre>
  
  <p>The method <code>add</code> is accepting the XML parameter with the JAXB object, in here, which is <code>Trans</code> and it is also the root element of this XML.</p>
  
  <p>Below is my JAXB object:</p>
  
  <pre><code>@XmlRootElement
  public class Trans {
  
  private String rechargephone;
  private String phonetype;
  private String amount;
  private String useracctid;
  private String userpin;
  private int quantity;
  
  public String getRechargephone() {
      return rechargephone;
  }
  public void setRechargephone(String rechargephone) {
      this.rechargephone = rechargephone;
  }
  </code></pre>
  
  <p>And the way that i'm creating the JAXB object is just creating a Java bean with <code>@XmlRootElement</code>.</p>
  
  <p>Can anyone suggest me please how to fix it and any idea on creating the JAXB object?</p>