Skip to main content

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

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


Back to the top