Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么Heroku试图运行newrelic-agent.jar而不是我的应用程序?_Java_Heroku_Newrelic - Fatal编程技术网

Java 为什么Heroku试图运行newrelic-agent.jar而不是我的应用程序?

Java 为什么Heroku试图运行newrelic-agent.jar而不是我的应用程序?,java,heroku,newrelic,Java,Heroku,Newrelic,我的应用程序正在运行,它正在暂存中运行,但在将该构建推送到生产环境后,Heroku正在运行以下命令: java -Dserver.port=12366 -javaagent:target/newrelic-agent.jar -jar target/newrelic-agent.jar 为什么Heroku试图运行newrelic-agent.jar而不是我的应用程序的jar 我的生成日志如下所示: -----> Java app detected -----> Installing

我的应用程序正在运行,它正在暂存中运行,但在将该构建推送到生产环境后,Heroku正在运行以下命令:

java -Dserver.port=12366 -javaagent:target/newrelic-agent.jar -jar target/newrelic-agent.jar
为什么Heroku试图运行newrelic-agent.jar而不是我的应用程序的jar

我的生成日志如下所示:

-----> Java app detected
-----> Installing JDK 1.8... done
-----> Installing Maven 3.3.9... done
-----> Executing: mvn -DskipTests clean dependency:list install
       [INFO] Scanning for projects...
       [INFO]                                                                         
       [INFO] ------------------------------------------------------------------------
       [INFO] Building projectxserver 1.0.0-SNAPSHOT
       [INFO] ------------------------------------------------------------------------
       [WARNING] The artifact org.hibernate:hibernate-validator:jar:6.0.9.Final has been relocated to org.hibernate.validator:hibernate-validator:jar:6.0.9.Final
       [INFO] 
       [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ projectxserver ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.0.2:list (default-cli) @ projectxserver ---
       [INFO] 
       [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ projectxserver ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Copying 1 resource
       [INFO] Copying 11 resources
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ projectxserver ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 54 source files to /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/classes
       [INFO] /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/src/main/java/tech/projectx/server/models/support/JacksonUtil.java: /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/src/main/java/tech/projectx/server/models/support/JacksonUtil.java uses unchecked or unsafe operations.
       [INFO] /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/src/main/java/tech/projectx/server/models/support/JacksonUtil.java: Recompile with -Xlint:unchecked for details.
       [INFO] 
       [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ projectxserver ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Copying 1 resource
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ projectxserver ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 1 source file to /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/test-classes
       [INFO] 
       [INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ projectxserver ---
       [INFO] Tests are skipped.
       [INFO] 
       [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ projectxserver ---
       [INFO] Building jar: /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/projectxserver-1.0.0-SNAPSHOT.jar
       [INFO] 
       [INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ projectxserver ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.0.2:copy (copy-new-relic-jar) @ projectxserver ---
       [INFO] Configured Artifact: com.newrelic.agent.java:newrelic-agent:?:jar
       [INFO] Copying newrelic-agent-4.0.0.jar to /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/newrelic-agent.jar
       [INFO] 
       [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ projectxserver ---
       [INFO] Installing /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/projectxserver-1.0.0-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/tech/projectx/projectxserver/1.0.0-SNAPSHOT/projectxserver-1.0.0-SNAPSHOT.jar
       [INFO] Installing /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/pom.xml to /app/tmp/cache/.m2/repository/tech/projectx/projectxserver/1.0.0-SNAPSHOT/projectxserver-1.0.0-SNAPSHOT.pom
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD SUCCESS
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time: 17.850 s
       [INFO] Finished at: 2018-05-08T19:10:25+00:00
       [INFO] Final Memory: 61M/410M
       [INFO] ------------------------------------------------------------------------
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 190.1M
-----> Launching...
       Released v46
       https://projectxserver-production.herokuapp.com/ deployed to Heroku
web: java -Dserver.port=$PORT -javaagent:target/newrelic-agent.jar -jar target/projectxserver-1.0.0-SNAPSHOT.jar

在重新部署几次之后,它开始使用正确的jar。Heroku是随机选取的吗?

当Heroku检测到您正在使用Spring Boot时,它会自动找出运行应用程序的命令。但是,由于newrelic JAR位于您的目标/目录中,它认为它是您的应用程序

您可以通过两种方式解决此问题:

将newrelic jar放在不同的目录下,如target/dependency或类似目录。 创建一个Procfile并显式地告诉Heroku运行应用程序所需的命令。 如果创建一个Procfile,它可能如下所示:

-----> Java app detected
-----> Installing JDK 1.8... done
-----> Installing Maven 3.3.9... done
-----> Executing: mvn -DskipTests clean dependency:list install
       [INFO] Scanning for projects...
       [INFO]                                                                         
       [INFO] ------------------------------------------------------------------------
       [INFO] Building projectxserver 1.0.0-SNAPSHOT
       [INFO] ------------------------------------------------------------------------
       [WARNING] The artifact org.hibernate:hibernate-validator:jar:6.0.9.Final has been relocated to org.hibernate.validator:hibernate-validator:jar:6.0.9.Final
       [INFO] 
       [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ projectxserver ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.0.2:list (default-cli) @ projectxserver ---
       [INFO] 
       [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ projectxserver ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Copying 1 resource
       [INFO] Copying 11 resources
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ projectxserver ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 54 source files to /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/classes
       [INFO] /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/src/main/java/tech/projectx/server/models/support/JacksonUtil.java: /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/src/main/java/tech/projectx/server/models/support/JacksonUtil.java uses unchecked or unsafe operations.
       [INFO] /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/src/main/java/tech/projectx/server/models/support/JacksonUtil.java: Recompile with -Xlint:unchecked for details.
       [INFO] 
       [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ projectxserver ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Copying 1 resource
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ projectxserver ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 1 source file to /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/test-classes
       [INFO] 
       [INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ projectxserver ---
       [INFO] Tests are skipped.
       [INFO] 
       [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ projectxserver ---
       [INFO] Building jar: /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/projectxserver-1.0.0-SNAPSHOT.jar
       [INFO] 
       [INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ projectxserver ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.0.2:copy (copy-new-relic-jar) @ projectxserver ---
       [INFO] Configured Artifact: com.newrelic.agent.java:newrelic-agent:?:jar
       [INFO] Copying newrelic-agent-4.0.0.jar to /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/newrelic-agent.jar
       [INFO] 
       [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ projectxserver ---
       [INFO] Installing /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/target/projectxserver-1.0.0-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/tech/projectx/projectxserver/1.0.0-SNAPSHOT/projectxserver-1.0.0-SNAPSHOT.jar
       [INFO] Installing /tmp/build_b35db9c210bc86f2ba9870e2cd5d9474/pom.xml to /app/tmp/cache/.m2/repository/tech/projectx/projectxserver/1.0.0-SNAPSHOT/projectxserver-1.0.0-SNAPSHOT.pom
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD SUCCESS
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time: 17.850 s
       [INFO] Finished at: 2018-05-08T19:10:25+00:00
       [INFO] Final Memory: 61M/410M
       [INFO] ------------------------------------------------------------------------
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 190.1M
-----> Launching...
       Released v46
       https://projectxserver-production.herokuapp.com/ deployed to Heroku
web: java -Dserver.port=$PORT -javaagent:target/newrelic-agent.jar -jar target/projectxserver-1.0.0-SNAPSHOT.jar
然后运行:

git add Procfile
git commit -m "Procfile"
git push heroku master

您可以在中查看默认命令的逻辑。

您的程序文件中有什么?在重新部署几次之后,它开始使用正确的jar。-通常,只有在有新提交的情况下,这才有效。当你做出这些承诺时,你改变了什么?@Chris:没有新的承诺。我没有文件。