Jetty Version: 8.1.0-RC2
OS           : Linux-Ubuntu: 10.10
JVM Version  : java version "1.6.0_26"
               Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
               Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)


I am using Jetty in an embedded fashion and am having difficulties with
the annotations for
Servlet 3.0.

My server code is such:

        WebAppContext context = new WebAppContext();

        context.setConfigurations( new
org.eclipse.jetty.webapp.Configuration[] {
                new AnnotationConfiguration(), new WebXmlConfiguration(),
                new WebInfConfiguration(), new TagLibConfiguration(),
                new PlusConfiguration(), new MetaInfConfiguration(),
                new FragmentConfiguration(), new EnvConfiguration() });

        context.setDescriptor("webapp/WEB-INF/web.xml");
        context.setResourceBase("webapp");
        context.setContextPath("/");
        context.setParentLoaderPriority(true);
        
context.setSessionHandler(ServiceManager.getSessionService().getSessionHandler());


        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[]{context});

        server.setHandler(contexts);


I have a servlet defined as such:

@WebServlet(name="commandServlet", urlPatterns = {"/commander"},
asyncSupported=true)
public class OCSServlet extends HttpServlet
{

    /**
     *
     */
    private static final long serialVersionUID = 531143127788829466L;

    /* (non-Javadoc)
     * @see
javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)
     */
    @Override

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException
    {
        AsyncContext ctx = req.startAsync(req, resp);
        /** ... do something ... **/
    }

}

Note that I have set a breakpoint on the doGet() method.


I have made sure that the appropriate jar files are in the classpath.
However,
when I go to the http://localhost:8080/commander url, my servlet never gets
invoked, i.e. the debugger never stops at my breakpoint and the browser
returns
HTTP ERROR 404

Problem accessing /commander. Reason:

    Not Found
Powered by Jetty://

Is there anything specific that I must do for the annotated servlet
classes to be
loaded?  Do the class files have to be under the webapp/classes directory?
 If I
I specify the context, like

        ServletContextHandler ctx = new
ServletContextHandler(ServletContextHandler.SESSIONS);
        ctx.addServlet(OCSServlet.class, "/commander");

then things are fine, but of course, this isn't loaded by annotation and
my servlet class
is loaded from my classpath.

Thank you all for the help.

Jeff

_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to