简体   繁体   中英

AWS Tomcat on Elastic Beanstalk servlet Filter

I'm trying to launch my web application for the first time on AWS Elastic Beanstalk (platform: Tomcat 8 with Java 8 running on 64bit Amazon Linux/3.0.0).

It succeeds in creating the application in beanstalk but when it tries to launch my application (uploaded with a war) it throws an error:

04-Jun-2018 20:44:02.060 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter SecurePathFilter
java.lang.AbstractMethodError
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4708)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5348)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1126)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1868)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

The SecurePathFilter is a javax.servlet.Filter class so I'm thinking it might be that jsp and servlet api jars are missing on the tomcat (or perhaps some other version of what I used locally) but how can I check this? And how could I add/change them?

Edit: As requested, the relevant pieces of my web.xml:

<filter>
    <filter-name>SecurePathFilter</filter-name>
    <filter-class>be.qsds.sade.filters.SecurePathFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>SecurePathFilter</filter-name>
    <url-pattern>/secure/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
</filter-mapping>

and my SecurePathFilter class is roughly:

public class SecurePathFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        ...

        filterChain.doFilter(request, response);
    }
}

@jontro led me in the right direction of the solution to my problem. I was building my application locally with the latest version of javax.servlet-api (4.0.1), where the Tomcat8.5 auto deployed on AWS uses an older version (3.1.0).

I changed the version in my pom, added some missing methods, rebuilt and uploaded my war and eureka!

Thanks for the guidance!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM