I'm having a weird situation. I use geotools to project rasters and it works for example
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857");
GridCoverage2D projectedImage = (GridCoverage2D) Operations.DEFAULT.resample(gridCoverageImage,
targetCRS);
Now I moved my process in a web server controller with the exact same code :
public ResponseEntity<InputStreamResource> getProjectedImage(@RequestParam
String filename, @RequestParam String targetCrs){
File file = new File(filename);
CoordinateReferenceSystem targetCRS = CRS.decode(targetCrs);
/** Some process to return file /**
}
I'm having :
org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:3857"
from authority "EPSG" found for object of type "EngineeringCRS"
My pom.xml
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>18.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>18.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-coverage</artifactId>
<version>18.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geotiff</artifactId>
<version>18.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-image</artifactId>
<version>18.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-wms</artifactId>
<version>18.2</version>
</dependency>
When I look into WEB-INF/lib, all jars are here including dependencies (gt-referencing, gt-metadata.....)
Tomcat : 8.0 Java 8 GeoTools : 18.2
It works fine when I'm not in a servlet container. Also, other utilities from geotools are working fine. For example, the cropping or the GridCoverage2D conversion work in this servlet container.
Could you please help me understand what's going on?
Thanks in advance