0

In my Vaadin project I want to be able to access images as a static resource directly. When I put the images below src/main/webapp/VAADIN/themes/... it works. What do I have to do to access images if they are located in src/main/webapp/images? So far, I have seen that I can put this servlet-mapping in my web.xml:

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/images/*</url-pattern>
</servlet-mapping>

Unfortunately, it is not working, I get this error:

Caused by: com.ibm.ws.exception.RuntimeWarning: SRVE0303E: Servlet name for the servlet mapping /images/* could not be found.

My application is running on WebSphere, so I also tried SimpleFileServlet as servlet-name:

<servlet-mapping>
    <servlet-name>SimpleFileServlet</servlet-name>
    <url-pattern>/images/*</url-pattern>
</servlet-mapping>

Still resulting in the same error as above.

Any help is appreciated!


UPDATE

Other servlet-mappings:

<servlet-mapping>
    <servlet-name>QuarzServlet</servlet-name>
    <url-pattern>/QuarzServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>RunJUnitServlet</servlet-name>
    <url-pattern>/RunJUnitServlet</url-pattern>
</servlet-mapping>

When trying to open the images (located in src/main/webapp/images/) in the webbrowser via URL, it just loads the Vaadin application. When I open the page where the images are used, Firebug tells me that the images could not be found.

Marco
  • 508
  • 2
  • 7
  • 22
  • Can you show us all your servlet mappings? Also, what do you see when trying to access an image under src/main/webapp/images? – ZRoman Dec 01 '16 at 02:41

1 Answers1

0

From your update, it seems like a Vaadin servlet is mapped to /* (or using a url-pattern that makes request to static files map to the Vaadin servlet). Since the Vaadin servlet's mapping matches the request URI, Websphere will serve the Vaadin servlet which is the one who might try to serve the static file. The request will never go through the Websphere file serving mechanism. You can verify your Vaadin servlet to see if you have an annotation like the following:

@WebServlet(value = "/*")

If this is the case, and you still want Websphere to serve static files, you will need to modify this mapping to be more specific and let requests to static files go through the Websphere file serving mechanism. You can find some additional information about how to set up the Vaadin servlet here:

https://vaadin.com/wiki/-/wiki/Main/Creating+a+servlet+3.0+application

Also, this stackoverflow question has some possible solutions to this problem:

How to serve static resources from a Vaadin/Spring application?

Péter Török
  • 114,404
  • 31
  • 268
  • 329
ZRoman
  • 180
  • 6