title: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource
body: <p>I have a Spring + Maven project which I wanted to run on Tomcat 7.0.69. 
  When I do it by script everything works fine. Here is prepare script:</p>
  
  <pre><code>    #!/bin/bash
  
  PROFILE=$1
  CONFIG_REPO=../../configuration
  DEPLOY_DIR=tomcat-deploy
  WAR_PREFIX=ppp-web/
  WAR_NAME=ppp$(echo $PROFILE | tr '[:upper:]' '[:lower:]').war
  
  validate_profile() {
      if [[ $PROFILE != 'AS' &amp;&amp; $PROFILE != 'TN' &amp;&amp; $PROFILE != 'HS' ]]; then
          echo "Incorrect application profile chosen: $PROFILE. Use TN, AS or HS."
          exit 1
      fi
  }
  
  validate_environment_settings() {
      if [[ -z "$CATALINA_HOME" ]]; then
          echo -e "\e[1;31m"
          echo -e "ERROR: ***************************************************************************************"
          echo -e "ERROR: *** You must set CATALINA_HOME environment variable before trying to deploy Tomcat. ***"
          echo -e "ERROR: ***************************************************************************************"
          echo -e "\e[0m"
          exit 1
      fi
  }
  
  setup_deploy_dir () {
      echo "Setting up deploy directory $DEPLOY_DIR ..."
  
      rm -rf $DEPLOY_DIR
  
      mkdir -p $DEPLOY_DIR/bin
      mkdir -p $DEPLOY_DIR/conf
      mkdir -p $DEPLOY_DIR/lib
      mkdir -p $DEPLOY_DIR/logs
      mkdir -p $DEPLOY_DIR/temp
      mkdir -p $DEPLOY_DIR/webapps
      mkdir -p $DEPLOY_DIR/webapps-conf
      mkdir -p $DEPLOY_DIR/webapps-lib
      mkdir -p $DEPLOY_DIR/work
  
      cp $CATALINA_HOME/bin/tomcat-juli.jar $DEPLOY_DIR/bin/
  }
  
  copy_if_exists () {
      local src=$1
      local dest=$2
  
      if [[ -e $src ]]; then
          echo "-&gt; Copying file $src to $dest ..."
          cp -r $src $dest
      else
          echo "-&gt; Directory or file $src does not exist. Skipped."
      fi
  }
  
  copy_to_correct_directories () {
      local src=$1
      local f
      for f in $src/*; do
          if [[ $f == */conf ||\
                $f == */webapps-conf ||\
                $f == */bin ||\
                $f == */install-additional-libs.xml ]]; then
              copy_if_exists $f $DEPLOY_DIR
          else
              # any other file is copied to application configuration directory
              copy_if_exists $f $DEPLOY_DIR/webapps-conf
          fi
      done
  }
  
  prepare_configuration () {
      local app=$1
      local env=$2
      local box=$3
      local instance=$4
  
      echo "Preparing configuration ..."
  
      copy_to_correct_directories $CONFIG_REPO/common $DEPLOY_DIR
      copy_to_correct_directories $CONFIG_REPO/$app/common $DEPLOY_DIR
      copy_to_correct_directories $CONFIG_REPO/$app/$env/common $DEPLOY_DIR
      copy_to_correct_directories $CONFIG_REPO/$app/$env/$box/common $DEPLOY_DIR
      copy_to_correct_directories $CONFIG_REPO/$app/$env/$box/$instance $DEPLOY_DIR
  }
  
  create_instance_name () {
      local instance=$1
      echo "Creating instance.name.properties file ..."
      echo "instance.name = $instance" &gt; $DEPLOY_DIR/webapps-conf/instance.name.properties
  }
  
  install_additional_libs () {
      echo "Installing additional libs ..."
      mvn -f $DEPLOY_DIR/install-additional-libs.xml dependency:copy
  }
  
  copy_war () {
      echo "Copying $WAR_NAME ..."
      cp ${WAR_PREFIX}target/$WAR_NAME $DEPLOY_DIR/webapps/
  }
  
  validate_profile
  validate_environment_settings
  setup_deploy_dir
  prepare_configuration PPP-${PROFILE} LOCAL localhost PPP${PROFILE}-LOCAL
  create_instance_name PPP${PROFILE}-LOCAL
  install_additional_libs
  copy_war
  </code></pre>
  
  <p>and here is my run script:</p>
  
  <pre><code>#!/bin/bash
  
  validate_environment_settings() {
      if [[ -z "$CATALINA_HOME" ]]; then
          echo -e "\e[1;31m"
          echo -e "ERROR: ***************************************************************************************"
          echo -e "ERROR: *** You must set CATALINA_HOME environment variable before trying to deploy Tomcat. ***"
          echo -e "ERROR: ***************************************************************************************"
          echo -e "\e[0m"
          exit 1
      fi
  }
  
  start_tomcat_windows() {
      cmd /Q &lt;&lt; EOF
  set CATALINA_BASE=%cd%\\tomcat-deploy
  %CATALINA_HOME%\\bin\\startup.bat
  EOF
  }
  
  start_tomcat_unix() {
      export CATALINA_BASE=$(pwd)/tomcat-deploy
      $CATALINA_HOME/bin/startup.sh
  }
  
  start_tomcat() {
      local system=$(uname -s)
  
      case $system in
          MINGW*)
              start_tomcat_windows
              ;;
  
          Linux|CYGWIN*)
              start_tomcat_unix
              ;;
  
          *)
              echo "Unsupported system: $system"
              exit 1
      esac
  }
  
  validate_environment_settings
  start_tomcat
  </code></pre>
  
  <p>As I said before when I do it from cmd everything works fine. But when I'm trying to run it from IntelliJ Idea 2016.2 I'm getting error:</p>
  
  <pre><code>org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [eps.properties] cannot be opened because it does not exist
  </code></pre>
  
  <p>File eps.properties is under PROJECT\profiles-ppp\tomcat-deploy\webapps-conf.</p>
  
  <p>The reference to it is in applicationContext.xml:</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:eps.properties,classpath:ppp-mom.properties,classpath*:*instance.name.properties,classpath:ppp.db.properties"/&gt;
  </code></pre>
  
  <p>The VM options are:</p>
  
  <pre><code>-Xmx1024m
  -XX:MaxPermSize=512m
  </code></pre>
  
  <p>Can anybody tell me what I'm doin wrong? Thanks in advance.</p>