如何修复此NoSuchMethodError?

时间:2017-05-16 15:01:33

标签: java servlets nosuchmethoderror

我在运行Java程序时遇到NoSuchMethodError错误。什么错了,我该如何解决?

>5월 16, 2017 11:44:31 오후 org.apache.catalina.core.StandardWrapperValve invoke
심각: Servlet.service() for servlet [appServlet] in context with path [/abs] threw exception [javax.servlet.ServletException: java.lang.NoSuchMethodError: com.abilsys.abs.common.taglib.selected.ABSSelectedTag.doFinally()V] with root cause
java.lang.NoSuchMethodError: com.abilsys.abs.common.taglib.selected.ABSSelectedTag.doFinally()V
    at org.apache.jsp.WEB_002dINF.views.abs.system.acnt.acntView_jsp._jspx_meth_abs_005fselect_005f0(acntView_jsp.java:926)
    at org.apache.jsp.WEB_002dINF.views.abs.system.acnt.acntView_jsp._jspService(acntView_jsp.java:263)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:266)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1225)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1012)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:509)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1524)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

我的代码是

package com.abilsys.abs.common.taglib.selected;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.abilsys.abs.common.taglib.selected.generator.SelectedGenerator;
import com.abilsys.abs.common.taglib.selected.service.SelectedService;
import com.abilsys.abs.common.taglib.selected.vo.SelectedVO;

public class ABSSelectedTag extends TagSupport {

    protected String id = null;
    protected String name = null;
    protected String value = null;
    protected String cssClass = null;
    protected String groupCode = null;
    protected String contextPath = null;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getGroupCode() {
        return groupCode;
    }

    public void setGroupCode(String groupCode) {
        this.groupCode = groupCode;
    }

    public String getCssClass() {
        return cssClass;
    }

    public void setCssClass(String cssClass) {
        this.cssClass = cssClass;
    }

    public String getContextPath() {
        return contextPath;
    }

    public void setContextPath(String contextPath) {
        this.contextPath = contextPath;
    }

    public SelectedVO getSelectedVo(){
        SelectedVO selectedVO = new SelectedVO();

        HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
        selectedVO.setContextPath(request.getContextPath().toString());
        selectedVO.setId(id);
        selectedVO.setName(name);
        selectedVO.setValue(value);
        selectedVO.setCssClass(cssClass);
        selectedVO.setGroupCode(groupCode);

        return selectedVO;
    }

    public int doEndTag() throws JspException {
        StringBuffer sb = new StringBuffer();
        try
        {
            SelectedVO selectedVo = getSelectedVo();            
            List<Map<String, Object>> codeList = null;
            List<Map<String, Object>> sCodeList = null;

            HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

            WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
            SelectedService selectedService = (SelectedService) ctx.getBean("selectedService");

            codeList = selectedService.getCodeInfo(groupCode);
            pageContext.getOut().print(SelectedGenerator.generator(selectedVo, codeList));  

        }
        catch(IOException ioe) 
        {
            throw new JspTagException("Error:  IOException while writing to the user");
        } 
        catch(Exception e) 
        {
            throw new JspTagException("Error: " + e);
        }
        return SKIP_BODY;
    }
}

2 个答案:

答案 0 :(得分:0)

使用doEndTag()调用doFinally方法。当你执行try / catch块时,还有一个执行doFinally()的finally块。我想这可能是我们的问题。 Take a look here.

答案 1 :(得分:0)

doFinally() class:

中声明一个名为ABSSelectedTag的方法
public class ABSSelectedTag extends TagSupport {
    ...

    public void doFinally(){
        // your code goes here. I don't know what you want to do here.
    }
}

我默认将doFinally()的返回类型设为void。您可以将其更改为intString

有关NoSuchMethodError的详细信息,请阅读此post