Solucionado (ver solução)
Solucionado
(ver solução)
5
respostas

404 depois de fazer deploy no heroku

Depois que consegui colocar o projeto no heroku pelo eclipse(https://cursos.alura.com.br/forum/topico-maven-erro-para-deploy-no-heroku-90726) acabei caindo em outro problema, ao acessar a página tomo um 404. O projeto está rodando sem problemas localmente, porém no heroku não posso dizer o mesmo.

Esse é o log do

heroku logs
2019-08-30T04:31:35.117165+00:00 app[api]: Deploy 02c360f9 by user bryanmotta7@gmail.com
2019-08-30T04:31:35.117165+00:00 app[api]: Release v10 created by user bryanmotta7@gmail.com
2019-08-30T04:31:35.000000+00:00 app[api]: Build succeeded
2019-08-30T04:31:36.788318+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-08-30T04:31:36.826633+00:00 app[web.1]: Aug 30, 2019 4:31:36 AM org.apache.coyote.AbstractProtocol pause
2019-08-30T04:31:36.826658+00:00 app[web.1]: INFO: Pausing ProtocolHandler ["http-nio-24290"]
2019-08-30T04:31:37.435206+00:00 heroku[web.1]: Process exited with status 143
2019-08-30T04:31:39.072724+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar target/dependency/webapp-runner.jar $WEBAPP_RUNNER_OPTS --port 33682 target/bitbank.war`
2019-08-30T04:31:41.937050+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-08-30T04:31:41.941148+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2019-08-30T04:31:42.615712+00:00 app[web.1]: Expanding bitbank.war into /app/target/tomcat.33682/webapps/expanded
2019-08-30T04:31:42.615763+00:00 app[web.1]: Adding Context  for /app/target/tomcat.33682/webapps/expanded
2019-08-30T04:31:42.977871+00:00 app[web.1]: Aug 30, 2019 4:31:42 AM org.apache.coyote.AbstractProtocol init
2019-08-30T04:31:42.977893+00:00 app[web.1]: INFO: Initializing ProtocolHandler ["http-nio-33682"]
2019-08-30T04:31:43.007814+00:00 app[web.1]: Aug 30, 2019 4:31:43 AM org.apache.catalina.core.StandardService startInternal
2019-08-30T04:31:43.007819+00:00 app[web.1]: INFO: Starting service [Tomcat]
2019-08-30T04:31:43.008735+00:00 app[web.1]: Aug 30, 2019 4:31:43 AM org.apache.catalina.core.StandardEngine startInternal
2019-08-30T04:31:43.008738+00:00 app[web.1]: INFO: Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-08-30T04:31:43.404693+00:00 heroku[web.1]: State changed from starting to up
2019-08-30T04:31:43.271202+00:00 app[web.1]: Aug 30, 2019 4:31:43 AM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
2019-08-30T04:31:43.271217+00:00 app[web.1]: INFO: No global web.xml found
2019-08-30T04:31:48.223641+00:00 app[web.1]: Aug 30, 2019 4:31:48 AM org.apache.catalina.core.ApplicationContext log
2019-08-30T04:31:48.223668+00:00 app[web.1]: INFO: No Spring WebApplicationInitializer types detected on classpath
2019-08-30T04:31:48.392669+00:00 app[web.1]: Aug 30, 2019 4:31:48 AM org.apache.jasper.servlet.TldScanner scanJars
2019-08-30T04:31:48.392674+00:00 app[web.1]: INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-08-30T04:31:48.477722+00:00 app[web.1]: Aug 30, 2019 4:31:48 AM org.apache.coyote.AbstractProtocol start
2019-08-30T04:31:48.477739+00:00 app[web.1]: INFO: Starting ProtocolHandler ["http-nio-33682"]
2019-08-30T04:35:44.604465+00:00 heroku[router]: at=info method=GET path="/" host=bitbankbm.herokuapp.com request_id=e3c122ba-d7c8-444b-b35b-48314852b83b fwd="187.15.84.50" dyno=web.1 connect=1ms service=58ms status=404 bytes=1230 protocol=https

pelo log eu nao conseguir ver o que poderia estar causando o problema.

Na aba resources no heroku tenha essa linha

web java $JAVA_OPTS -jar target/dependency/webapp-runner.jar $WEBAPP_RUNNER_OPTS --port $PORT target/bitbank.war

acredito que seria em relação ao arquivo Procfile configurado no meu projeto, porém o'que está configurado no meu projeto esta

web: java $JAVA_OPTS -jar -Dspring.profiles.active=prod target/dependency/webapp-runner.jar --port $PORT target/*.war

não sei dizer se estão relacionados, mas foi a única coisa que achei diferente por enquanto.

Link do meu projeto completo https://github.com/BryanMotta/FormacaoJava

Obrigado pela ajuda :)

5 respostas

Olá Bryan!

Você está usando Postgres?

Estou sim, colcoquei no projeto como mostra nos videos e depois também coloquei como add-ons "Heroku Postgres "

Edit: aprendi a fazer a atualização pelo github, e fazendo desse modo o Profile fica com o caminho correto

web: java $JAVA_OPTS -jar -Dspring.profiles.active=prod target/dependency/webapp-runner.jar --port $PORT target/bitbank.war

porem o problema muda

2019-08-31T03:43:44.000000+00:00 app[api]: Build succeeded
2019-08-31T03:43:46.931516+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar -Dspring.profiles.active=prod target/dependency/webapp-runner.jar --port 15690 target/bitbank.war`
2019-08-31T03:43:48.342919+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-31T03:43:48.347117+00:00 heroku[web.1]: State changed from crashed to starting
2019-08-31T03:43:48.290189+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-08-31T03:43:48.291515+00:00 app[web.1]: Error: Unable to access jarfile target/dependency/webapp-runner.jar
2019-08-31T03:43:48.329497+00:00 heroku[web.1]: Process exited with status 1
2019-08-31T03:43:51.357631+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar -Dspring.profiles.active=prod target/dependency/webapp-runner.jar --port 3352 target/bitbank.war`
2019-08-31T03:43:53.360987+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-31T03:43:53.341088+00:00 heroku[web.1]: Process exited with status 1
2019-08-31T03:43:53.303166+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-08-31T03:43:53.304550+00:00 app[web.1]: Error: Unable to access jarfile target/dependency/webapp-runner.jar
2019-08-31T03:45:02.460729+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=bitbankbm.herokuapp.com request_id=ef692a72-47d4-496f-94b2-e5aed364ab93 fwd="187.15.84.50" dyno= connect= service= status=503 bytes= protocol=https
 Error: Unable to access jarfile target/dependency/webapp-runner.jar

Ai agora estou tentando resolver, e ver qual consigo corrigir.

Tenta rodar esse comando:

heroku buildpacks:set heroku/java

Depois faça o git push novamente.

Veja se funciona pra ti.

Aguardo seu retorno!

solução!

Fala aí Guilherme, tudo bem? Eu consegui resolver o problema no sábado, aparentemente era algum problema com as versões do

maven-dependency-plugin

e

<maven.compiler.source>1.8</maven.compiler.source>

depois de fazer vários testes consegui chegar nessa configuração

    <build>
        <finalName>bitbank</finalName>
        <plugins>

            <plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>2.0.10</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.github.jsimone</groupId>
                                    <artifactId>webapp-runner</artifactId>
                                    <version>9.0.24.0</version>
                                    <destFileName>webapp-runner.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <properties>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

Eu tinha chegado a testar esse comando que me passou durante os testes mas não resolvia o problema também. Agora esta com o projeto online no heroku https://bitbankbm.herokuapp.com .

Agora estou com erro para acessar o banco de dados, estou tetando resolver ele hoje, mas isso é coisa para outra pergunta no fórum se necessário .

Obrigado pela ajuda!

Opa Bryan, Massa!

Obrigado por compartilhar.

Irei marcar sua resposta como solução!

Se precisar, fique a vontade para abrir um novo tópico.

Bons estudos!