title: SPRING-DATA-JPA Simple Auditing Not Working
body: <p>I am trying to make use of the auditing provided by spring data jpa.Below is my webappconfig</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @EnableTransactionManagement
  @ComponentScan("com.astrika.kernel")
  @PropertySource("classpath:application.properties")
  @EnableJpaRepositories(basePackages="com.astrika.kernel.repository")
  @EnableJpaAuditing
  
  public class WebAppConfig {
  
  private static final String PROPERTY_NAME_DATABASE_DRIVER = "db.driver";
  private static final String PROPERTY_NAME_DATABASE_PASSWORD = "db.password";
  private static final String PROPERTY_NAME_DATABASE_URL = "db.url";
  private static final String PROPERTY_NAME_DATABASE_USERNAME = "db.username";
  
  
  private static final String PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN = "entitymanager.packages.to.scan";
  
  private static final String PROPERTY_NAME_HIBERNATE_POST_INSERT = "hibernate.ejb.event.post-insert";
  private static final String PROPERTY_NAME_HIBERNATE_POST_UPDATE = "hibernate.ejb.event.post-update";
  private static final String PROPERTY_NAME_HIBERNATE_POST_DELETE = "hibernate.ejb.event.post-delete";
  private static final String PROPERTY_NAME_HIBERNATE_PRE_COLLC_UPDATE = "hibernate.ejb.event.pre-collection-update";
  private static final String PROPERTY_NAME_HIBERNATE_PRE_COLLC_REMOVE = "hibernate.ejb.event.pre-collection-remove";
  private static final String PROPERTY_NAME_HIBERNATE_PRE_COLLC_RECREATE = "hibernate.ejb.event.post-collection-recreate";
  
  @Resource
  private Environment env;
  
  @Bean
  public DataSource dataSource() {
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
  
      dataSource.setDriverClassName(env.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
      dataSource.setUrl(env.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
      dataSource.setUsername(env.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
      dataSource.setPassword(env.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));
  
      return dataSource;
  }
  
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
      LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
      entityManagerFactoryBean.setDataSource(dataSource());
      entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
      entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
      entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter());
      entityManagerFactoryBean.setMappingResources("WEB-INF/classes/orm.xml");
       //     entityManagerFactoryBean.setJpaProperties(hibProperties());
  
      return entityManagerFactoryBean;
  }
  
  //  private Properties hibProperties() {
  //      Properties properties = new Properties();
  //      properties.put(PROPERTY_NAME_HIBERNATE_POST_INSERT, 
  
  // env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_POST_INSERT));
  //      properties.put(PROPERTY_NAME_HIBERNATE_POST_UPDATE, 
  
  // env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_POST_UPDATE));
  //      properties.put(PROPERTY_NAME_HIBERNATE_POST_DELETE, 
  
  // env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_POST_DELETE));
  //      properties.put(PROPERTY_NAME_HIBERNATE_PRE_COLLC_UPDATE,    
  
  // env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_PRE_COLLC_UPDATE));
  //      properties.put(PROPERTY_NAME_HIBERNATE_PRE_COLLC_REMOVE,    
  
  // env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_PRE_COLLC_REMOVE));
  //      properties.put(PROPERTY_NAME_HIBERNATE_PRE_COLLC_RECREATE,  
  
  // env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_PRE_COLLC_RECREATE));
  //      return properties;
  //  }
   @Bean
      public JpaVendorAdapter jpaVendorAdapter() {
          HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new  
  
  HibernateJpaVendorAdapter();
  
          hibernateJpaVendorAdapter.setShowSql(false);
          hibernateJpaVendorAdapter.setGenerateDdl(true);
          hibernateJpaVendorAdapter.setDatabase(Database.MYSQL);
          return hibernateJpaVendorAdapter;
      }
  
  @Bean
  public JpaTransactionManager transactionManager() {
      JpaTransactionManager transactionManager = new JpaTransactionManager();
      transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
      return transactionManager;
  }
  
  @Bean
  public UrlBasedViewResolver setupViewResolver() {
      UrlBasedViewResolver resolver = new UrlBasedViewResolver();
      resolver.setPrefix("/pages/");
      resolver.setSuffix(".jsp");
      resolver.setViewClass(JstlView.class);
      return resolver;
  }
  
  @Bean
  public ResourceBundleMessageSource messageSource() {
      ResourceBundleMessageSource source = new ResourceBundleMessageSource();
      source.setBasename(env.getRequiredProperty("message.source.basename"));
      source.setUseCodeAsDefaultMessage(true);
      return source;
  }
  </code></pre>
  
  <p>and my orm.xml looks like this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd" 
      version="2.0"&gt;
  
  &lt;persistence-unit-metadata&gt;
      &lt;persistence-unit-defaults&gt;
          &lt;entity-listeners&gt;
              &lt;entity-listener class="org.springframework.data.jpa.domain.support.AuditingEntityListener" /&gt;
          &lt;/entity-listeners&gt;
      &lt;/persistence-unit-defaults&gt;
  &lt;/persistence-unit-metadata&gt;
  </code></pre>
  
  <p></p>
  
  <p>When ever i run my application in my tomcat server i get the error</p>
  
  <pre><code>INFO: HHH000360: Unable to resolve mapping file [WEB-INF/classes/orm.xml]
  </code></pre>
  
  <p>And the audit fields like createdOn,lastModifiedOn never gets a value.They always null.
  Please help as why i get the above tomcat error? and is it responsible for null values on audit fields? and am i missing any more configuration?</p>
  
  <p>I forgot to mention i am using annotation based auditing i.e. @CreatedOn and 
  @LastModifiedOn</p>