1 Reply Latest reply on Jun 27, 2005 10:36 AM by svewap

    errors with alter-table <- true in jbosscmp-jdbc.xml Duplica

      Hi

      If i set my alter-table to be true in jbosscmp-jdbc.xml i receive exceptions while performing a deploy: (it looks like its trying to add my pk column twice once in the create and another time in the alter table) i'm using jboss-4.0.2

      jbosscmp-jdbc.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <jbosscmp-jdbc>
      
       <defaults>
       <datasource>java:/MASDS</datasource>
       <datasource-mapping>mySQL</datasource-mapping>
       <create-table>true</create-table>
       <alter-table>true</alter-table>
       <remove-table>false</remove-table>
       <fk-constraint>true</fk-constraint>
       <relation-mapping-style>foreign-key</relation-mapping-style>
       <post-table-create>
       <sql-statement>
       ALTER TABLE %%t TYPE=INNODB default charset=UTF8;
       </sql-statement>
       </post-table-create>
       </defaults>
       <enterprise-beans>
       <entity>
       <ejb-name>Sequence</ejb-name>
       <!-- enable row locking via SELECT ... FOR UPDATE -->
       <row-locking>true</row-locking>
       </entity>
      
       </enterprise-beans>
      
      </jbosscmp-jdbc>
      


      While performing a deploy to my ear i receive these errors:



      .
      .
      .

      7:58,407 ERROR [MASUserEntity] Could not alter table MASUserEntity: null, messa
      ge from server: "Duplicate column name 'uid'"
      jboss.j2ee:jndiName=domain/PABContactEntityHome,service=EJB
      EntityContainer 11:1
      7:58,407 ERROR [EntityContainer] Starting failed jboss.j2ee:jndiName=domain/PABC
      ontactEntityHome,service=EJB
      org.jboss.deployment.DeploymentException: Error while alter table MASUserEntity
      ALTER TABLE MASUserEntity ADD uid INTEGER NOT NULL; - nested throwable: (java.sq
      l.SQLException: null, message from server: "Duplicate column name 'uid'")
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.alterTable(JDBCStartC
      ommand.java:466)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.execute(JDBCStartComm
      and.java:125)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDB
      CStoreManager.java:484)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
      r.java:381)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManag
      er.java:157)
      at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:340)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:272)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:222)
      at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:897)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:418)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy251.start(Unknown Source)
      at org.jboss.ejb.EjbModule.startService(EjbModule.java:395)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:272)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:222)
      at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:897)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:418)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy22.start(Unknown Source)
      at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:605)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:956)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
      at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
      or.java:121)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
      BeanOperationInterceptor.java:127)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy8.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
      tScanner.java:325)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:501)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:204)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      loop(AbstractDeploymentScanner.java:215)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      run(AbstractDeploymentScanner.java:194)
      Caused by: java.sql.SQLException: null, message from server: "Duplicate column
      name 'uid'"
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1905)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)
      at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1164)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2087)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2037)
      at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1252)
      at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1198)
      at org.jboss.resource.adapter.jdbc.WrappedStatement.executeUpdate(Wrappe
      dStatement.java:229)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.alterTable(JDBCStartC
      ommand.java:453)
      ... 75 more
      11:17:58,625 WARN [ServiceController] Problem starting service jboss.j2ee:jndi
      Name=domain/PABContactEntityHome,service=EJB
      org.jboss.deployment.DeploymentException: Error while alter table MASUserEntity
      ALTER TABLE MASUserEntity ADD uid INTEGER NOT NULL; - nested throwable: (java.sq
      l.SQLException: null, message from server: "Duplicate column name 'uid'")
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.alterTable(JDBCStartC
      ommand.java:466)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.execute(JDBCStartComm
      and.java:125)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDB
      CStoreManager.java:484)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
      r.java:381)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManag
      er.java:157)
      at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:340)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:272)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:222)
      at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:897)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:418)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy251.start(Unknown Source)
      at org.jboss.ejb.EjbModule.startService(EjbModule.java:395)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:272)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:222)
      at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:897)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:418)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy22.start(Unknown Source)
      at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:605)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:956)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
      at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
      or.java:121)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
      BeanOperationInterceptor.java:127)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy8.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
      tScanner.java:325)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:501)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:204)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      loop(AbstractDeploymentScanner.java:215)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      run(AbstractDeploymentScanner.java:194)
      Caused by: java.sql.SQLException: null, message from server: "Duplicate column
      name 'uid'"
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1905)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)
      at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1164)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2087)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:2037)
      at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1252)
      at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1198)
      at org.jboss.resource.adapter.jdbc.WrappedStatement.executeUpdate(Wrappe
      dStatement.java:229)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.alterTable(JDBCStartC
      ommand.java:453)
      ... 75 more
      11:17:59,563 INFO [EJBDeployer] Deployed: file:/C:/projects/mas/MASCore/common
      /tools/jboss-4.0.2/server/default/tmp/deploy/tmp30823mas.ear-contents/mas.jar
      11:17:59,578 DEBUG [WSDLReaderImpl] Retrieving document at 'jar:file:/C:/projec
      ts/mas/MASCore/common/tools/jboss-4.0.2/server/default/tmp/deploy/tmp30823mas.ea


      Why is that error occuring?

        • 1. Re: errors with alter-table <- true in jbosscmp-jdbc.xml Dup
          svewap

          hi!
          You are not alone. I tried today to create my MySQL-tables by my ejbs. if they already exist and the alter-table - value is true, jbossas wants to duplicate the primary-column in my table. i can understand my mysql-db, why it says: "Stupid boy! Why do you want to duplicate a column?". Sounds like a bug in jboss, or?
          Perhaps jboss wants to test the table. First it inserts some datas, then it deletes them again and then it wants to test the table-structure:

          2005-06-27 15:38:14,453 DEBUG
           [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.Infolabel]
           Insert Entity SQL: INSERT INTO infolabel (idinfolabel, filanguage, fiinfo,
           value) VALUES (?, ?, ?, ?)
          2005-06-27 15:38:14,453 DEBUG
           [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.Infolabel]
           Entity Exists SQL: SELECT COUNT(*) FROM infolabel WHERE idinfolabel=?
          2005-06-27 15:38:14,453 DEBUG
           [org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.Infolabel]
           entity-command: [commandName=default,commandClass=class
           org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand,attributes={}]
          2005-06-27 15:38:14,453 DEBUG
           [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.Infolabel]
           Remove SQL: DELETE FROM infolabel WHERE idinfolabel=?
          2005-06-27 15:38:14,468 WARN
           [org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.Infolabel] ALTER
           TABLE infolabel ADD idinfolabel INTEGER NOT NULL
          2005-06-27 15:38:14,484 ERROR
           [org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.Infolabel] Could not
           alter table infolabel: Duplicate column name 'idinfolabel'


          Can i tell jbossas, that it should skip this step?

          Grüße aus Deutschland,
          Sven