Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty 8.1 annotations

take a look at this for the list of configurations and order

http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-annotations/src/main/config/etc/jetty-annotations.xml?h=jetty-8

--
jesse mcconnell
jesse.mcconnell@xxxxxxxxx



2012/2/13 Andreas Schöneck <as.maps@xxxxxxxxx>:
> Generally speaking, I bet Jetty won't do the scanning for annotations for
> you unless you explicitly advise it to.
>
> I came across a class org.eclipse.jetty.annotations.AnnotationConfiguration
> which might be a good starting point for further research.
>
>
> On Mon, Feb 13, 2012 at 2:02 PM, <jeffrey@xxxxxxxxxxxxxxx> wrote:
>>
>> 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
>> jetty-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>


Back to the top