title: POST: 500 Internal Server Error only in Chrome
body: <p>I have a Spring-Boot Backend Application and an Angular 2 Frontend-Application.
  Everytime when I try to post I get an <code>Internal Server Error 500</code>. This happens only in Chrome. All the get methods works absolutely fine. I don´t know where is the problem.</p>
  
  <p>http service in Angular:</p>
  
  <pre><code>addDomain(domainEntity:DomainEntity){
      let headers = new Headers({
          'Content-Type': 'application/json'
      });
      let options = new RequestOptions({
          headers: headers
      });
      let body = JSON.stringify(domainEntity)
  
      return this._http.post(this.baseURL+'addDomain', body, options);   
  }
  </code></pre>
  
  <p>Spring Boot UIRestController:</p>
  
  <pre><code>@RequestMapping(method=RequestMethod.POST, value= "/addDomain", produces="application/json")
      public DomainEntity addDomain(HttpServletRequest request, HttpServletResponse response, @RequestBody DomainEntity domain, Model model);
  </code></pre>
  
  <p>Service:</p>
  
  <pre><code>public DomainEntity addDomain(DomainEntity domain, Model model) {
      String url =  this.webServiceProperties.webUserBaseURL+"addDomain/";
  
      HttpHeaders headers = new HttpHeaders();   
      headers.setContentType(MediaType.APPLICATION_JSON);  
      HttpEntity&lt;DomainEntity&gt; entity = new HttpEntity&lt;DomainEntity&gt;(domain, headers); 
  
      try{
          RestTemplate restTemplate = new RestTemplate();
          ResponseEntity&lt;DomainEntity&gt; responseEntity= restTemplate.exchange(
                  UriComponentsBuilder.fromHttpUrl(url).build().encode().toUri(),
                  HttpMethod.POST, 
                  entity,
                  DomainEntity.class);
  
          return responseEntity.getBody();
      }catch(Exception e1){
          e1.printStackTrace();   
      }
  
      return null;
  }
  </code></pre>
  
  <p>Exception in chome console:</p>
  
  <pre><code>zone.js:101 POST http://myURL/addDomain 500 (Internal Server Error)scheduleTask @ zone.js:101ZoneDelegate.scheduleTask @ zone.js:336Zone.scheduleMacroTask @ zone.js:273(anonymous function) @ zone.js:122send @ VM54:3(anonymous function) @ http.umd.js:1327Observable.subscribe @ Observable.ts:93DomainListManagementComponent.addDomain @ domainListManagement.component.js:63_View_DomainListManagementComponent1._handle_click_72_0 @ DomainListManagementComponent.template.js:1046(anonymous function) @ core.umd.js:10111(anonymous function) @ platform-browser.umd.js:2088(anonymous function) @ platform-browser.umd.js:2260ZoneDelegate.invoke @ zone.js:323onInvoke @ core.umd.js:6075ZoneDelegate.invoke @ zone.js:322Zone.runGuarded @ zone.js:230NgZoneImpl.runInnerGuarded @ core.umd.js:6108NgZone.runGuarded @ core.umd.js:6335outsideHandler @ platform-browser.umd.js:2260ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256ZoneTask.invoke @ zone.js:423
  domainListManagement.component.js:63 
  Response {_body: "&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/7.0.65 - Error re…hade"&gt;&lt;h3&gt;Apache Tomcat/7.0.65&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;", status: 500, ok: false, statusText: "Ok", headers: Headers…}
  </code></pre>
  
  <p>I have taken a look at the tomcat log. But I still can´t understand why it only does not work in Chrome. Following Error I get in the tomcat log:</p>
  
  <pre><code>2016-08-17 15:10:01.706 ERROR 14157 --- [bio-8007-exec-1] o.s.boot.context.web.ErrorPageFilter     : Forwarding to error page from request [/admin-ui-service/addDomain] due to exception [null]
  
  java.lang.NullPointerException: null
      at org.springframework.web.util.WebUtils.isSameOrigin(WebUtils.java:816) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.cors.DefaultCorsProcessor.processRequest(DefaultCorsProcessor.java:76) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.servlet.handler.AbstractHandlerMapping$CorsInterceptor.preHandle(AbstractHandlerMapping.java:503) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:956) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) ~[tomcat-servlet-3.0-api.jar:na]
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) ~[tomcat-servlet-3.0-api.jar:na]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.65]
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat7-websocket.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.65]
      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.65]
      at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.65]
      at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.65]
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.65]
      at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.65]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.65]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) [catalina.jar:7.0.65]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.65]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) [catalina.jar:7.0.65]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) [catalina.jar:7.0.65]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.65]
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) [catalina.jar:7.0.65]
      at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:249) [catalina.jar:7.0.65]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.65]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) [catalina.jar:7.0.65]
      at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190) [tomcat-coyote.jar:7.0.65]
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) [tomcat-coyote.jar:7.0.65]
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.65]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_95]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_95]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.65]
      at java.lang.Thread.run(Thread.java:745) [na:1.7.0_95]
  </code></pre>