I used this archetype.

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



running   as  mvn jetty:run


I made this hack by adding a new class
HelloHandler and commenting out the  line server.setHandler(root)
 , which has worked so far but it is just a hack in the existing Main
class. I was hoping I can just an index.html but seems to be too good to be
true.  I guess I will have to rework the existing Main class.

//        server.setHandler(root);
          server.setHandler(new HelloHandler());

public class HelloHandler extends AbstractHandler
{
    public void handle(String target,Request baseRequest,HttpServletRequest
request,HttpServletResponse response)
        throws IOException, ServletException
    {
        response.setContentType("text/html;charset=utf-8");
        response.setStatus(HttpServletResponse.SC_OK);
        baseRequest.setHandled(true);
        response.getWriter().println("<h1>Hello World</h1>");
    }
}


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
behaviour.
        // 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.setHandler(new HelloHandler());
        server.start();
        server.join();
    }
}







On Wed, 24 Mar 2021, 23:13 Jan Bartel, <[email protected]> wrote:

> Hi,
>
> How are you running jetty? Are you running in the
> distribution/embedded/maven plugin? Do you have jsp and it's dependencies
> enabled?
>
> Making a very simple webapp that is a directory that looks like:
>
> /test
>   index.jsp
>
> deploys and runs just fine on the jetty-11 distro, so there must be
> something else going on with your setup.
>
> Firstly, I would make sure you're using the latest full release version of
> jetty-11, which is 11.0.1. Then build up from a simple webapp like the one
> above gradually adding more of your app in until you can see where the
> problem lies.
>
> regards
> Jan
>
> On Thu, 25 Mar 2021 at 09:19, Som Lima <[email protected]> wrote:
>
>> Hi,
>>
>> I am using  working on the heroku  archetype   webapp  for  jersey jax-rs
>>  section 5.1
>>
>>
>> https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest3x/getting-started.html#deploy-it-on-heroku
>>
>> It is publishing   jax-rs resources.
>>
>> https://lit-savannah-55019.herokuapp.com/myresource
>>
>> The archetype seem to have everything
>> to be a webapp also , so I thought I just need to drop jsp in the
>> src/main/webapp/index.jsp
>>
>> Adding welcome-file-list tag and
>> welcome-file  tag with index.jsp.
>> in the web.xml file.
>>
>> That didn't do the trick.
>>
>> I got a 404.
>> running jetty  11.0.0.beta3.
>>
>> Can you please tell me what  more is needed for the index.jsp to be
>> published
>> .
>>
>> Regards
>>
>>
>>
>> _______________________________________________
>> jetty-users mailing list
>> [email protected]
>> To unsubscribe from this list, visit
>> https://www.eclipse.org/mailman/listinfo/jetty-users
>>
>
>
> --
> Jan Bartel <[email protected]>
> www.webtide.com
> *Expert assistance from the creators of Jetty and CometD*
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to