As the title states, I get a java.lang.AbstractMethodError on a method that is definitively implemented by my class. The complete error message is:
java.lang.AbstractMethodError: htmlexport.HTMLExport.getParameterFormDescriptor()Ljava/util/List;
I have an interface that defines the method as follows:
List getParameterFormDescriptor();
And as I said this method is implemented by the implementing class.
The interface is included in a jar that is in my local Maven repository. I already tried mvn clean and mvn install and bumping the version number, but this does not solve the problem.
The implementing class is in another jar file which I create using an ANT-script. The file is then loaded via a ClassLoader in the main application.
Any clues why I get this error? All other methods defined by the interface are working.
Here comes the code
I have a Wicket WebPage where I make the call to this method:
public class AddJobPage extends BasePage {
public AddJobPage(final PageParameters params) {
super(params);
final Workable w =
WorkableManager.getInstance().findWorkableByName(params.get("workableName").toString());
w.getParameterFormDescriptor();
}
}
The WorkableManager internally loads the jar-file which includes the implementing class using an URLClassLoader. This is working fine and I get an instance
of the needed class.
The interface that defines the method is:
public interface Workable {
List getParameterFormDescriptor();
}
And the implementing class looks like this (Module extends Workable):
public class HTMLExport implements Module {
@Override
public final List getParameterFormDescriptor() {
final List form = new ArrayList<>();
form.add(new ParamFormElement(ParamFormElement.Type.TEXT, "Bitte eingeben:", "test"));
return form;
}
}
The interface is in a separate project and assembled as a jar-file in my local Maven repository. The HTMLExport class is in a different project, too and
compiled and assembled using Ant. The resulting jar-file is in a folder next to my main application and as I said loading the class works. The main application
is a Maven project and has the interface added as a dependency. In Eclipse I do not have any errors or warnings.
The stacktrace is following:
Root cause:
java.lang.AbstractMethodError: htmlexport.HTMLExport.getParameterFormDescriptor()Ljava/util/List;
at web.pages.AddJobPage.(AddJobPage.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:171)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:99)
at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:137)
at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
at org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:300)
at org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:342)
at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:203)
at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1631)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:549)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1111)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:478)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1045)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:462)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:279)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:534)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
at java.lang.Thread.run(Thread.java:722)
Complete stack:
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public web.pages.AddJobPage(org.apache.wicket.request.mapper.parameter.PageParameters)' and argument 'workableName=[HTML Export]'. An exception has been thrown during construction!
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:194)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:99)
at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:137)
at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
at org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:300)
at org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:342)
at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:203)
at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:171)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:99)
at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:137)
at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
at org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:300)
at org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:342)
at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:203)
at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)
解决方案
The problem was that the implementing class was not compiled correctly and the Ant script did not copy the correct class into the jar-file. I converted it to a maven project and now the method can be found.