简体   繁体   English

在Heroku(Maven)中启动应用

[英]Start app in Heroku (Maven)

I am trying to start an app on Heroku but I am facing an issue, I will tell step by step what I did to arrive at this point, if someone help me I will be very help and I will send a chocolate cake :D 我正在尝试在Heroku上启动应用程序,但是我遇到了一个问题,我将一步一步地告诉您在这一点上我做了什么,如果有人帮助我,我将非常有帮助,并且我将发送一个巧克力蛋糕:D

First I create my maven project in Eclipse, in my localhost, everything went ok. 首先,我在Eclipse中的localhost中创建了maven项目,一切正常。

So I send the code to github : https://github.com/ViniMartinPS/olimpiadas 所以我将代码发送到github: https : //github.com/ViniMartinPS/olimpiadas

But I dont think the code will be very helpfull here, in my head, the problem is configs. 但是我认为代码在这里不会很有帮助,在我看来,问题在于配置。

I create my app in Heroku and did the deploy using the git code, no problems, deploy OK. 我在Heroku中创建了我的应用程序,并使用git代码进行了部署,没有问题,部署成功。 I also downloaded 2 plugins : Heroku Postgree and JawsDB MySQL, but I didnt change anything. 我还下载了2个插件:Heroku Postgree和JawsDB MySQL,但我没有做任何更改。 My code is just a test to see if Heroku is working for me. 我的代码只是测试,看看Heroku是否为我工作。

So, I thought was everything ok to test but I have the error message when I tried to access the page: 因此,我认为可以进行所有测试,但是尝试访问该页面时出现错误消息:

" An error occurred in the application and your page could not be served. Please try again in a few moments. “应用程序中发生错误,无法提供您的页面。请稍后重试。

If you are the application owner, check your logs for details." 如果您是应用程序所有者,请检查您的日志以获取详细信息。”

And I have that in the log : 我在日志中有:

2016-08-23T19:00:49.102379+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/games/webapi/jogos/esporte1" host=thawing-temple-28369.herokuapp.com request_id=f5edce97-25b5-4b6a-8139-47c6083260c9 fwd="179.132.109.129" dyno= connect= service= status=503 bytes=
2016-08-23T19:00:49.588961+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=thawing-temple-28369.herokuapp.com request_id=f0c3ff79-2d70-4fa7-ad0a-b810ec9a6d38 fwd="179.132.109.129" dyno= connect= service= status=503 bytes=

Then I research to see about Dynos/Procfiles and I tried to create one and paste into Heroku: 然后,我研究了有关Dynos / Procfiles的问题,并尝试创建一个并粘贴到Heroku中:

web: java $JAVA_OPTS -cp target/classes:target/olimpiadas/games/MyResource 

MyResource is a class example that I have in my project. MyResource是我的项目中的类示例。

then I restart the dynos : 然后我重新启动dynos:

2016-08-23T19:03:10.002566+00:00 heroku[web.1]: State changed from crashed to starting
2016-08-23T19:03:12.998462+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -cp target/classes:target/olimpiadas/games/MyResource`
2016-08-23T19:03:15.501843+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2016-08-23T19:03:15.506279+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2016-08-23T19:03:15.728591+00:00 app[web.1]:            (to execute a jar file)
2016-08-23T19:03:15.728598+00:00 app[web.1]:     -cp <class search path of directories and zip/jar files>
2016-08-23T19:03:15.728603+00:00 app[web.1]:     -version      print product version and exit
2016-08-23T19:03:15.728604+00:00 app[web.1]:     -version:<value>
2016-08-23T19:03:15.728609+00:00 app[web.1]:                   in a future release.
2016-08-23T19:03:15.728613+00:00 app[web.1]:     -disableassertions[:<packagename>...|:<classname>]
2016-08-23T19:03:15.728618+00:00 app[web.1]:                   see also, -agentlib:jdwp=help and -agentlib:hprof=help
2016-08-23T19:03:15.841736+00:00 heroku[web.1]: Process exited with status 1
2016-08-23T19:03:15.875119+00:00 heroku[web.1]: State changed from starting to crashed
2016-08-23T19:03:15.876084+00:00 heroku[web.1]: State changed from crashed to starting
2016-08-23T19:03:18.382238+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -cp target/classes:target/olimpiadas/games/MyResource`
2016-08-23T19:03:20.004342+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2016-08-23T19:03:20.009058+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2016-08-23T19:03:20.401910+00:00 app[web.1]: Usage: java [-options] class [args...]
2016-08-23T19:03:20.401923+00:00 app[web.1]:            (to execute a class)
2016-08-23T19:03:20.401924+00:00 app[web.1]:    or  java [-options] -jar jarfile [args...]
2016-08-23T19:03:20.401928+00:00 app[web.1]: 
2016-08-23T19:03:20.401929+00:00 app[web.1]:     -classpath <class search path of directories and zip/jar files>
2016-08-23T19:03:20.401930+00:00 app[web.1]:     -D<name>=<value>
2016-08-23T19:03:20.401934+00:00 app[web.1]:                   Warning: this feature is deprecated and will be removed
2016-08-23T19:03:20.401938+00:00 app[web.1]:                   disable assertions with specified granularity
2016-08-23T19:03:20.401940+00:00 app[web.1]:                   load native agent library <libname>, e.g. -agentlib:hprof
2016-08-23T19:03:20.401947+00:00 app[web.1]: See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
2016-08-23T19:03:20.459704+00:00 heroku[web.1]: Process exited with status 1
2016-08-23T19:03:20.459575+00:00 heroku[web.1]: State changed from starting to crashed

I have the same error if I try to use the page again. 如果我再次尝试使用该页面,则会遇到相同的错误。 Probably this Procfile is wrong, or I need to add something else about databases, I dont know. 此Procfile可能是错误的,或者我需要添加有关数据库的其他信息,我不知道。

Can someone help me ? 有人能帮我吗 ? I really need to deploy this application, I will be very happy :) 我真的需要部署此应用程序,我会很高兴的:)

Thank you so much 非常感谢

There is something wrong with the command in the Procfile , but I'm not certain what it is. Procfile的命令有Procfile ,但是我不确定它是什么。 To start, reduce your Procfile to just this: 首先,将您的Procfile为:

web: java -cp target/classes:target/olimpiadas/games/MyResource

EDIT 编辑

I just realized this command has no main class. 我只是意识到此命令没有主类。 that is the problem. 那就是问题所在。 Is olimpiadas.games.MyResource your main class? olimpiadas.games.MyResource是您的主要课程吗?

@codefinger @codefinger

thats my MyResource: 多数民众赞成在我的MyResource:

package olimpiadas.games;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * Root resource (exposed at "myresource" path)
 */
@Path("myresource")
public class MyResource {

    /**
     * Method handling HTTP GET requests. The returned object will be sent
     * to the client as "text/plain" media type.
     *
     * @return String that will be returned as a text/plain response.
     */
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getIt() {
        return "Got it!";
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM