Cant load WMS layer with Spring Boot backend, React frontend

649
5
09-20-2021 09:47 AM
ironmaskito
New Contributor III

Hi all, we recently wrapped our react code in a spring boot application deployed locally and now are unable to load WMS layer using a url to a publicly available WMS resource ("https://nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WMSServ...").

The error I'm getting in devtools looks like this: 

: [esri.layers.WMSLayer] #load() Failed to load layer (title: 'Samples', id: '17c03f8411d-layer-2')

I don't think it is a CORS issue because I am able to see a successful GET request in my devtools containing the WMS data. I've also enabled cross origin requests in the application as well as enabled CORS using browser extension. The code the error originates from: 

    let wmsOptions = {
      customParameters: message.params,
      title: message.name || message.featureId,
      url: url,
    };
    let wmsLayer = new WMSLayer(wmsOptions);
 
I confirmed wms layer loads successfully before transitioning to Spring. 
Tags (2)
0 Kudos
5 Replies
AndyGup
Esri Regular Contributor

Hi@ironmaskito since the app works without Spring, it's reasonable to believe that Spring is causing the problem and not the ArcGIS JS API. I was also able to verify the NOAA WMS layer works okay in a vanilla JS app without a CORS browser extension or a proxy. 

My recommended next step in these situations is for you to compare HTTP headers and payload (attributes + data) between the app that's working and app that is not working. I'm not aware of any other definitive way to figure out how the HTTP requests/response is being affected. As an example, we've seen similar cases where the wrapper framework was triggering pre-flight, and that would cause the HTTP requests to fail.

0 Kudos
ironmaskito
New Contributor III

Thank you. I've compared the headers and response and they are identical. Only difference I've noticed is the call stack of the request is different apart from the circled section, though I can't understand why

similarities.png

0 Kudos
AndyGup
Esri Regular Contributor

@ironmaskitocan you clarify if you are using AMD or ESM? One likely culprit is downleveling of async/await but we don't do that in our ESM build.

Also, just to clarify: are you using the Spring/Java Enterprise framework? Just want to make sure we aren't talking about some other Spring. We are trying to figure out why there are babel-like asyncToGenerator calls in the Spring screenshot.

0 Kudos
ironmaskito
New Contributor III

Sorry I should have clarified. We are using  Java Spring Boot with Spring Boot Starter Web. The front-end and back-end are running on the same port on a local machine. We are using the ESM build of arcgis version 4.20.2

0 Kudos
ironmaskito
New Contributor III

The problem appears to be introduced by a change in the build process when moving from react's development server to react's production environment and nothing to do with the spring framework. Will let you know when we are able to find the problem.

0 Kudos