I am facing two problems between running Vaadin 12 with Spring boot 2.0.6 in Eclipse Photon IDE and in a war on Tomcat 8.5 server:
when requesting home page it comes up with this Exception Caused by: java.lang.IllegalArgumentException: Unable to create an instance of 'myProject.HomePage'. Make sure the class has a public no-arg constructor.
I found some workaround to access login page (which does not resolve the first problem) but it displays a blank page because the two resources cannot be found http://contextRoot/frontend/styles/shared-styles.html and http://contextRoot/frontend/src/views/login/login-view.html. These two resources are located in src\main\resources\static folder.
If I deploy my project as a jar, ok it is working but css files are not read
If I give an Autowire argument to LoginView, displayed Exception for HomePage is not thrown
For information:
Everything goes fine while my project is run from IDE
Everything goes fine if my project takes Vaadin 10 instead of 12
My log displays this message: INFOS: 2 Spring WebApplicationInitializers detected on classpath
Does anyone have a clue for this?
I am experiencing a similar issue where sometimes (in average about every second time I run the app) the static resources in the frontend folder are not available. When this happens, the login page is blank. See attachment ‘no-static-resources.png’ for a screenshot of the dev-tool when this happens.
Usually (not always) when I then stop the app, clean and install it again and re-run it, then it has again the static resources - see attachment ‘has-static-resources.png’.
I have no idea what is the cause for this and it is causing real headache!
I do not use tomcat, and I do not have an exception about missing no-arg constructors.
I import files from the frontend folder using this path syntax:
@HtmlImport("src/views/login-view.html")
public class LoginView ....
Edit: I use websphere/liberty for local runs. my frontend folder is in src/main/webapp and not in src/main/resources/static because that has never worked for me.
I was not trying to give you a solution - Since I have the same or a similar issue I just wanted to provide more information about it from my perspective
Update: I do no longer experience this issue anymore, the static files are now always available to me.
I am not exactly sure what it was that fixed it, but my guess is that it has to do with the SecurityConfiguration that I have edited for my project this week. More explicitely, I added the line .requestMatchers(SecurityUtils::isFrameworkInternalRequest).permitAll() in the method override of configure(HttpSecurity http), and added a whole method override for configure(WebSecurity web) that I copied from [this forum post]
(https://vaadin.com/forum/thread/17475153/17476082).
Hello Alvaro Jose Garcia Cohen, I made it too but it does not work.
I think the real problem is the application cannot see files in static folder.
I implemented .requestMatchers(SecurityUtils::isFrameworkInternalRequest).permitAll().
I tried to start bakery project in tomcat 9 and it is absolutely the same.
Steeve Spatafora:
I moved every file in app-root/WEB-INF/classes/static into app-root.
For example: the frontend folder.
Hi Steeve, after you moved the frontend foolder in the path: app-root/WEB-INF/classes/static, how you call it in view?
Because for me @StyleSheet(“fronted://nameRes…”) doesn’t work
we put all files from static folder into webapp in our IDE before deployment.
Then we call them, from your example, with @StyleSheet(“context://fronted/name”)