Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty 8 standalone and Servlet 3.0 without web.xml

You didn't say spring, so I went with standard Servlet 3.0 behavior.

The source for TimeServlet.

package org.eclipse.demo;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
@WebServlet(urlPatterns="/time")
public class TimeServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        resp.setContentType("text/plain");
        resp.getWriter().println(new Date());
    }
}

Its a rather simple class.



--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Thu, Jan 15, 2015 at 11:39 AM, Nir Barel <nirba@xxxxxxxxxxxxxx> wrote:
Hi

You use @WebServlet annotation and not spring WebApplicationInitializer that doesn't use it as I understand from their docs.

I still don't understand how jetty should start spring framework just by searching for WebApplicationInitializer classes??

Can you share the code of TimeServlet?

Sent securely from my iPad

From: Joakim Erdfelt
Sent: Thursday, January 15, 2015 at 19:55:48
To: JETTY user mailing list
Subject: Re: [jetty-users] Jetty 8 standalone and Servlet 3.0 without web.xml

It works here ...

$ jar -tvf webapps/webapp-3.0-bare.war 
     0 Thu Jan 15 10:42:14 MST 2015 META-INF/
   131 Thu Jan 15 10:42:14 MST 2015 META-INF/MANIFEST.MF
     0 Thu Jan 15 10:42:14 MST 2015 WEB-INF/
     0 Thu Jan 15 10:42:14 MST 2015 WEB-INF/classes/
     0 Thu Jan 15 10:42:14 MST 2015 WEB-INF/classes/org/
     0 Thu Jan 15 10:42:14 MST 2015 WEB-INF/classes/org/eclipse/
     0 Thu Jan 15 10:42:14 MST 2015 WEB-INF/classes/org/eclipse/demo/
  1055 Thu Jan 15 10:42:14 MST 2015 WEB-INF/classes/org/eclipse/demo/TimeServlet.class
  3756 Thu Jan 15 10:42:06 MST 2015 META-INF/maven/org.eclipse.jetty.demo/webapp-3.0-bare/pom.xml
   136 Thu Jan 15 10:42:14 MST 2015 META-INF/maven/org.eclipse.jetty.demo/webapp-3.0-bare/pom.properties

Running the server :

2015-01-15 10:51:57.553:INFO:oejs.Server:jetty-8.1.16.v20140903
2015-01-15 10:51:57.568:INFO:oejdp.ScanningAppProvider:Deployment monitor /home/joakim/jetty-distros/jetty-distribution-8.1.16.v20140903/webapps at interval 1
2015-01-15 10:51:57.573:INFO:oejd.DeploymentManager:Deployable added: /home/joakim/jetty-distros/jetty-distribution-8.1.16.v20140903/webapps/webapp-3.0-bare.war
2015-01-15 10:51:57.600:INFO:oejw.WebInfConfiguration:Extract jar:file:/home/joakim/jetty-distros/jetty-distribution-8.1.16.v20140903/webapps/webapp-3.0-bare.war!/ to /tmp/jetty-0.0.0.0-8080-webapp-3.0-bare.war-_webapp-3.0-bare-any-/webapp
2015-01-15 10:51:58.038:INFO:oejdp.ScanningAppProvider:Deployment monitor /home/joakim/jetty-distros/jetty-distribution-8.1.16.v20140903/contexts at interval 1
2015-01-15 10:51:58.052:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
2015-01-15 10:51:58.194:INFO:oejus.SslContextFactory:Enabled Protocols [SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2] of [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2]
2015-01-15 10:51:58.197:INFO:oejs.AbstractConnector:Started SslSelectChannelConnector@0.0.0.0:8443
^C
2015-01-15 10:52:24.953:INFO:oejs.Server:Graceful shutdown SslSelectChannelConnector@0.0.0.0:8443
2015-01-15 10:52:24.953:INFO:oejs.Server:Graceful shutdown SelectChannelConnector@0.0.0.0:8080
2015-01-15 10:52:24.953:INFO:oejs.Server:Graceful shutdown o.e.j.w.WebAppContext{/webapp-3.0-bare,file:/tmp/jetty-0.0.0.0-8080-webapp-3.0-bare.war-_webapp-3.0-bare-any-/webapp/},/home/joakim/jetty-distros/jetty-distribution-8.1.16.v20140903/webapps/webapp-3.0-bare.war
2015-01-15 10:52:26.012:INFO:oejsl.ELContextCleaner:javax.el.BeanELResolver purged
2015-01-15 10:52:26.012:INFO:oejsh.ContextHandler:stopped o.e.j.w.WebAppContext{/webapp-3.0-bare,file:/tmp/jetty-0.0.0.0-8080-webapp-3.0-bare.war-_webapp-3.0-bare-any-/webapp/},/home/joakim/jetty-distros/jetty-distribution-8.1.16.v20140903/webapps/webapp-3.0-bare.war

Testing the specified @WebServlet ...

Thu Jan 15 10:52:19 MST 2015
$


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Wed, Jan 14, 2015 at 1:57 AM, Nir Barel <nirba@xxxxxxxxxxxxxx> wrote:

Hi,

 

I am trying to run Jetty 8 standalone ( not embedded ) and to use the servlet 3.0 code configuration capabilities using WebApplicationInitializer

When I deploy my war ( includes servlet 3.0 APIs ) the jetty choose to use the defaultweb.xml

that configured to use servlet 2.5 and therefore it doesn’t call my WebApplicationInitializer class.

 

Does it supported for not embedded jetty?

How can I tell jetty not to use web.xml or defaultweb.xml at all?

 

 

From the jetty debug log:

 

2015-01-14 10:54:24,722 DEBUG org.eclipse.jetty.webapp.WebInfConfiguration.unpack:508 [main] - webapp=file:/var/log/opt/tmp/jetty-127.0.0.1-8443-web.war-_web-any-/webapp/

2015-01-14 10:54:24,737 DEBUG org.eclipse.jetty.webapp.WebAppContext.preConfigure:456 [main] - preConfigure o.e.j.w.WebAppContext{/web,file:/var/log/opt/tmp/jetty-127.0.0.1-8443-web.war-_web-any-/webapp/},/opt

/webapps/web.war with org.eclipse.jetty.webapp.WebXmlConfiguration@6dc0d731

2015-01-14 10:54:24,766 DEBUG org.eclipse.jetty.webapp.WebDescriptor.processVersion:207 [main] - jar:file:/opt/jetty/lib/jetty-webapp-8.1.12.v20130726.jar!/org/eclipse/jetty/webapp/webdefault.xml: Calculated metadatacomplete =

True with version=2.5

2015-01-14 10:54:24,767 DEBUG org.eclipse.jetty.webapp.WebXmlConfiguration.findWebXml:114 [main] - No WEB-INF/web.xml in /opt/webapps/web.war. Serving files and default/dynamic servlets only

2015-01-14 10:54:24,767 DEBUG org.eclipse.jetty.webapp.WebAppContext.preConfigure:456 [main] - preConfigure o.e.j.w.WebAppContext{/web,file:/var/log/opt/tmp/jetty-127.0.0.1-8443-web.war-_web-any-/webapp/},/opt

/webapps/web.war with org.eclipse.jetty.webapp.MetaInfConfiguration@6357be97

 

 

 

 


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



Email secured by Check Point



Back to the top