klaus
(Klaus Pfeiffer)
June 25, 2020, 5:11pm
#1
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?
klaus
(Klaus Pfeiffer)
June 30, 2020, 11:14am
#2
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
mnemonik83
(Nico Scarciolla)
January 7, 2021, 4:18pm
#7
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
klaus
(Klaus Pfeiffer)
January 8, 2021, 8:50am
#8
1 Like