title: 'javax.servlet.ServletContext' that could not be found
body: <p>I have a Springboot application as follows:</p>
  
  <pre><code>@SpringBootApplication
  @ImportResource("classpath:/config/applicationContext.xml")
  public class TaxBatchMain {
  
      @Autowired
      TaxIdService taxIdService;
  
      private static final Logger LOGGER = LogManager.getLogger(TaxBatchMain.class);
  
      public static void main(String[] args) {
  
          new SpringApplicationBuilder(TaxBatchMain.class).web(false).run(args);
          TaxBatchMain taxBatchMain = new TaxBatchMain();
  
      }
  
      public TaxBatchMain() {
  
          SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
  
      }
  
      @PostConstruct
      public void checkForTransactions() {
  
          try {
          ////
              String tab = "someother content";
  
              String footer  = taxIdService.formatFooter();
              ////
              ////
          }catch(){
          //////////
  
          }
      }
  
  }
  </code></pre>
  
  <p>TaxIdServiceImpl class is as follows:</p>
  
  <pre><code>@Service
  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
  public class TaxIdServiceImpl implements TaxIdService {
  
  
      @Autowired
      private ServletContext servletContext;
  
       private String formatFooter(String footer) {
          String[] searchList = {"&lt;ENVIRONMENT_NAME&gt;", "&lt;MS_ENV_NAME&gt;"};
          String[] replacementList = {(String) servletContext.getAttribute(ServletContextKey.EMAIL_HOST_NAME.name()),
            (String) servletContext.getAttribute(ServletContextKey.MS_EMAIL_HOST_NAME.name())};
  
          return StringUtils.replaceEach(footer, searchList, replacementList);
      }
  
  }
  </code></pre>
  
  <p>Application Context looks like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"....................///
  
  
  &lt;context:annotation-config /&gt;
  
      &lt;context:property-placeholder location="classpath:/config.properties" /&gt;
  
      &lt;util:properties id="configProperties" location="classpath:/config.properties" /&gt;
  
    &lt;!--   &lt;context:property-placeholder location="classpath:data/application.properties"/&gt; --&gt;
  
      &lt;context:component-scan base-package="com.tax.main" /&gt; 
      &lt;context:component-scan base-package="com.tax.service" /&gt;
      &lt;context:component-scan base-package="com.tax.model" /&gt;
      &lt;context:component-scan base-package="com.tax.mapper" /&gt;
      &lt;context:component-scan base-package="com.tax.util" /&gt;
  
      /////
  </code></pre>
  
  <p>When I run the main class i get foll. error</p>
  
  <p>APPLICATION FAILED TO START</p>
  
  <hr>
  
  <p>Description:</p>
  
  <p>Field servletContext in com.tax.service.TaxIdServiceImpl required a bean of type 'javax.servlet.ServletContext' that could not be found.</p>
  
  <p>Action:</p>
  
  <p>Consider defining a bean of type 'javax.servlet.ServletContext' in your configuration.</p>