The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required .class files

If you have encountered this annoying error in Eclipse you are in luck. Here I will be telling you how to fix it!

First, right-click the project in Project Explorer and click Properties:

On the Properties screen type “build” and open Java Build Path screen:

 

As you can see we have a missing Library in our classpath. Type “facet” and open “Project Facets” screen:

 

Checkout the “Runtimes” on the right. One of the specified runtimes should be selected there. If none is selected, select the appropriate runtime and click “Apply”. Now go to “Java Build Path” screen again. You should see the library for the selected runtime environment in your build path.

 

Right-click your project in the Project Explorer, click Maven -> Update Project and the problem should be gone.

You can’t select a runtime¬†environment for your project in Eclipse. They are all disabled!

If that is the case, open the project folder in Finder, delete “.settings” folder and try to do the above again.

Hope this helps.
Good Luck,
Serdar