question

GregoryKnott-6972 avatar image
0 Votes"
GregoryKnott-6972 asked GregoryKnott-6972 answered

MSAL4JSample startup exception in authFilter

From tomcat deployment:

27-Aug-2021 14:22:01.726 SEVERE [localhost-startStop-2] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [authFilter]
java.lang.AbstractMethodError
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:110)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4538)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:970)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1840)
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)

  • OR - from IDE:

2021-08-27 14:17:23.079 ERROR 19656 --- [ost-startStop-1] o.a.c.c.C.[.[.[/msal-web-sample] : Exception starting filter [authFilter]

java.lang.AbstractMethodError: null
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:283) ~[catalina.jar:8.5.46]
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:112) ~[catalina.jar:8.5.46]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4546) [catalina.jar:8.5.46]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5191) [catalina.jar:8.5.46]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.46]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1412) [catalina.jar:8.5.46]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1402) [catalina.jar:8.5.46]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_212]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]


azure-ad-msal
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @gregoryknott-6972,

Thanks for using Microsoft Q&A!!
Can you please share the MSAL4J Sample which you are referring to ?

Thanks
Saurabh

0 Votes 0 ·

@gregoryknott-6972 Are you getting this error during deployment ? Are you deploying on a container ?

Thanks
Saurabh

0 Votes 0 ·

This is on Spring startup, the application never gets initialized and the endpoints never become available.

This error occurs when deploying the war to Tomcat v8.5 and is viewed in the tomcat logs.
This error also occurs when running the app from Eclipse IDE.

0 Votes 0 ·

1 Answer

GregoryKnott-6972 avatar image
0 Votes"
GregoryKnott-6972 answered

I have fixed several issues with the sample code and it is now working for me. I ended up creating a fresh spring boot application from https://start.spring.io/

Issue 1:

The @SprintBootApplication annotation in the main application file did not seem to be scanning the java package for other classes marked with @Component and @Controller etc. To fix I had to also add e.g. @ComponentScan("org.example.msal4jsample")

Use the package name for your project.



Issue 2:

The @RequestMapping annotations on the routes in the PageController file are incorrect and I had to shorten them to just "/", "/secure/aad", "/sign_out", "/graph/me"



Issue 3:

An exception occurs as posted above from the AuthFilter class since it implements javax.servlet.FIlter. I had to add the following lines to correct:

     @Override
     public void init(FilterConfig config) {}
        
     @Override
     public void destroy() {}


Issue 4:

In the getAuthResulteByAuthCode function in the AuthHelper class -> the URI passed in parameters to acquireToken must have the full redirectUriSignin from config rather that the currentUri passed from the AuthFilter class.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.