mvn archetype:generate -DarchetypeArtifactId=jersey-heroku-webapp \
-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=
false
\
-DgroupId=com.example -DartifactId=simple-heroku-webapp -Dpackage=com.example \
-DarchetypeVersion=3.0.1
There should be run instructions in section
1.5. Creating a Web Application that can be deployed on Heroku
following the text:
To compile and package the application into a WAR, invoke the following maven command in your console:
mvn clean package
mvn jetty:run for adding code and developing applications in the local development environment.
Once the application to heroku website is uploaded the main function is used to run the code not the mvn jetty:run
The jetty engine which is run in the main function does not offer the same functionality as mvn jetty:run during development.
so the class com.example.heroku.Main needs to be updated accordingly for the application to behave in the same way
during development and run time deployment on the internet. Which it doesn't at the moment.
This is more of a bug than enhancement.
I know young children especially from the third world who want to learn dynamic web application technology and display their work
on the internet free but can't afford to do so will benefit from it.
package com.example.heroku;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
/**
* This class launches the web application in an embedded Jetty container. This is the entry point to your application. The Java
* command that is used for launching should fire this main method.
*/
public class Main {
public static void main(String[] args) throws Exception{
// The port that we should run on can be set into an environment variable
// Look for that variable and default to 8080 if it isn't there.
String webPort = System.getenv("PORT");
if (webPort == null || webPort.isEmpty()) {
webPort = "8080";
}
final Server server = new Server(Integer.valueOf(webPort));
final WebAppContext root = new WebAppContext();
root.setContextPath("/");
// Parent loader priority is a class loader setting that Jetty accepts.
// By default Jetty will behave like most web containers in that it will
// allow your application to replace non-server libraries that are part of the
// container. Setting parent loader priority to true changes this behavior.
// Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
root.setParentLoaderPriority(true);
final String webappDirLocation = "src/main/webapp/";
root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
root.setResourceBase(webappDirLocation);
server.setHandler(root);
server.start();
server.join();
}
}