uberJar + sw responsive = HTTP 403 forbidden on VAADIN/responsivelayout/styles.css

Hi all,
I’m using the SW-responsive add-on. In my local dev environment the styles.css from the add-on is loaded, but when running the uberJar I get a 403 response in the browser for VAADIN/responsivelayout/styles.css and thus the layout of the affected page is broken.

Any thoughts on that?

Ok, I debugged the issue.

The resourcePath looks like this ...build/distributions/uberJar/app.jar!/LIB-INF/app/WEB-INF/classes/VAADIN/responsivelayout/styles.css

There is a check in com.haulmont.cuba.web.sys.CubaApplicationServlet#isAllowedVAADINResourceUrl that looks like this:

                if (resourcePath.contains("!/LIB-INF/app/VAADIN/")) {
                    return true;
                }

Obviously now for this case, there is a mismatch. I fixed it now by creating a custom MyApplicationServlet class with the following content:

public class MyApplicationServlet extends CubaApplicationServlet {

    @Override
    protected boolean isAllowedVAADINResourceUrl(HttpServletRequest request, URL resourceUrl) {
        boolean isUberJar = Boolean.parseBoolean(AppContext.getProperty("cuba.uberJar"));
        if (isUberJar) {
            String resourcePath = resourceUrl.getPath();
            if ("jar".equals(resourceUrl.getProtocol())) {
                if (resourcePath.contains("!/LIB-INF/app/WEB-INF/classes/VAADIN/")) {
                    return true;
                }
            }
        }
        return super.isAllowedVAADINResourceUrl(request, resourceUrl);
    }

}

… and changing the servlet configuration to:

    <servlet>
        <servlet-name>app_servlet</servlet-name>
<!--        <servlet-class>com.haulmont.cuba.web.sys.CubaApplicationServlet</servlet-class>-->
        <servlet-class>com.example.web.MyApplicationServlet</servlet-class>
        <async-supported>true</async-supported>
    </servlet>

Hope that helps someone and maybe this change should be introduced into the main branch.
Should I maybe make a pull request?

1 Like

Hi Klaus,

same problem on version 7.2.11. You save me with your post.

@CUBA: can you introduce this fix into the next release?

Thanks

@mnemonik83 Thanks for reporting that is was helpful to you, I created a pull request now: fixing http 403 forbidden in uberJar by klaus7 · Pull Request #3134 · cuba-platform/cuba · GitHub

1 Like