BatchUpdateException: Duplicate entry '' for

Help
2007-01-02
2013-04-09
  • Leos Literak
    Leos Literak
    2007-01-02

    I try to run tudu-2.0-beta-1 on jetty 6 and mysql. I created the scheme and initialized it. When I run jetty, todo war initialization failes:

    2007-01-02 15:40:54.536:/tudu:INFO:  Loading Spring root WebApplicationContext
    0    [main] WARN  tudu.domain.configuration.DataSourceFactory  - Initializing database connection pool.
    99   [main] WARN  tudu.domain.configuration.DataSourceFactory  - No database configured in JNDI at "java:/comp/envjdbc/tudu"
    498  [main] WARN  tudu.domain.configuration.DataSourceFactory  - MySQL database found.
    4788 [main] WARN  tudu.service.impl.ConfigurationManagerImpl  - Spring context is started : org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext: display name [Root WebApplicationContext]; startup date [Tue Jan 02 15:40:54 CET 2007]; root of context hierarchy; config locations [classpath:/tudu/domain/applicationContext-jpa.xml,classpath:/tudu/service/applicationContext.xml,classpath:/tudu/security/applicationContext-security.xml,/WEB-INF/spring/applicationContext-*]]
    4788 [main] WARN  tudu.service.impl.ConfigurationManagerImpl  - Testing Database.
    4946 [main] WARN  tudu.service.impl.ConfigurationManagerImpl  - Database is empty : populating with default values.
    4947 [main] WARN  tudu.service.impl.ConfigurationManagerImpl  - Populating HSQLDB database.
    5109 [main] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 1062, SQLState: 23000
    5109 [main] ERROR org.hibernate.util.JDBCExceptionReporter  - Duplicate entry '' for key 1
    5115 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener  - Could not synchronize database state with session
    org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
            at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
            at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
            at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
            at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
            at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
            at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:218)
            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2159)
            at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2595)
            at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
            at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
            at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
            at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
            at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
            at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:296)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:176)
            at $Proxy22.flush(Unknown Source)
            at tudu.domain.dao.jpa.RoleDAOJpa.saveRole(RoleDAOJpa.java:40)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:280)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:78)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
            at $Proxy24.saveRole(Unknown Source)
            at tudu.service.impl.ConfigurationManagerImpl.initDatabase(ConfigurationManagerImpl.java:96)
            at tudu.service.impl.ConfigurationManagerImpl.onApplicationEvent(ConfigurationManagerImpl.java:58)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:280)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
            at $Proxy29.onApplicationEvent(Unknown Source)
            at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
            at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
            at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
            at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:241)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
            at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)

    Is this a bug or my fault?

    Thanks

    Leos

     
    • Julien Dubois
      Julien Dubois
      2007-01-09

      The problem is that Tudu Lists thinks the database is empty, and hence tries to populate it with default values.

      The check is done in the "Role" table, as the information contained in this table should not be altered. Here's the code if you are interested :
      http://tudu.svn.sourceforge.net/viewvc/tudu/trunk/tudu2/tudu-core/src/main/java/tudu/service/impl/ConfigurationManagerImpl.java?revision=400&view=markup
      (see line 68)

      Is this table empty in your system?

      Otherwise can you drop your database schema and recreate it with the one from your distribution?

       
    • Mario
      Mario
      2007-06-25

      I had same problem and I resolved it upgrading mysql server (from 4.X) to 5.0