Error No 'Access-Control-Allow-Origin' header is present on the requested resource [The server responded with...












0















I using Java 8 + Spring framework 4.1.x and Tomcat 8
IP Server 10.1.3.193.
When calling service from link http://10.1.3.193:8080/HRMS/index2.html success,
but calling from http: //localhost:8080/HRMS/index2.html error Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



Or I'm running another tomcat on the 10.1.3.194 machine
Call http://10.1.3.194:8080/HRMS/index2.html ERROR Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://10.1.3.194:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



File html call web service index2.html



function getData(){
$.ajax({
url: 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/',
type: 'GET',
dataType: 'json',
contentType: 'application/json',
mimeType: 'json',
headers: {'Authorization': 'Basic ZHVuZ3FuOjEyMw=='},
success: function(data) {
alert('thanh cong');
},
error:function(data,status,er) {
alert('error: ');
}
});
}


File config web.xml



<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<async-supported>true</async-supported>

<init-param>
<param-name>cors.allowGenericHttpRequests</param-name>
<param-value>true</param-value>
</init-param>

<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>

<init-param>
<param-name>cors.allowSubdomains</param-name>
<param-value>false</param-value>
</init-param>

<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, DELETE, OPTIONS</param-value>
</init-param>

<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>Accept, Authorization, Origin, Content-Type, X-Requested-With</param-value>
<!-- <param-value>*</param-value> -->
</init-param>

<init-param>
<param-name>cors.supportsCredentials</param-name>
<param-value>true</param-value>
</init-param>

<init-param>
<param-name>cors.maxAge</param-name>
<param-value>3600</param-value>
</init-param>

</filter>

<filter-mapping>
<!-- CORS Filter mapping -->
<filter-name>CORS</filter-name>
<!-- <url-pattern>*</url-pattern> -->
<url-pattern>/remoting/*</url-pattern>
</filter-mapping>


OR web.xml



<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>If-Mofidied-Since,Range,Origin,Authorization,accept</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


With 2 web.xml files when calling web service is error. I did not figure out the cause and fix the error. please help. Thanks










share|improve this question





























    0















    I using Java 8 + Spring framework 4.1.x and Tomcat 8
    IP Server 10.1.3.193.
    When calling service from link http://10.1.3.193:8080/HRMS/index2.html success,
    but calling from http: //localhost:8080/HRMS/index2.html error Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



    Or I'm running another tomcat on the 10.1.3.194 machine
    Call http://10.1.3.194:8080/HRMS/index2.html ERROR Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://10.1.3.194:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



    File html call web service index2.html



    function getData(){
    $.ajax({
    url: 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/',
    type: 'GET',
    dataType: 'json',
    contentType: 'application/json',
    mimeType: 'json',
    headers: {'Authorization': 'Basic ZHVuZ3FuOjEyMw=='},
    success: function(data) {
    alert('thanh cong');
    },
    error:function(data,status,er) {
    alert('error: ');
    }
    });
    }


    File config web.xml



    <filter>
    <filter-name>CORS</filter-name>
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
    <async-supported>true</async-supported>

    <init-param>
    <param-name>cors.allowGenericHttpRequests</param-name>
    <param-value>true</param-value>
    </init-param>

    <init-param>
    <param-name>cors.allowOrigin</param-name>
    <param-value>*</param-value>
    </init-param>

    <init-param>
    <param-name>cors.allowSubdomains</param-name>
    <param-value>false</param-value>
    </init-param>

    <init-param>
    <param-name>cors.supportedMethods</param-name>
    <param-value>GET, HEAD, POST, DELETE, OPTIONS</param-value>
    </init-param>

    <init-param>
    <param-name>cors.supportedHeaders</param-name>
    <param-value>Accept, Authorization, Origin, Content-Type, X-Requested-With</param-value>
    <!-- <param-value>*</param-value> -->
    </init-param>

    <init-param>
    <param-name>cors.supportsCredentials</param-name>
    <param-value>true</param-value>
    </init-param>

    <init-param>
    <param-name>cors.maxAge</param-name>
    <param-value>3600</param-value>
    </init-param>

    </filter>

    <filter-mapping>
    <!-- CORS Filter mapping -->
    <filter-name>CORS</filter-name>
    <!-- <url-pattern>*</url-pattern> -->
    <url-pattern>/remoting/*</url-pattern>
    </filter-mapping>


    OR web.xml



    <filter>
    <filter-name>CorsFilter</filter-name>
    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
    <init-param>
    <param-name>cors.allowed.origins</param-name>
    <param-value>*</param-value>
    </init-param>
    <init-param>
    <param-name>cors.allowed.headers</param-name>
    <param-value>If-Mofidied-Since,Range,Origin,Authorization,accept</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>CorsFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>


    With 2 web.xml files when calling web service is error. I did not figure out the cause and fix the error. please help. Thanks










    share|improve this question



























      0












      0








      0








      I using Java 8 + Spring framework 4.1.x and Tomcat 8
      IP Server 10.1.3.193.
      When calling service from link http://10.1.3.193:8080/HRMS/index2.html success,
      but calling from http: //localhost:8080/HRMS/index2.html error Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



      Or I'm running another tomcat on the 10.1.3.194 machine
      Call http://10.1.3.194:8080/HRMS/index2.html ERROR Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://10.1.3.194:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



      File html call web service index2.html



      function getData(){
      $.ajax({
      url: 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/',
      type: 'GET',
      dataType: 'json',
      contentType: 'application/json',
      mimeType: 'json',
      headers: {'Authorization': 'Basic ZHVuZ3FuOjEyMw=='},
      success: function(data) {
      alert('thanh cong');
      },
      error:function(data,status,er) {
      alert('error: ');
      }
      });
      }


      File config web.xml



      <filter>
      <filter-name>CORS</filter-name>
      <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
      <async-supported>true</async-supported>

      <init-param>
      <param-name>cors.allowGenericHttpRequests</param-name>
      <param-value>true</param-value>
      </init-param>

      <init-param>
      <param-name>cors.allowOrigin</param-name>
      <param-value>*</param-value>
      </init-param>

      <init-param>
      <param-name>cors.allowSubdomains</param-name>
      <param-value>false</param-value>
      </init-param>

      <init-param>
      <param-name>cors.supportedMethods</param-name>
      <param-value>GET, HEAD, POST, DELETE, OPTIONS</param-value>
      </init-param>

      <init-param>
      <param-name>cors.supportedHeaders</param-name>
      <param-value>Accept, Authorization, Origin, Content-Type, X-Requested-With</param-value>
      <!-- <param-value>*</param-value> -->
      </init-param>

      <init-param>
      <param-name>cors.supportsCredentials</param-name>
      <param-value>true</param-value>
      </init-param>

      <init-param>
      <param-name>cors.maxAge</param-name>
      <param-value>3600</param-value>
      </init-param>

      </filter>

      <filter-mapping>
      <!-- CORS Filter mapping -->
      <filter-name>CORS</filter-name>
      <!-- <url-pattern>*</url-pattern> -->
      <url-pattern>/remoting/*</url-pattern>
      </filter-mapping>


      OR web.xml



      <filter>
      <filter-name>CorsFilter</filter-name>
      <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
      <init-param>
      <param-name>cors.allowed.origins</param-name>
      <param-value>*</param-value>
      </init-param>
      <init-param>
      <param-name>cors.allowed.headers</param-name>
      <param-value>If-Mofidied-Since,Range,Origin,Authorization,accept</param-value>
      </init-param>
      </filter>
      <filter-mapping>
      <filter-name>CorsFilter</filter-name>
      <url-pattern>/*</url-pattern>
      </filter-mapping>


      With 2 web.xml files when calling web service is error. I did not figure out the cause and fix the error. please help. Thanks










      share|improve this question
















      I using Java 8 + Spring framework 4.1.x and Tomcat 8
      IP Server 10.1.3.193.
      When calling service from link http://10.1.3.193:8080/HRMS/index2.html success,
      but calling from http: //localhost:8080/HRMS/index2.html error Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



      Or I'm running another tomcat on the 10.1.3.194 machine
      Call http://10.1.3.194:8080/HRMS/index2.html ERROR Access to XMLHttpRequest at 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/' from origin 'http://10.1.3.194:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.



      File html call web service index2.html



      function getData(){
      $.ajax({
      url: 'http://10.1.3.193:8080/HRMS/remoting/kpidataWQA/dsDonVi/',
      type: 'GET',
      dataType: 'json',
      contentType: 'application/json',
      mimeType: 'json',
      headers: {'Authorization': 'Basic ZHVuZ3FuOjEyMw=='},
      success: function(data) {
      alert('thanh cong');
      },
      error:function(data,status,er) {
      alert('error: ');
      }
      });
      }


      File config web.xml



      <filter>
      <filter-name>CORS</filter-name>
      <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
      <async-supported>true</async-supported>

      <init-param>
      <param-name>cors.allowGenericHttpRequests</param-name>
      <param-value>true</param-value>
      </init-param>

      <init-param>
      <param-name>cors.allowOrigin</param-name>
      <param-value>*</param-value>
      </init-param>

      <init-param>
      <param-name>cors.allowSubdomains</param-name>
      <param-value>false</param-value>
      </init-param>

      <init-param>
      <param-name>cors.supportedMethods</param-name>
      <param-value>GET, HEAD, POST, DELETE, OPTIONS</param-value>
      </init-param>

      <init-param>
      <param-name>cors.supportedHeaders</param-name>
      <param-value>Accept, Authorization, Origin, Content-Type, X-Requested-With</param-value>
      <!-- <param-value>*</param-value> -->
      </init-param>

      <init-param>
      <param-name>cors.supportsCredentials</param-name>
      <param-value>true</param-value>
      </init-param>

      <init-param>
      <param-name>cors.maxAge</param-name>
      <param-value>3600</param-value>
      </init-param>

      </filter>

      <filter-mapping>
      <!-- CORS Filter mapping -->
      <filter-name>CORS</filter-name>
      <!-- <url-pattern>*</url-pattern> -->
      <url-pattern>/remoting/*</url-pattern>
      </filter-mapping>


      OR web.xml



      <filter>
      <filter-name>CorsFilter</filter-name>
      <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
      <init-param>
      <param-name>cors.allowed.origins</param-name>
      <param-value>*</param-value>
      </init-param>
      <init-param>
      <param-name>cors.allowed.headers</param-name>
      <param-value>If-Mofidied-Since,Range,Origin,Authorization,accept</param-value>
      </init-param>
      </filter>
      <filter-mapping>
      <filter-name>CorsFilter</filter-name>
      <url-pattern>/*</url-pattern>
      </filter-mapping>


      With 2 web.xml files when calling web service is error. I did not figure out the cause and fix the error. please help. Thanks







      javascript java spring tomcat






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 28 '18 at 5:12







      user1550956

















      asked Nov 27 '18 at 3:34









      user1550956user1550956

      43127




      43127
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53492346%2ferror-no-access-control-allow-origin-header-is-present-on-the-requested-resour%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53492346%2ferror-no-access-control-allow-origin-header-is-present-on-the-requested-resour%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks