eclipse启动springboot项目报错

java.lang.AbstractMethodError: Receiver class org.apache.tomcat.websocket.server.WsSessionListener does not define or inherit an implementation of the resolved method 'abstract void sessionCreated(javax.servlet.http.HttpSessionEvent)' of interface javax.servlet.http.HttpSessionListener.
at org.apache.catalina.session.StandardSession.tellNew(StandardSession.java:388)
	at org.apache.catalina.session.StandardSession.setId(StandardSession.java:360)
	at org.apache.catalina.session.StandardSession.setId(StandardSession.java:341)
	at org.apache.catalina.session.ManagerBase.createSession(ManagerBase.java:686)
	at org.apache.catalina.connector.Request.doGetSession(Request.java:3027)
	at org.apache.catalina.connector.Request.getSession(Request.java:2416)
	at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:908)
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:270)

把StandardSession.java的源码放到工程中,打印listener对象

for (int i = 0; i < listeners.length; i++) {
                if (!(listeners[i] instanceof HttpSessionListener))
                    continue;
                HttpSessionListener listener =
                    (HttpSessionListener) listeners[i];
                try {
                    context.fireContainerEvent("beforeSessionCreated",
                            listener);
                    System.out.println(listener+"这里出错。");
                    listener.sessionCreated(event);
                    context.fireContainerEvent("afterSessionCreated", listener);
                } catch (Throwable t) {
                    ExceptionUtils.handleThrowable(t);
                    try {
                        context.fireContainerEvent("afterSessionCreated",
                                listener);
                    } catch (Exception e) {
                        // Ignore
                    }
                    manager.getContext().getLogger().error
                        (sm.getString("standardSession.sessionEvent"), t);
                }
            }

发现这个对象的类是org.apache.tomcat.websocket.server.WsSessionListener。

然后把WsSessionListener的源码放到工程中发现没有实现sessionCreated()方法

解决方法就是生成一个空的sessionCreated方法

package org.apache.tomcat.websocket.server;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class WsSessionListener implements HttpSessionListener{

    private final WsServerContainer wsServerContainer;


    public WsSessionListener(WsServerContainer wsServerContainer) {
        this.wsServerContainer = wsServerContainer;
    }


    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        wsServerContainer.closeAuthenticatedSession(se.getSession().getId());
    }


	@Override
	public void sessionCreated(HttpSessionEvent se) {
		/*开发环境增加本方法是为了解决
		 * java.lang.AbstractMethodError: 
		 * Receiver class org.apache.tomcat.websocket.server.WsSessionListener 
		 * does not define or inherit an implementation of the resolved 
		 * method 'abstract void sessionCreated(javax.servlet.http.HttpSessionEvent)' 
		 * of interface javax.servlet.http.HttpSessionListener.
		 */
		
	}
}

题解决。

原文地址:https://blog.csdn.net/memory235/article/details/132305066

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_44490.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注