Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] java.lang.InstantiationException with new Servlet, tho seen in war

Sorry about the line numbers - it's the last trunk version that built for me. Current build still fails due to NamingContext being gone, as I mentioned before.

Bill


-------- Original message --------
From: Jan Bartel
Date:10/14/2015 6:49 PM (GMT-08:00)
To: JETTY user mailing list
Subject: Re: [jetty-users] java.lang.InstantiationException with new Servlet, tho seen in war

Bill,

Well,  you're trying to instantiate an abstract class. Not going to work like that.

Jan
PS For future posts, please include the version of jetty you're using so the linenumbers are meaningful.

On 15 October 2015 at 12:37, Bill Ross <ross@xxxxxxxxxxxx> wrote:
I am getting an uninformative InstantiationException at startup with a new Servlet added to web.xml - it seems to be set up exactly like Servlets that have been working.

Here is some stack (no indication of cause, but if I comment the new Servlet out of web.xml, it goes away):

2015-10-14 18:18:52.413:WARN:/pr:main: unavailable
java.lang.InstantiationException
        at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at java.lang.Class.newInstance(Class.java:442)
        at org.eclipse.jetty.server.handler.ContextHandler$Context.createInstance(ContextHandler.java:2443)
        at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1306)
        at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:1193)
        at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:593)
        at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:403)


Comparing CommentServlet (fail) to GetNextServlet (works):

-- web.xml

    <servlet>
        <servlet-name>getnext</servlet-name>
        <servlet-class>com.priot.servlet.GetNext</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>getnext</servlet-name>
        <url-pattern>/getnext</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>comment</servlet-name>
        <servlet-class>com.priot.servlet.CommentServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>comment</servlet-name>
        <url-pattern>/comment</url-pattern>
    </servlet-mapping>

-- the war:

WEB-INF/classes/com/priot/servlet/CommentServlet.class
WEB-INF/classes/com/priot/servlet/GetNext.class

-- the code:

package com.priot.servlet;

public abstract class CommentServlet extends HttpServlet {

    @Override
    public void init(ServletConfig config) throws ServletException {
    }

    @Override
    public String getServletInfo() {
        return "CommentServlet";
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException  {
      ...
    }
}

Any ideas?

Thanks,
Bill
_______________________________________________
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



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
Expert assistance from the creators of Jetty and CometD


Back to the top