GlobalResourceHandler returns error due to resource not found

Hello all,

I am using Vaadin 7.3.7. At some point of the application, a PDF file is being generated as StreamResource, which is then attached to the UI for printing through a UI component. This UI component is based on an AbstractJavaScriptComponent and implements the LegacyComponent. A GlobalResourceHandler is registered to the UI component and the StreamResource.
When running the application through Eclipse and an embedded Jetty, everything is working fine.
As soon the application is deployed to i. e. a Tomcat instance, the following error is thrown on the console …

Jun 26, 2015 1:32:01 PM com.vaadin.server.GlobalResourceHandler error

WARNING: Global resource legacy/2/data/apps/pdf/1.pdf not found Looking at the Developer Console, the network recorder shows the file with “(Aborted)”

/myapp/APP/global/2/legacy/2//data/apps/pdf/1.pdf Looking at the absolute path the custom component receives … Code:


package whatever;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.ui.AbstractJavaScriptComponent;
import com.vaadin.ui.LegacyComponent;

@com.vaadin.annotations.JavaScript(value = {“vaadin://js/mylibrary.js”, “vaadin://js/printcomponent-connector.js”})
public class PrintComponent extends AbstractJavaScriptComponent implements LegacyComponent {

private static final long serialVersionUID = 3509318442942357405L;

private List<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();

public PrintComponent() {

/** {@inheritDoc} */
protected PrintComponentState getState() {
    return (PrintComponentState) super.getState();

public void addValueChangeListener(ValueChangeListener listener) {

public void setHtmlCompId(String id) {
    getState().compId = id;

public void setURL(String url) {
    getState().url = url;

public static interface ValueChangeListener extends Serializable {
    void valueChange();

public void changeVariables(Object source, Map<String, Object> variables) {
    // TODO Auto-generated method stub

public void paintContent(PaintTarget target) throws PaintException {
    // TODO Auto-generated method stub


/* Define the namespace */ var mylibrary = mylibrary || {}; mylibrary.PrintComponent = function (element, id, url) { console.log(url); element.innerHTML = '<embed width="0" height="0" id="' + id + '" src="' + url + '" type="application/pdf"/>'; };

window.whatever_PrintComponent = function() { var printcomponent = new mylibrary.PrintComponent(this.getElement(), this.getState().compId, this.getState().url); };
Creating the Resource file:

        PrintComponent comp = new PrintComponent();
        StreamResource streamResource = StreamResource(comp, uniquePdfName, pdfFileAsByteArray);
        downloadQueue.addToQueue(comp, streamResource);

        Application.ensureCurrentApplication().getSession().getGlobalResourceHandler(true).register(streamResource, comp);

        /* Retrieve the port */
        String port = new String();
        int po = Page.getCurrent().getLocation().getPort();
        if (po > -1) {
            port = ":" + po; 

        String path = new String();
        String p = Page.getCurrent().getLocation().getPath();
        if (p != null
        && p.equals("/") == false) {
            /* Limit the path to not having the very last '/' as it may cause issues for the whole document path */
            path = p.substring(0, p.lastIndexOf("/"));

        /* Build the complete document path */    
        ResourceReference reference = ResourceReference.create(streamResource, comp, uniqueId);
        String url = Page.getCurrent().getLocation().getScheme() + "://"
                        + Page.getCurrent().getLocation().getHost()
                        + port
                        + path
                        + reference.getURL().substring(5);

What am I dealing with?

Thanks in advance,

Hi Martin!

Did u resolve this issue?