title: Don't know how to register ServletContextListener in Spring Boot
body: <p>I am trying to <strong>rebuild</strong> my <strong>Spring-based</strong> web app on <strong>Spring boot</strong> beacuse I need it to be running on <strong>embedded Jetty</strong>.</p>
  
  <p>I imported all my spring-related <strong>xml configuration files</strong> to spring boot using <strong>@ImportResource</strong> annotation, but I also need my <strong>ServletContextListener</strong> implementation to be registered in Spring Boot cause it does some important stuff.</p>
  
  <p>How can I do it? I read <a href="https://stackoverflow.com/questions/32394862/how-to-register-servletcontextlistener-in-spring-boot">the topic</a> with the same question on the site but have not found clear answer there.</p>
  
  <p><strong>SpringBootApplication</strong></p>
  
  <pre><code>import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.context.annotation.ImportResource;
  
  @ImportResource({"classpath:spring/dispatcher-servlet.xml", "classpath:spring/spring-database.xml", "classpath:spring/spring-security.xml"})
  @SpringBootApplication
  public class DvdExchangeSpringBootApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(DvdExchangeSpringBootApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p><strong>My ServletContextListener</strong></p>
  
  <pre><code>import javax.servlet.ServletContextEvent;
  import javax.servlet.ServletContextListener;
  import javax.servlet.annotation.WebListener;
  
  
  public class WebAppPropertiesListener implements ServletContextListener {
  
      public void contextInitialized(ServletContextEvent servletContextEvent) {
          String rootPath = servletContextEvent.getServletContext().getRealPath("/");
          System.setProperty("webroot", rootPath);
  
          DBInitializer.initializeDB();
      }
  
      public void contextDestroyed(ServletContextEvent servletContextEvent) {
  
      }
  
  }
  </code></pre>
  
  <p>Even if I try to follow some of <a href="https://stackoverflow.com/questions/32394862/how-to-register-servletcontextlistener-in-spring-boot">mentioned advices</a> all I get is the error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [spring/spring-database.xml]: Could not resolve placeholder 'webroot' in string value "jdbc:hsqldb:file:${webroot}/WEB-INF/classes/DBStorage/testdb"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'webroot' in string value "jdbc:hsqldb:file:${webroot}/WEB-INF/classes/DBStorage/testdb"
      at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.processProperties(PropertySourcesPlaceholderConfigurer.java:177) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:152) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:166) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
      at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
      at com.dvdexchange.DvdExchangeSpringBootApplication.main(DvdExchangeSpringBootApplication.java:18) [classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
      at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
  Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'webroot' in string value "jdbc:hsqldb:file:${webroot}/WEB-INF/classes/DBStorage/testdb"
      at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:178) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:204) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:141) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:82) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:208) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
      ... 18 common frames omitted
  
  2016-07-11 21:49:18.691  INFO 540 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/charsets.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/deploy.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/sunpkcs11.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/ext/zipfs.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/javaws.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/jce.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/jfr.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/jfxswt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/jsse.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/management-agent.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/plugin.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/resources.jar, file:/C:/Program%20Files/Java/jdk1.8.0_65/jre/lib/rt.jar, file:/D:/Downloads/DVDExchangespringboot/target/classes/, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot-starter-security/1.3.6.RELEASE/spring-boot-starter-security-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.6.RELEASE/spring-boot-starter-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot/1.3.6.RELEASE/spring-boot-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.6.RELEASE/spring-boot-autoconfigure-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.6.RELEASE/spring-boot-starter-logging-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/C:/Users/Artyom/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/C:/Users/Artyom/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-aop/4.2.7.RELEASE/spring-aop-4.2.7.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.6.RELEASE/spring-boot-starter-web-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.6.RELEASE/spring-boot-starter-validation-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.36/tomcat-embed-el-8.0.36.jar, file:/C:/Users/Artyom/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/C:/Users/Artyom/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/boot/spring-boot-starter-jetty/1.3.6.RELEASE/spring-boot-starter-jetty-1.3.6.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-servlets/9.2.17.v20160517/jetty-servlets-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-continuation/9.2.17.v20160517/jetty-continuation-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-http/9.2.17.v20160517/jetty-http-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-util/9.2.17.v20160517/jetty-util-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-io/9.2.17.v20160517/jetty-io-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-webapp/9.2.17.v20160517/jetty-webapp-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-xml/9.2.17.v20160517/jetty-xml-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-servlet/9.2.17.v20160517/jetty-servlet-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-security/9.2.17.v20160517/jetty-security-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-server/9.2.17.v20160517/jetty-server-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.2.17.v20160517/websocket-server-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.2.17.v20160517/websocket-common-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.2.17.v20160517/websocket-api-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.2.17.v20160517/websocket-client-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.2.17.v20160517/websocket-servlet-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-server-impl/9.2.17.v20160517/javax-websocket-server-impl-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-annotations/9.2.17.v20160517/jetty-annotations-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-plus/9.2.17.v20160517/jetty-plus-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/jetty-jndi/9.2.17.v20160517/jetty-jndi-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar, file:/C:/Users/Artyom/.m2/repository/org/ow2/asm/asm/5.0.1/asm-5.0.1.jar, file:/C:/Users/Artyom/.m2/repository/org/ow2/asm/asm-commons/5.0.1/asm-commons-5.0.1.jar, file:/C:/Users/Artyom/.m2/repository/org/ow2/asm/asm-tree/5.0.1/asm-tree-5.0.1.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/websocket/javax-websocket-client-impl/9.2.17.v20160517/javax-websocket-client-impl-9.2.17.v20160517.jar, file:/C:/Users/Artyom/.m2/repository/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar, file:/C:/Users/Artyom/.m2/repository/org/hsqldb/hsqldb/2.3.3/hsqldb-2.3.3.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-core/4.2.5.RELEASE/spring-core-4.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-web/4.2.5.RELEASE/spring-web-4.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-beans/4.2.7.RELEASE/spring-beans-4.2.7.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-context/4.2.7.RELEASE/spring-context-4.2.7.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-webmvc/4.2.5.RELEASE/spring-webmvc-4.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-expression/4.2.7.RELEASE/spring-expression-4.2.7.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.3/jackson-core-2.6.3.jar, file:/C:/Users/Artyom/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.3/jackson-databind-2.6.3.jar, file:/C:/Users/Artyom/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.7/jackson-annotations-2.6.7.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-orm/4.2.5.RELEASE/spring-orm-4.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-jdbc/4.2.7.RELEASE/spring-jdbc-4.2.7.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-tx/4.2.7.RELEASE/spring-tx-4.2.7.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/spring-aspects/4.2.5.RELEASE/spring-aspects-4.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/security/spring-security-web/3.2.5.RELEASE/spring-security-web-3.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/security/spring-security-core/3.2.5.RELEASE/spring-security-core-3.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/security/spring-security-config/3.2.5.RELEASE/spring-security-config-3.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/security/spring-security-taglibs/3.2.5.RELEASE/spring-security-taglibs-3.2.5.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/org/springframework/security/spring-security-acl/4.0.4.RELEASE/spring-security-acl-4.0.4.RELEASE.jar, file:/C:/Users/Artyom/.m2/repository/jstl/jstl/1.2/jstl-1.2.jar, file:/C:/Users/Artyom/.m2/repository/org/hibernate/hibernate-core/5.1.0.Final/hibernate-core-5.1.0.Final.jar, file:/C:/Users/Artyom/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/C:/Users/Artyom/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/C:/Users/Artyom/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar, file:/C:/Users/Artyom/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/Artyom/.m2/repository/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar, file:/C:/Users/Artyom/.m2/repository/org/jboss/jandex/2.0.0.Final/jandex-2.0.0.Final.jar, file:/C:/Users/Artyom/.m2/repository/com/fasterxml/classmate/1.3.0/classmate-1.3.0.jar, file:/C:/Users/Artyom/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar, file:/C:/Users/Artyom/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar, file:/C:/Users/Artyom/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.1.Final/hibernate-commons-annotations-5.0.1.Final.jar, file:/C:/Users/Artyom/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar, file:/C:/Users/Artyom/.m2/repository/commons-pool/commons-pool/1.6/commons-pool-1.6.jar, file:/C:/Users/Artyom/.m2/repository/org/slf4j/slf4j-api/1.7.18/slf4j-api-1.7.18.jar, file:/C:/Users/Artyom/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.18/jcl-over-slf4j-1.7.18.jar, file:/C:/Users/Artyom/.m2/repository/ch/qos/logback/logback-classic/1.1.6/logback-classic-1.1.6.jar, file:/C:/Users/Artyom/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/C:/Users/Artyom/.m2/repository/org/mortbay/jasper/apache-jsp/8.0.27/apache-jsp-8.0.27.jar, file:/C:/Users/Artyom/.m2/repository/org/eclipse/jetty/toolchain/jetty-schemas/3.1.M0/jetty-schemas-3.1.M0.jar, file:/C:/Users/Artyom/.m2/repository/org/mortbay/jasper/apache-el/8.0.27/apache-el-8.0.27.jar, file:/C:/Program%20Files%20(x86)/JetBrains/IntelliJ%20IDEA%202016.1.1/lib/idea_rt.jar]
  
  Process finished with exit code 1
  </code></pre>
  
  <p>Help me please!</p>
  
  <p><strong>UPDATE 1 (11.07.2016)</strong></p>
  
  <p>My <strong>application.properties</strong> already contains the following:</p>
  
  <pre><code>server.contextPath=/DVDExchange
  webroot = ${webroot}
  </code></pre>
  
  <p>But it does not work. The same error occurs.</p>
  
  <p><strong>UPDATE 2 (11.07.2016)</strong></p>
  
  <p>These are my db connection configurations:</p>
  
  <p><strong>spring-database.xml</strong></p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/aop
      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt;
  
      &lt;!-- HSQLDB data source --&gt;
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="org.hsqldb.jdbcDriver" /&gt;
          &lt;property name="url" value="jdbc:hsqldb:file:${webroot}/classes/DBStorage/testdb" /&gt;
          &lt;property name="username" value="SA" /&gt;
          &lt;property name="password" value="" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Hibernate session factory --&gt;
      &lt;bean id="sessionFactory"
            class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="mappingResources"&gt;
              &lt;list&gt;
                  &lt;value&gt;User.hbm.xml&lt;/value&gt;
                  &lt;value&gt;Disk.hbm.xml&lt;/value&gt;
                  &lt;value&gt;Takenitem.hbm.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;
                      org.hibernate.dialect.MySQL5Dialect
                  &lt;/prop&gt;
                  &lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="userDAO" class="com.dvdexchange.dao.impl.UserDAOHibernateImpl"/&gt;
  
      &lt;bean id="myUserServiceImpl" class="com.dvdexchange.service.impl.UserServiceImpl"&gt;
          &lt;property name="userDAO" ref="userDAO" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- MUST have transaction manager, using aop and aspects  --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;tx:advice id="txAdvice" transaction-manager="transactionManager"&gt;
          &lt;tx:attributes&gt;
              &lt;tx:method name="get*" read-only="true" /&gt;
              &lt;tx:method name="find*" read-only="true" /&gt;
              &lt;tx:method name="*" /&gt;
          &lt;/tx:attributes&gt;
      &lt;/tx:advice&gt;
  
      &lt;aop:config&gt;
          &lt;aop:pointcut id="userServicePointCut"
                        expression="execution(* com.dvdexchange.service.*ServiceImpl.*(..))" /&gt;
          &lt;aop:advisor advice-ref="txAdvice" pointcut-ref="userServicePointCut" /&gt;
      &lt;/aop:config&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>hibernate.cfg.xml</strong></p>
  
  <pre><code>&lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;!-- Database connection settings --&gt;
          &lt;property name="connection.driver_class"&gt;org.hsqldb.jdbcDriver&lt;/property&gt;
          &lt;property name="connection.url"&gt;jdbc:hsqldb:file:${webroot}/classes/DBStorage/testdb&lt;/property&gt;
          &lt;property name="connection.username"&gt;SA&lt;/property&gt;
          &lt;property name="connection.password"&gt;&lt;/property&gt;
  
          &lt;!-- JDBC connection pool (use the built-in) --&gt;
          &lt;property name="connection.pool_size"&gt;5&lt;/property&gt;
  
          &lt;!-- SQL dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.HSQLDialect&lt;/property&gt;
  
          &lt;!-- Echo all executed SQL to stdout --&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;!-- Drop and re-create the database schema on startup
          &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;--&gt;
  
  
          &lt;!-- Mapping files --&gt;
          &lt;mapping resource="User.hbm.xml"/&gt;
          &lt;mapping resource="Disk.hbm.xml"/&gt;
          &lt;mapping resource="Takenitem.hbm.xml"/&gt;
  
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><strong>UPDATE 3 (12.07.2016)</strong></p>
  
  <p>After solving db storing problem I still can not make my web app work as needed. This is the error I get on start of my app:</p>
  
  <p><a href="https://i.stack.imgur.com/uF5bS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uF5bS.png" alt="error 404"></a></p>