Проблема при развертывании приложения Vaadin 14 на Heroku - PullRequest
1 голос
/ 25 октября 2019

У меня проблема при развертывании приложения Vaadin 14 (Spring Boot) на Heroku. Это журналы Heroku:

2019-10-23T19:34:19.005415+00:00 app[web.1]: 2019-10-23 19:34:19.004 ERROR 4 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]
     : Exception sending context initialized event to listener instance of class [com.vaadin.flow.spring.VaadinServletContextInitialize
r$DevModeServletContextListener]
2019-10-23T19:34:19.005427+00:00 app[web.1]:
2019-10-23T19:34:19.005432+00:00 app[web.1]: java.lang.IllegalStateException: Running project in development mode with no access to fol
der '/tmp/build_1eb1799fb4903b1c64716231dcb4a093'.
2019-10-23T19:34:19.005435+00:00 app[web.1]: Build project in production mode instead, see https://vaadin.com/docs/v14/flow/production/
tutorial-production-mode-basic.html
2019-10-23T19:34:19.005436+00:00 app[web.1]: at com.vaadin.flow.server.DeploymentConfigurationFactory.verifyFolderExists(DeploymentConf
igurationFactory.java:283) ~[flow-server-2.0.14.jar!/:2.0.14]
2019-10-23T19:34:19.005438+00:00 app[web.1]: at com.vaadin.flow.server.DeploymentConfigurationFactory.readBuildInfo(DeploymentConfigura
tionFactory.java:222) ~[flow-server-2.0.14.jar!/:2.0.14]
2019-10-23T19:34:19.005439+00:00 app[web.1]: at com.vaadin.flow.server.DeploymentConfigurationFactory.createInitParameters(DeploymentCo
nfigurationFactory.java:166) ~[flow-server-2.0.14.jar!/:2.0.14]
2019-10-23T19:34:19.005441+00:00 app[web.1]: at com.vaadin.flow.server.DeploymentConfigurationFactory.createPropertyDeploymentConfigura
tion(DeploymentConfigurationFactory.java:126) ~[flow-server-2.0.14.jar!/:2.0.14]
2019-10-23T19:34:19.005445+00:00 app[web.1]: at com.vaadin.flow.spring.VaadinServletContextInitializer$SpringStubServletConfig.createDe
ploymentConfiguration(VaadinServletContextInitializer.java:747) ~[vaadin-spring-12.0.6.jar!/:na]
2019-10-23T19:34:19.005447+00:00 app[web.1]: at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.co
ntextInitialized(VaadinServletContextInitializer.java:289) ~[vaadin-spring-12.0.6.jar!/:na]
2019-10-23T19:34:19.005449+00:00 app[web.1]: at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4680) [tomc
at-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.00545+00:00 app[web.1]: at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143) [tomca
t-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005451+00:00 app[web.1]: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core
-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005452+00:00 app[web.1]: at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat
-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005454+00:00 app[web.1]: at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat
-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005456+00:00 app[web.1]: at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_222-heroku]
2019-10-23T19:34:19.005457+00:00 app[web.1]: at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java
:75) [tomcat-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005458+00:00 app[web.1]: at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [
na:1.8.0_222-heroku]
2019-10-23T19:34:19.00546+00:00 app[web.1]: at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-emb
ed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005461+00:00 app[web.1]: at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) [tomcat-embe
d-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005462+00:00 app[web.1]: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core
-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005464+00:00 app[web.1]: at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat
-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005465+00:00 app[web.1]: at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat
-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005466+00:00 app[web.1]: at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_222-heroku]
2019-10-23T19:34:19.005467+00:00 app[web.1]: at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java
:75) [tomcat-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005469+00:00 app[web.1]: at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [
na:1.8.0_222-heroku]
2019-10-23T19:34:19.00547+00:00 app[web.1]: at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-emb
ed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005472+00:00 app[web.1]: at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-
embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005473+00:00 app[web.1]: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core
-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005474+00:00 app[web.1]: at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) [tomca
t-embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005475+00:00 app[web.1]: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core
-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005485+00:00 app[web.1]: at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) [tomcat-
embed-core-9.0.22.jar!/:9.0.22]
2019-10-23T19:34:19.005487+00:00 app[web.1]: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core
-9.0.22.jar!/:9.0.22]

Из-за журналов проблема в производственном режиме. Но я установил переменную среды Heroku SPRING_PROFILES_ACTIVE в производственную.

heroku config:set SPRING_PROFILES_ACTIVE=production

Вот pom.xml (часть сборки и профилей):

<build>
    <defaultGoal>spring-boot:run</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <!-- Clean build and startup time for Vaadin apps sometimes may exceed
                 the default Spring Boot's 30sec timeout.  -->
            <configuration>
                <wait>500</wait>
                <maxAttempts>240</maxAttempts>
            </configuration>
        </plugin>

        <!--
            Take care of synchronizing java dependencies and imports in
            package.json and main.js files.
            It also creates webpack.config.js if not exists yet.
        -->
        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${vaadin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-frontend</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <!-- Use the latest released version:
            https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
            <version>1.8.0</version>

            <executions>
                <execution>
                    <!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
                    <id>install node and npm</id>
                    <goals>
                        <goal>install-node-and-npm</goal>
                    </goals>
                    <!-- optional: default phase is "generate-resources" -->
                    <phase>generate-resources</phase>
                </execution>
            </executions>
            <configuration>
                <nodeVersion>v10.16.2</nodeVersion>

                <!-- optional: with node version greater than 4.0.0 will use npm provided by node distribution -->
                <!--                    <npmVersion>2.15.9</npmVersion>-->

                <!-- optional: where to download node and npm from. Defaults to https://nodejs.org/dist/ -->
                <!--                    <downloadRoot>http://myproxy.example.org/nodejs/</downloadRoot>-->
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>production</id>
        <properties>
            <vaadin.productionMode>true</vaadin.productionMode>
        </properties>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-server-production-mode</artifactId>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-maven-plugin</artifactId>
                    <version>${vaadin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-frontend</goal>
                                <goal>build-frontend</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

Что я делаю неправильно? У меня не было таких проблем при развертывании приложения Vaadin 13 на Heroku.

РЕДАКТИРОВАТЬ ПРОБЛЕМУ РЕШЕНО Проблема решена с помощью команды

mvn clean package -Pproduction heroku:deploy
...