I have shapefiles in my resources directory and see them in the jar. After executing my service, the logger in OpenShift shows this:
"Read lock: file:/opt/app-root/src/file:/opt/app-root/src/mars-de-service.jar!/BOOT-INF/classes!/CountryBoundaries.shp)". This tells me that it is able to find it and read it. In fact, in my local environment, the file is actually processed. However, in OpenShift, the next line in the logger shows this:
"java.lang.RuntimeException: java.io.FileNotFoundException: /opt/app-root/src/file:/opt/app-root/src/mars-de-service.jar!/BOOT-INF/classes!/CountryBoundaries.shp (No such file or directory)". In my local, as I mentioned, I don't get such an error and my service works fine.
Below is my code:
URL res = CountryCodeLookup.class.getClassLoader().getResource("CountryBoundaries.shp"); File sourceFile = new File(res.getFile()); store = FileDataStoreFinder.getDataStore(sourceFile); featureSource = store.getFeatureSource(); GeometryDescriptor geomDesc = featureSource.getSchema().getGeometryDescriptor(); attrName = geomDesc.getLocalName();
What am I missing?