Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources not found when running the .war embedded tomcat #265

Closed
denis-anisimov opened this issue Apr 18, 2018 · 4 comments
Closed

Resources not found when running the .war embedded tomcat #265

denis-anisimov opened this issue Apr 18, 2018 · 4 comments

Comments

@denis-anisimov
Copy link

@manolo commented on Mon Mar 12 2018

Out of the box, Spring Boot uses a public static void main entry-point that launches an embedded web tomcat server packaged into the .war file, thus running java -jar target/my-app.war launches the app. Tough, flow seems unable to find resources packaged into the .war file. The same war deployed in a tomcat works as expected.

You can reproduce e.g. by checking out bakery and packaging it:

mvn package -Pproduction
java -jar target/bakery-*.war

The error in console is:
Can't find resource 'frontend://src/views/login/login-view.html' via the servlet context'


@deyaeddin commented on Sat Mar 24 2018

I'm facing the same error when I changed the packaging to jar with Spring Boot 2.0,
it's running fine with error in console when I use

mvn spring-boot:run

but when I use:

java -jar target/bakery-app.jar

I got the following exception error

ERROR 3103 --- [nio-8002-exec-2] c.v.flow.router.InternalServerError : There was an exception while trying to navigate to 'login'

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.thalesgroup.ife.dutyfree.dutyfreeframework.ui.views.login.LoginView': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.thalesgroup.ife.dutyfree.dutyfreeframework.ui.views.login.LoginView]: Constructor threw exception; nested exception is java.lang.IllegalStateException: Can't find resource 'frontend://src/views/login/login-view.html' via the servlet context
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1232) ~[spring-beans-5.0.4.RELEASE.jar!/:5.0.4.RELEASE]


@docwho2 commented on Mon Mar 26 2018

I just ran into this as well. This is the default behavior when you deploy to AWS Beanstalk. But what AWS does by default is rename your WAR file to "application.jar" and then executes "java -jar application.jar". Took me half a day to figure out renaming the WAR to JAR breaks everything. I had simple views before, but now that I'm including HTML in the views I'm seeing the same errors. I will change my deployment package to execute the WAR with mvn spring-boot:run until there is fix.


@Legioth commented on Wed Mar 28 2018

Similar messages also observed with mvn spring-boot:run for the vaadin_push.zip project referenced in vaadin/flow#3738 (comment).

@Wnt
Copy link

Wnt commented Aug 2, 2018

Current version of our spring starter pack has the resources by default in the wrong directory:
the resources are in src/main/webapp while they should be in src/main/resources/static/

To workaround this problem you can move the resources to the correct directory src/main/resources/static/ and make the following changes to your pom.xml

pom modifications

@pleku
Copy link
Contributor

pleku commented Aug 6, 2018

Kind of depends on designer support for other template locations vaadin/designer#1812.

However, this ought to be fixed and when the designer also supports this, we move the templates in the spring starter(s) too.

@pleku pleku added this to the 1.0 Maintenance milestone Aug 6, 2018
@SomeoneToIgnore
Copy link
Contributor

Seems to be working just fine both in production and development mode for Vaadin Platform 12.0-SNAPSHOT

@SomeoneToIgnore
Copy link
Contributor

Does not reproduce, closing for now.
Please add a comment or open a new issue if you think anything is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants