for vaadin theme resource

Is it possible to obtain url ( ) for an image placed inside vaadin theme?
I need this to embed an image while generating pdf file using iText.
I already tried using context.getResource(“resource path”). but it can load only if resource is located inside WEB-INF.
In my application, vaadin theme is located under tomcat/ webapps/ ROOT directory.
Thanks for any inputs.

There’s no programmatic way to get a reliable URL for a theme resource.

But, if you’re open for some hacks and assumptions, you can hardlink to an url that follows the pattern [server]
/[resource path]
. For example:

I know my reply is quite some time after your post, but if you’re still interested, or it helps others, this how I solve the problem you describe:

String basepath = getApplication().getContext().getBaseDirectory().getAbsolutePath();

This will give you the path on the hard disk to your root context, so if your image is in $CONTEXT/images. you could do something like this:

File file = new File (basepath + "/images/someimage.jpg") ;

Hope that helps,