We’re having issues while trying to load resources after we deploy to production.
Following Vaadin’s documentation we tried both VaadinService.getResourceAsStream(path) and ServletContext.getResourceAsStream(path). They work locally but return null in our QA environment where we deploy using Maven: ./mvnw -B clean package -DskipTests -Pproduction-mode --file pom.xml
The logo we are trying to use is located in src/main/resources/META-INF/resources/images/ where we try to load: VaadinServlet.getCurrent().getServletContext().getResourceAsStream("/images/logo.png"))
For reference other images we have in the same folder work as expected when using Vaadin’s Image component, but we need to do it manually for a specific use case for one of the logos.
Also tried that. Moved the image to the root resources folder and changed from Vaadin’s way to plain Java way of using class loader and the same happened, works locally, no luck after deploying.
About the Image Component I’m not sure where to look. That one just creates an HTML container and the src attribute is just the relative path to the image.
What do you mean by deploying? Spring Boot’s fat jar is not deployed in e.g. an external tomcat by default. Normally using ClassPathResource from spring should work in every context