title: Caused by: java.util.NoSuchElementException: null
body: <p>I have an exam about Java Web Programming. I am using Spring MVC and Hibernate to create a E-commerce Web Application. Unfortunately i am getting same error for two days. I can say i have read all articles about this error but still my project is not working. I am trying to build a project that company admins can do basic CRUD transactions and also i have a page that shows products to customers. While running project at first time on server i am getting this error. I am sorry for the long writing. I wanted everything to be clear.</p>
  
  <p>My controller class</p>
  
  <pre><code>package com.bilgeadam.webexam.controller;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  import com.bilgeadam.webexam.model.DatabaseService;
  import com.bilgeadam.webexam.model.entity.impl.Address;
  import com.bilgeadam.webexam.model.entity.impl.Customer;
  import com.bilgeadam.webexam.model.entity.impl.Product;
  import com.bilgeadam.webexam.model.entity.impl.ShoppingCart;
  
  /**
   * @author Fatih Taşdemir Oct 30, 2017
   */
  
  @Controller
  @RequestMapping({ "/", "home" })
  public class CustomerPanelController {
  
      @Autowired
      DatabaseService databaseService;
  
      @GetMapping
      public String home(Model model) {
          model.addAttribute("products", databaseService.getProductService().findAll());
          return "products";
      }
  
  
  }
  </code></pre>
  
  <p>Database service class</p>
  
  <pre><code>package com.bilgeadam.webexam.model;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import com.bilgeadam.webexam.model.service.AddressService;
  import com.bilgeadam.webexam.model.service.CustomerService;
  import com.bilgeadam.webexam.model.service.OrderService;
  import com.bilgeadam.webexam.model.service.ProductDetailService;
  import com.bilgeadam.webexam.model.service.ProductService;
  import com.bilgeadam.webexam.model.service.ShoppingCartService;
  import com.bilgeadam.webexam.model.service.UserService;
  
  @Component
  public class DatabaseService {
  
      @Autowired
      private AddressService addressService;
      @Autowired
      private CustomerService customerService;
      @Autowired
      private OrderService orderService;
      @Autowired
      private ProductDetailService productDetailService;
      @Autowired
      private ProductService productService;
      @Autowired
      private ShoppingCartService shoppingCartService;
      @Autowired
      private UserService userService;
  
      public AddressService getAddressService() {
          return addressService;
      }
  
      public CustomerService getCustomerService() {
          return customerService;
      }
  
      public OrderService getOrderService() {
          return orderService;
      }
  
      public ProductDetailService getProductDetailService() {
          return productDetailService;
      }
  
      public ProductService getProductService() {
          return productService;
      }
  
      public ShoppingCartService getShoppingCartService() {
          return shoppingCartService;
      }
  
      public UserService getUserService() {
          return userService;
      }
  
  }
  </code></pre>
  
  <p>HibernateDAO class</p>
  
  <pre><code>package com.bilgeadam.webexam.model.dao;
  
  import java.lang.reflect.ParameterizedType;
  
  import java.util.Date;
  import java.util.List;
  
  import org.hibernate.Criteria;
  import org.hibernate.SessionFactory;
  import org.hibernate.criterion.Restrictions;
  import org.springframework.beans.factory.annotation.Autowired;
  
  import com.bilgeadam.webexam.model.entity.GenericEntity;
  
  /**
   * @author Fatih Taşdemir Oct 29, 2017
   */
  
  public abstract class HibernateDAO&lt;E extends GenericEntity&gt; implements GenericDAO&lt;E&gt; {
  
      @Autowired
      private SessionFactory sessionFactory;
  
      private Class&lt;E&gt; entityClass;
  
      @SuppressWarnings("unchecked")
      public HibernateDAO() {
          this.entityClass = (Class&lt;E&gt;) ((ParameterizedType) getClass().getGenericSuperclass())
                  .getActualTypeArguments()[0];
      }
  
      @Override
      public void save(E entity) {
          entity.setDeleted(false);
          entity.setCreatedDate(new Date());
          entity.setUpdatedDate(new Date());
          sessionFactory.getCurrentSession().save(entity);
      }
  
      @Override
      public void update(E entity) {
          entity.setUpdatedDate(new Date());
          sessionFactory.getCurrentSession().update(entity);
      }
  
      @Override
      public void delete(E entity) {
          E e = findById(entity.getId());
          e.setDeleted(true);
          update(e);
      }
  
      @SuppressWarnings("unchecked")
      @Override
      public E findById(Integer id) {
          Criteria criteria = sessionFactory.getCurrentSession().createCriteria(entityClass);
          criteria.add(Restrictions.eq("id", id));
          criteria.add(Restrictions.eq("deleted", false));
          return (E) criteria.uniqueResult();
      }
  
      @SuppressWarnings("unchecked")
      @Override
      public List&lt;E&gt; findAll() {
          Criteria criteria = sessionFactory.getCurrentSession().createCriteria(entityClass);
          criteria.add(Restrictions.eq("deleted", false));
          return criteria.list();
      }
  
  }
  </code></pre>
  
  <p>GenericDAO class </p>
  
  <pre><code>package com.bilgeadam.webexam.model.dao;
  
  import java.util.List;
  
  import com.bilgeadam.webexam.model.entity.GenericEntity;
  
  /**
   * @author Fatih Taşdemir Oct 29, 2017
   */
  
  public interface GenericDAO&lt;E extends GenericEntity&gt; {
  
      public abstract void save(E entity);
  
      public abstract void update(E entity);
  
      public abstract void delete(E entity);
  
      public abstract E findById(Integer id);
  
      public abstract List&lt;E&gt; findAll();
  
  }
  </code></pre>
  
  <p>AbstractService class</p>
  
  <pre><code>package com.bilgeadam.webexam.model.service;
  
  import java.util.List;
  
  import org.springframework.transaction.annotation.Transactional;
  
  import com.bilgeadam.webexam.model.entity.GenericEntity;
  import com.bilgeadam.webexam.model.dao.GenericDAO;
  
  /**
   * @author Fatih Taşdemir Oct 29, 2017
   */
  
  @Transactional
  public class AbstractService&lt;E extends GenericEntity&gt; implements GenericService&lt;E&gt; {
  
      protected final GenericDAO&lt;E&gt; genericDAO;
  
      public AbstractService(GenericDAO&lt;E&gt; genericDAO) {
          this.genericDAO = genericDAO;
      }
  
      @Override
      public void save(E entity) {
          genericDAO.save(entity);
      }
  
      @Override
      public void update(E entity) {
          genericDAO.update(entity);
      }
  
      @Override
      public void delete(E entity) {
          genericDAO.delete(entity);
      }
  
      @Override
      public E findById(Integer id) {
          return genericDAO.findById(id);
      }
  
      @Override
      public List&lt;E&gt; findAll() {
          return genericDAO.findAll();
      }
  }
  </code></pre>
  
  <p>ProductDAOImpl class</p>
  
  <pre><code>package com.bilgeadam.webexam.model.dao.impl;
  
  import org.springframework.stereotype.Repository;
  
  import com.bilgeadam.webexam.model.dao.HibernateDAO;
  import com.bilgeadam.webexam.model.dao.ProductDAO;
  import com.bilgeadam.webexam.model.entity.impl.Product;
  
  /**
   * @author Fatih Taşdemir Oct 29, 2017
   */
  
  @Repository
  public class ProductDAOImpl extends HibernateDAO&lt;Product&gt; implements ProductDAO {
  
  }
  </code></pre>
  
  <p>ProductServiceImpl class</p>
  
  <pre><code>package com.bilgeadam.webexam.model.service.impl;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import com.bilgeadam.webexam.model.dao.ProductDAO;
  import com.bilgeadam.webexam.model.entity.impl.Product;
  import com.bilgeadam.webexam.model.service.AbstractService;
  import com.bilgeadam.webexam.model.service.ProductService;
  
  /**
   * @author Fatih Taşdemir Oct 29, 2017
   */
  
  @Service
  public class ProductServiceImpl extends AbstractService&lt;Product&gt; implements ProductService {
  
      @Autowired
      public ProductServiceImpl(ProductDAO productDAO) {
          super(productDAO);
      }
  
  }
  </code></pre>
  
  <p>Product class</p>
  
  <pre><code>package com.bilgeadam.webexam.model.entity.impl;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.MapsId;
  import javax.persistence.OneToOne;
  import javax.persistence.Table;
  import javax.validation.constraints.Min;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Past;
  import javax.validation.constraints.Size;
  
  import org.springframework.web.multipart.MultipartFile;
  
  import com.bilgeadam.webexam.model.entity.AbstractEntity;
  
  /**
   * @author Fatih Taşdemir Oct 28, 2017
   */
  
  @Entity
  @Table(name = "PRODUCT")
  public class Product extends AbstractEntity {
  
      private static final long serialVersionUID = 1L;
      private String name;
      private String brand;
      private String model;
      private String barcode;
      private double price;
      private String productCategory;
      private Integer producedYear;
      private Integer availableStock;
      private ProductDetail productDetail;
      private MultipartFile productImage;
      private String productImageUrl;
      private Integer unitsInOrder;
  
      getter and setters
  </code></pre>
  
  <p>Spring bean configuration file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:security="http://www.springframework.org/schema/security"
      xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd"&gt;
  
      &lt;!-- MVC configurations --&gt;
      &lt;mvc:annotation-driven enable-matrix-variables="true"
          validator="validator" /&gt;
      &lt;context:component-scan base-package="com.bilgeadam.webexam" /&gt;
      &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
      &lt;!-- Properties files --&gt;
      &lt;context:property-placeholder location="classpath:application.properties"
          ignore-unresolvable="true" /&gt;
  
      &lt;!-- Spring MVC Interceptor Beans --&gt;
      &lt;mvc:interceptors&gt;
          &lt;bean
              class="com.bilgeadam.webexam.interceptor.PerformanceMonitorInterceptor" /&gt;
          &lt;bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
              &lt;property name="paramName" value="language" /&gt;
          &lt;/bean&gt;
          &lt;bean class="com.bilgeadam.webexam.interceptor.AuditingInterceptor" /&gt;
      &lt;/mvc:interceptors&gt;
  
      &lt;!-- Spring MVC Internationalization --&gt;
      &lt;bean id="localeResolver"
          class="org.springframework.web.servlet.i18n.SessionLocaleResolver"&gt;
          &lt;property name="defaultLocale" value="en" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Tiles configurations --&gt;
      &lt;bean
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/views/pages/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Spring MVC LocalValidatorFactoryBean --&gt;
      &lt;bean id="validator"
          class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"&gt;
          &lt;property name="validationMessageSource" ref="messageSource" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Transaction definition --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager"
          proxy-target-class="true" /&gt;
  
      &lt;!-- Spring MVC CommonMultiPartResolver --&gt;
      &lt;bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
          &lt;property name="maxUploadSize" value="10240000" /&gt;
      &lt;/bean&gt;
  
  
  
      &lt;!-- Datasource Bean definition --&gt;
      &lt;jee:jndi-lookup id="dataSource" jndi-name="${jndi.datasource}"
          expected-type="javax.sql.DataSource" /&gt;
  
      &lt;!-- Hibernate 5 SessionFactory Bean definition --&gt;
      &lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="packagesToScan"&gt;
              &lt;array&gt;
                  &lt;value&gt;com.bilgeadam.webexam.model.entity.impl&lt;/value&gt;
              &lt;/array&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
                  &lt;prop key="hibernate.default_schema"&gt;${hibernate.default_schema}&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;${hibernate.hbm2ddl.auto}&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;
                  &lt;prop key="hibernate.format_sql"&gt;${hibernate.format_sql}&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.CharSet"&gt;${hibernate.connection.CharSet}&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.characterEncoding"&gt;${hibernate.connection.characterEncoding}&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.useUnicode"&gt;${hibernate.connection.useUnicode}&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.import_files_sql_extractor"&gt;${hibernate.multiline.sql}&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"
          class="org.springframework.orm.hibernate5.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="persistenceExceptionTranslationPostProcessor"
          class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt;
  
      &lt;!-- Spring MessageSource --&gt;
      &lt;bean id="messageSource"
          class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
          &lt;property name="basename" value="messages" /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.webexam&lt;/groupId&gt;
      &lt;artifactId&gt;WebExam&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;properties&gt;
          &lt;!-- JRE version --&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
          &lt;!-- JDK version --&gt;
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
          &lt;!-- Spring framework version --&gt;
          &lt;spring-framework.version&gt;4.3.7.RELEASE&lt;/spring-framework.version&gt;
          &lt;!-- Spring security version --&gt;
          &lt;spring-security.version&gt;4.2.3.RELEASE&lt;/spring-security.version&gt;
          &lt;!-- Servlet version --&gt;
          &lt;servlet.version&gt;3.1.0&lt;/servlet.version&gt;
          &lt;!-- JSP version --&gt;
          &lt;jsp.version&gt;2.3.1&lt;/jsp.version&gt;
          &lt;!-- JSTL version --&gt;
          &lt;jstl.version&gt;1.2&lt;/jstl.version&gt;
          &lt;!-- MySQL version --&gt;
          &lt;mysql.version&gt;5.1.39&lt;/mysql.version&gt;
          &lt;!-- Hibernate version --&gt;
          &lt;hibernate.version&gt;5.1.3.Final&lt;/hibernate.version&gt;
          &lt;!-- DBCP version --&gt;
          &lt;dbcp.version&gt;1.4&lt;/dbcp.version&gt;
          &lt;!-- SLF4J version --&gt;
          &lt;slf4j.version&gt;1.7.5&lt;/slf4j.version&gt;
          &lt;!-- LogBack version --&gt;
          &lt;logback.version&gt;1.0.13&lt;/logback.version&gt;
          &lt;!-- Apache Tiles version --&gt;
          &lt;apache.tiles.version&gt;3.0.7&lt;/apache.tiles.version&gt;
          &lt;!-- Jackson version --&gt;
          &lt;jackson.version&gt;2.8.8&lt;/jackson.version&gt;
          &lt;!-- Apache Commons FileUpload --&gt;
          &lt;file.upload.version&gt;1.3.1&lt;/file.upload.version&gt;
          &lt;!-- Apache Commons IO --&gt;
          &lt;common.io.version&gt;2.4&lt;/common.io.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;!-- Spring Framework API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${spring-framework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;${spring-framework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;${spring-framework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
              &lt;version&gt;${spring-framework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
              &lt;version&gt;${spring-security.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
              &lt;version&gt;${spring-security.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-taglibs&lt;/artifactId&gt;
              &lt;version&gt;${spring-security.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Servlet + JSP + JSTL API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;version&gt;${servlet.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet.jsp-api&lt;/artifactId&gt;
              &lt;version&gt;${jsp.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;${jstl.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- MySQL JDBC API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;${mysql.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Hibernate Core API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
              &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- DBCP API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
              &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
              &lt;version&gt;${dbcp.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- SLF4J API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;${slf4j.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;${slf4j.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Logback API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
              &lt;version&gt;${logback.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Apache Tiles API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
              &lt;artifactId&gt;tiles-extras&lt;/artifactId&gt;
              &lt;version&gt;${apache.tiles.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Jackson API --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
              &lt;version&gt;${jackson.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;${jackson.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
              &lt;version&gt;${jackson.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Apache Commons FileUpload --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
              &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
              &lt;version&gt;${file.upload.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Apache Commons IO --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-io&lt;/groupId&gt;
              &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
              &lt;version&gt;${common.io.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      version="2.5"&gt;
      &lt;display-name&gt;WebExam&lt;/display-name&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/security-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/config.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;DispatcherServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring/config.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;DispatcherServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;!-- Filter Declerations --&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;encoding-filter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;encoding&lt;/param-name&gt;
              &lt;param-value&gt;UTF-8&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/filter&gt;
  
      &lt;!-- Filter Mappings --&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;encoding-filter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>and stack trace:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/config.xml]: Invocation of init method failed; nested exception is java.util.NoSuchElementException
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      ... 85 common frames omitted
  Caused by: java.util.NoSuchElementException: null
      at java.util.ArrayList$Itr.next(ArrayList.java:860) ~[na:1.8.0_151]
      at org.hibernate.cfg.annotations.TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit(TableBinder.java:724) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass.doSecondPass(PkDrivenByDefaultMapsIdSecondPass.java:37) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1621) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1578) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:727) ~[hibernate-core-5.1.3.Final.jar:5.1.3.Final]
      at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:511) ~[spring-orm-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:495) ~[spring-orm-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
      ... 95 common frames omitted
  </code></pre>