Images with ClassResource

Hello Gurus.
I’m newbie for Vaadin and struggle with problem that i searched answers for. Found some similar problems. But still problem continues.
Enviroment:Vaadin 6.4.1. , Tomcat, Eclipse

Image is not found and debug shows image location to:

I have linked image directory in Eclipse to the project directory. /myproject/Images
And images can be seen there in eclipse tree.

Code that i have looks like:
Resource icon = new ClassResource(“Images/omaalus.jpg”, this);
ImageOverlay overlay = new ImageOverlay(image, icon);

I have tried several paths like
as well. No luck.

Same problems is also without overlay add/on. So that is not impacting this.

Would you guys have any ideas on it ?


The servlet can’t see the image, because your project is not in the servlet container classpath. I suggest that you create a new theme and reference your images from there. How to do this:

  1. Create a new theme, eg. MyTheme (
    more info
    ). Don’t forget the setTheme(“MyTheme”) call in Application.init().
  2. Move your Images directory under WebContents/VAADIN/themes/MyTheme/
  3. Use your images in the app with ThemeResource(“Images/omaalus.jpg”)

Hi I am also new to Vaadin and was trying to add an image in a panel for which I wrote the following code:

ExternalResource resource = new ExternalResource(“images/Image.png”);
Embedded image = new Embedded(“My Image”, resource);

and Image.png is at Project\WebContent\images\Image.png

I dont know but there is some thing I am missing.

Can someone help?

Assuming your servlet configuration does expose the image in the correct location, I think you need a full path for the external resource - add a “/” in front of the path.

Alternatively, you could put your resources in the theme and use ThemeResource.

Thanks ,it works. But im wondering how should I use ClassResource? I have seen the image file in classpath already , but still could not be found in browser.