title: Spring + Hibernate: LocalSessionFactoryBean - NoSuchMethodError: org.hibernate.cfg.annotations.reflection.XMLContext
body: <p>I am trying integrate <code>Hibernate 4.0.0.FINAL</code> with <code>Spring 3.1.0.RELEASE</code>
  using <code>@Configuration</code>.</p>
  <p>Afterwards, this problem occurs:</p>
  <pre><code>BeanCreationException: Error creating bean with name 'alertsSessionFactoryBean'
  NoSuchMethodError: org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/lang/Boolean;
  </code></pre>
  <p>This is my <code>PersistenceHibernateConfig</code> file</p>
  <pre><code>@Configuration
  @EnableTransactionManagement
  public class PersistenceHibernateConfig {
  
      @Value(&quot;${jdbc.driverClassName}&quot;)
      private String driverClassName;
  
      @Value(&quot;${jdbc.url}&quot;)
      private String url;
  
      @Value(&quot;${hibernate.dialect}&quot;)
      String hibernateDialect;
  
      @Value(&quot;${hibernate.show_sql}&quot;)
      boolean hibernateShowSql;
  
      @Value(&quot;${hibernate.hbm2ddl.auto}&quot;)
      String hibernateHbm2ddlAuto;
  
      @Bean
      public LocalSessionFactoryBean alertsSessionFactoryBean() {
          final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
          sessionFactory.setDataSource(this.restDataSource());
          sessionFactory.setPackagesToScan(new String[]{&quot;com.cloudlb&quot;});
          sessionFactory.setHibernateProperties(this.hibernateProperties());
      
          return sessionFactory;
      }
  
      @Bean
      public DataSource restDataSource() {
          final DriverManagerDataSource dataSource = new DriverManagerDataSource();
          dataSource.setDriverClassName(this.driverClassName);
          dataSource.setUrl(this.url);
          dataSource.setUsername(&quot;test&quot;);
          dataSource.setPassword(&quot;1234&quot;);
  
          return dataSource;
      }
  
      @Bean
      public HibernateTransactionManager transactionManager() {
          final HibernateTransactionManager txManager = new HibernateTransactionManager();
          txManager.setSessionFactory(this.alertsSessionFactoryBean().getObject());
  
          return txManager;
      }
  
      @Bean
      public PersistenceExceptionTranslationPostProcessor exceptionTranslationPostProcessor() {
          return new PersistenceExceptionTranslationPostProcessor();
      }
  
      @Bean
      public PersistenceExceptionTranslator exceptionTranslator() {
          return new HibernateExceptionTranslator();
      }
  
      final Properties hibernateProperties() {
          return new Properties() {
              {
                  this.put(&quot;persistence.dialect&quot;, PersistenceHibernateConfig.this.hibernateDialect);
                  this.put(&quot;hibernate.hbm2ddl.auto&quot;, PersistenceHibernateConfig.this.hibernateHbm2ddlAuto);
                  this.put(&quot;hibernate.show_sql&quot;, PersistenceHibernateConfig.this.hibernateShowSql);
              }
          };
      }
  }
  </code></pre>
  <p>I think it could be a problem with LocalSessionFactoryBean but I can't understand what is wrong. I may be missing something.</p>
  <p>I found out that it is because of missing hibernate-annotation.jar if it is 3.x
  Don't know why in 4.0 the annotation: org.hibernate.cfg.annotations.reflection.XMLContext is in hibernate-core jar file and it still error.</p>