Heroku 未定义上下文
Heroku No Contexts defined
我在 heroku 中部署了一个应用程序,但我无法访问它
Heroku 日志
2015-10-18T14:13:28.456831+00:00 heroku[web.1]: State changed from crashed to starting
2015-10-18T14:13:38.538928+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2015-10-18T14:13:38.552255+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx384m -Xss512k -Dfile.encoding=UTF-8
2015-10-18T14:13:39.140316+00:00 app[web.1]: 2015-10-18 14:13:39.135:INFO:oejr.Runner:main: Runner
2015-10-18T14:13:39.140320+00:00 app[web.1]: ERROR: No Contexts defined
2015-10-18T14:13:39.140321+00:00 app[web.1]: Usage: java [-Djetty.home=dir] -jar jetty-runner.jar [--help|--version] [ server opts] [[ context opts] context ...]
2015-10-18T14:13:39.140322+00:00 app[web.1]: Server opts:
2015-10-18T14:13:39.140323+00:00 app[web.1]: --version - display version and exit
2015-10-18T14:13:39.140324+00:00 app[web.1]: --log file - request log filename (with optional 'yyyy_mm_dd' wildcard
2015-10-18T14:13:39.140325+00:00 app[web.1]: --out file - info/warn/debug log filename (with optional 'yyyy_mm_dd' wildcard
2015-10-18T14:13:39.140326+00:00 app[web.1]: --host name|ip - interface to listen on (default is all interfaces)
2015-10-18T14:13:39.140327+00:00 app[web.1]: --port n - port to listen on (default 8080)
2015-10-18T14:13:39.140328+00:00 app[web.1]: --stop-port n - port to listen for stop command
2015-10-18T14:13:39.130872+00:00 app[web.1]: 2015-10-18 14:13:39.127:INFO::main: Logging initialized @89ms
2015-10-18T14:13:39.140329+00:00 app[web.1]: --stop-key n - security string for stop command (required if --stop-port is present)
2015-10-18T14:13:39.140329+00:00 app[web.1]: [--jar file]*n - each tuple specifies an extra jar to be added to the classloader
2015-10-18T14:13:39.140330+00:00 app[web.1]: [--lib dir]*n - each tuple specifies an extra directory of jars to be added to the classloader
2015-10-18T14:13:39.140331+00:00 app[web.1]: [--classes dir]*n - each tuple specifies an extra directory of classes to be added to the classloader
2015-10-18T14:13:39.140332+00:00 app[web.1]: --stats [unsecure|realm.properties] - enable stats gathering servlet context
2015-10-18T14:13:39.140332+00:00 app[web.1]: [--config file]*n - each tuple specifies the name of a jetty xml config file to apply (in the order defined)
2015-10-18T14:13:39.140333+00:00 app[web.1]: Context opts:
2015-10-18T14:13:39.140334+00:00 app[web.1]: [[--path /path] context]*n - WAR file, web app dir or context xml file, optionally with a context path
2015-10-18T14:13:39.939608+00:00 heroku[web.1]: Process exited with status 1
2015-10-18T14:13:39.957993+00:00 heroku[web.1]: State changed from starting to crashed
工头开始
11:29:04 web.1 | started with pid 464
11:29:04 web.1 | Error: Unable to access jarfile target/dependency/jetty-runner.jar
11:29:04 web.1 | exited with code 1
11:29:04 system | sending SIGTERM to all processes
Pom.xml 文件
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-runner</artifactId>
<version>9.2.3.v20140905</version>
<destFileName>jetty-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
每次我尝试访问我的应用程序时,浏览器都会显示以下消息
因为我无法访问我的应用程序?与码头有任何兼容性错误吗?
您如何部署您的应用程序?用 git push
, mvn heroku:deploy
, heroku deploy:war
, 还有别的吗?
您的 pom.xml
应该包括围绕 jetty-runner 配置的所有这些:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-runner</artifactId>
<version>9.2.7.v20150116</version>
<destFileName>jetty-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
也就是说,确保它绑定到 package
目标。如果您使用 git push
,请检查构建输出以确保插件配置运行。
最后,通过检查 slug 来检查 jetty-runner 是否存在:
$ heroku run ls target/dependency
我设法解决了部署到 Heroku 的问题。要在 eclipse 中使用 CTRL + SHIFT + F 快捷方式格式化我的 pom.xml 文件,我的代码如下:
问题
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>0.4.4</version>
<configuration>
<appName>cliente-mws-usp</appName>
<processTypes>
<web>java $JAVA_OPTS -jar target/dependency/jetty-runner.jar
--port $PORT target/*.war</web>
</processTypes>
<stack>cedar-14</stack>
<jdkVersion>1.7</jdkVersion>
</configuration>
</plugin>
问题是 Heroku 只执行了 stretch java $JAVA_OPTS -jar target/dependency/jetty-runner.jar
并认为命令的其余部分 --port $PORT target/*.war
因为我已经断线了。要撤消格式并将所有命令保留在一行中,再次部署功能正常。
解决方案
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>0.4.4</version>
<configuration>
<appName>cliente-mws-usp</appName>
<processTypes>
<web>java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war</web>
</processTypes>
<stack>cedar-14</stack>
<jdkVersion>1.7</jdkVersion>
</configuration>
</plugin>
再次感谢您的帮助和解释。
我在 heroku 中部署了一个应用程序,但我无法访问它
Heroku 日志
2015-10-18T14:13:28.456831+00:00 heroku[web.1]: State changed from crashed to starting
2015-10-18T14:13:38.538928+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2015-10-18T14:13:38.552255+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx384m -Xss512k -Dfile.encoding=UTF-8
2015-10-18T14:13:39.140316+00:00 app[web.1]: 2015-10-18 14:13:39.135:INFO:oejr.Runner:main: Runner
2015-10-18T14:13:39.140320+00:00 app[web.1]: ERROR: No Contexts defined
2015-10-18T14:13:39.140321+00:00 app[web.1]: Usage: java [-Djetty.home=dir] -jar jetty-runner.jar [--help|--version] [ server opts] [[ context opts] context ...]
2015-10-18T14:13:39.140322+00:00 app[web.1]: Server opts:
2015-10-18T14:13:39.140323+00:00 app[web.1]: --version - display version and exit
2015-10-18T14:13:39.140324+00:00 app[web.1]: --log file - request log filename (with optional 'yyyy_mm_dd' wildcard
2015-10-18T14:13:39.140325+00:00 app[web.1]: --out file - info/warn/debug log filename (with optional 'yyyy_mm_dd' wildcard
2015-10-18T14:13:39.140326+00:00 app[web.1]: --host name|ip - interface to listen on (default is all interfaces)
2015-10-18T14:13:39.140327+00:00 app[web.1]: --port n - port to listen on (default 8080)
2015-10-18T14:13:39.140328+00:00 app[web.1]: --stop-port n - port to listen for stop command
2015-10-18T14:13:39.130872+00:00 app[web.1]: 2015-10-18 14:13:39.127:INFO::main: Logging initialized @89ms
2015-10-18T14:13:39.140329+00:00 app[web.1]: --stop-key n - security string for stop command (required if --stop-port is present)
2015-10-18T14:13:39.140329+00:00 app[web.1]: [--jar file]*n - each tuple specifies an extra jar to be added to the classloader
2015-10-18T14:13:39.140330+00:00 app[web.1]: [--lib dir]*n - each tuple specifies an extra directory of jars to be added to the classloader
2015-10-18T14:13:39.140331+00:00 app[web.1]: [--classes dir]*n - each tuple specifies an extra directory of classes to be added to the classloader
2015-10-18T14:13:39.140332+00:00 app[web.1]: --stats [unsecure|realm.properties] - enable stats gathering servlet context
2015-10-18T14:13:39.140332+00:00 app[web.1]: [--config file]*n - each tuple specifies the name of a jetty xml config file to apply (in the order defined)
2015-10-18T14:13:39.140333+00:00 app[web.1]: Context opts:
2015-10-18T14:13:39.140334+00:00 app[web.1]: [[--path /path] context]*n - WAR file, web app dir or context xml file, optionally with a context path
2015-10-18T14:13:39.939608+00:00 heroku[web.1]: Process exited with status 1
2015-10-18T14:13:39.957993+00:00 heroku[web.1]: State changed from starting to crashed
工头开始
11:29:04 web.1 | started with pid 464
11:29:04 web.1 | Error: Unable to access jarfile target/dependency/jetty-runner.jar
11:29:04 web.1 | exited with code 1
11:29:04 system | sending SIGTERM to all processes
Pom.xml 文件
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-runner</artifactId>
<version>9.2.3.v20140905</version>
<destFileName>jetty-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
每次我尝试访问我的应用程序时,浏览器都会显示以下消息
因为我无法访问我的应用程序?与码头有任何兼容性错误吗?
您如何部署您的应用程序?用 git push
, mvn heroku:deploy
, heroku deploy:war
, 还有别的吗?
您的 pom.xml
应该包括围绕 jetty-runner 配置的所有这些:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-runner</artifactId>
<version>9.2.7.v20150116</version>
<destFileName>jetty-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
也就是说,确保它绑定到 package
目标。如果您使用 git push
,请检查构建输出以确保插件配置运行。
最后,通过检查 slug 来检查 jetty-runner 是否存在:
$ heroku run ls target/dependency
我设法解决了部署到 Heroku 的问题。要在 eclipse 中使用 CTRL + SHIFT + F 快捷方式格式化我的 pom.xml 文件,我的代码如下:
问题
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>0.4.4</version>
<configuration>
<appName>cliente-mws-usp</appName>
<processTypes>
<web>java $JAVA_OPTS -jar target/dependency/jetty-runner.jar
--port $PORT target/*.war</web>
</processTypes>
<stack>cedar-14</stack>
<jdkVersion>1.7</jdkVersion>
</configuration>
</plugin>
问题是 Heroku 只执行了 stretch java $JAVA_OPTS -jar target/dependency/jetty-runner.jar
并认为命令的其余部分 --port $PORT target/*.war
因为我已经断线了。要撤消格式并将所有命令保留在一行中,再次部署功能正常。
解决方案
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>0.4.4</version>
<configuration>
<appName>cliente-mws-usp</appName>
<processTypes>
<web>java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war</web>
</processTypes>
<stack>cedar-14</stack>
<jdkVersion>1.7</jdkVersion>
</configuration>
</plugin>
再次感谢您的帮助和解释。