title: Cookies.get('XSRF-TOKEN') returns undefined (spring web jars)
body: <p>I have following thymeleaf page:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" ng-app="springChat" xmlns:th="http://www.springframework.org/schema/beans"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"/&gt;
      &lt;title&gt;Spring WebSocket Chat&lt;/title&gt;
      &lt;script type="text/javascript" src="/webjars/js-cookie/js.cookie.js"&gt;&lt;/script&gt;
      &lt;script src="/webjars/jquery/jquery.min.js"&gt;&lt;/script&gt;
  
      &lt;meta name="_csrf" th:content="${_csrf.token}"/&gt;
      &lt;meta name="_csrf_header" th:content="${_csrf.headerName}"/&gt;
      &lt;meta name="_csrf_parameter_name" th:content="${_csrf.parameterName}"/&gt;
  &lt;/head
  .....
  </code></pre>
  
  <p>and to this page I attached the following js:</p>
  
  <pre><code>function connect() {
      var socket = new SockJS('/gs-guide-websocket');
      stompClient = Stomp.over(socket);
  
      var token = $("meta[name='_csrf']").attr("content");
      var paramName = $("meta[name='_csrf_parameter_name']").attr("content");
      var csrfHeader = $("meta[name='_csrf_header']").attr("content");
  
      //$('&lt;input&gt;').attr('type', 'hidden').attr('name', csrfHeader).attr('value', token).appendTo('#login-form');
      var headers = {};
      headers[csrfHeader] = token;
  
      stompClient.connect(headers, function (frame) {...));
  
  }
  </code></pre>
  
  <p>It works fine. I see that it sends csrf token to the server.</p>
  
  <p>When I read <a href="https://spring.io/guides/tutorials/spring-boot-oauth2/" rel="nofollow noreferrer">spring tutorial</a> I've found interesting feature in new spring:</p>
  
  <p>if to add <code>&lt;script type="text/javascript" src="/webjars/js-cookie/js.cookie.js"&gt;&lt;/script&gt;</code> on the page you can use the following line to retrieve the token:</p>
  
  <pre><code>Cookies.get('XSRF-TOKEN')
  </code></pre>
  
  <p>It contains in the dependency:</p>
  
  <pre><code>compile("org.webjars:js-cookie:2.1.0")
  </code></pre>
  
  <p>So I've added it and wrote following code:</p>
  
  <pre><code>function connect() {
      var socket = new SockJS('/gs-guide-websocket');
      stompClient = Stomp.over(socket);
  
      var headers = {};
      headers["X-XSRF-TOKEN"] = Cookies.get('XSRF-TOKEN');
  
      stompClient.connect(headers, function (frame) {...));
  
  }
  </code></pre>
  
  <p>browser console:</p>
  
  <pre><code>Opening Web Socket...
  stomp.min.js:8 Web Socket Opened...
  stomp.min.js:8 &gt;&gt;&gt; CONNECT
  X-XSRF-TOKEN:undefined
  accept-version:1.1,1.0
  heart-beat:10000,10000
  
  &lt;&lt;&lt; ERROR
  message:Failed to send message to ExecutorSubscribableChannel[clientInboundChannel]; nested exception is org.springframework.security.web.csrf.InvalidCsrfTokenException\c Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.
  content-length:0
  </code></pre>
  
  <h2>build.gradle:</h2>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  
  jar {
      baseName = 'gs-messaging-stomp-websocket'
      version = '0.1.0'
  }
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile("org.springframework.boot:spring-boot-starter-websocket")
      compile("org.webjars:webjars-locator-core")
      compile("org.webjars:sockjs-client:1.0.2")
      compile("org.webjars:stomp-websocket:2.3.3")
      compile("org.webjars:bootstrap:3.3.7")
      compile("org.webjars:jquery:3.1.0")
      compile("org.webjars:js-cookie:2.1.0")
      compile('org.thymeleaf:thymeleaf-spring5');
  
      compile("org.springframework.boot:spring-boot-starter-actuator")
      //security
      compile ('org.springframework.security:spring-security-messaging')
      compile group: 'org.springframework.security', name: 'spring-security-web'
      compile group: 'org.springframework.security', name: 'spring-security-config'
  
      testCompile("org.springframework.boot:spring-boot-starter-test")
  }
  </code></pre>
  
  <p>Why this doesn't work properly?</p>