3 Replies Latest reply on Nov 19, 2002 2:41 AM by Jeremy Boynes

    bad error message and table create order?

    Samuel Montgomery-Blinn Newbie

      Is there a way to specify table create order, or more specifically which bean should load first?

      I have a bean, "AuthGroupMembership" which uses foreign-key mapping to two other beans, "AuthUser" and "AuthGroup". When JBoss attempts to deploy the beans, it fails on "AuthGroupMembership" with an incorrect error.

      ---
      16:28:44,702 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss
      /3.0.4/server/default/deploy/openearth.jar
      16:28:44,902 INFO [EjbModule] Creating
      16:28:44,922 INFO [EjbModule] Deploying AuthUserMembership
      16:28:45,052 INFO [EjbModule] Deploying AuthDomain
      16:28:45,062 INFO [EjbModule] Deploying AuthRole
      16:28:45,082 INFO [EjbModule] Deploying AuthRealm
      16:28:45,102 INFO [EjbModule] Deploying AuthUser
      16:28:45,112 INFO [EjbModule] Deploying AuthGroupMapping
      16:28:45,143 INFO [EjbModule] Deploying AuthGroup
      16:28:45,153 INFO [EjbModule] Deploying AuthUserMapping
      16:28:45,243 INFO [EjbModule] Created
      16:28:45,243 INFO [EjbModule] Starting
      16:28:46,504 INFO [AuthDomain] Created table 'AUTH_DOMAIN' successfully.
      16:28:46,665 INFO [AuthRealm] Created table 'AUTH_REALM' successfully.
      16:28:46,675 INFO [AuthUserMapping] Created table 'AUTH_USER_MAPPING' successfu
      lly.
      16:28:46,695 INFO [AuthUserMembership] Created table 'AUTH_USER_MEMBERSHIP' suc
      cessfully.
      16:28:46,725 INFO [AuthRole] Created table 'AUTH_ROLE' successfully.
      16:28:46,725 WARN [ServiceController] Problem starting service jboss.j2ee:jndiN
      ame=openauth.entity.AuthGroupMapping,service=EJB
      java.lang.IllegalStateException: Foreign key constraint is not allowed for this
      type of datastore
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.addForeignKeyConstrai
      nt(JDBCStartCommand.java:336)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.addForeignKeyConstrai
      nt(JDBCStartCommand.java:304)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.execute(JDBCStartComm
      and.java:123)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDB
      CStoreManager.java:457)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
      r.java:369)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManag
      er.java:198)
      at org.jboss.ejb.EntityContainer.start(EntityContainer.java:376)
      at org.jboss.ejb.Container.invoke(Container.java:756)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:978)
      at $Proxy5.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:398)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
      nDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
      at $Proxy21.start(Unknown Source)
      at org.jboss.ejb.EjbModule.startService(EjbModule.java:430)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:1
      65)
      at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
      nDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:978)
      at $Proxy5.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:398)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
      nDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
      at $Proxy11.start(Unknown Source)
      at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:395)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:807)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:621)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:585)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
      nDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
      at $Proxy4.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
      tScanner.java:435)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scanDirectory(URLDe
      ploymentScanner.java:656)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:507)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:212)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      loop(AbstractDeploymentScanner.java:225)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      run(AbstractDeploymentScanner.java:202)
      16:28:46,945 INFO [EjbModule] Started
      16:28:46,955 INFO [MainDeployer] Deployed package: file:/C:/jboss/3.0.4/server/
      default/deploy/openearth.jar
      16:28:46,965 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean ope
      ration 'checkIncompleteDeployments()'
      Cause: Incomplete Deployment listing:
      Packages waiting for a deployer:

      Incompletely deployed packages:

      MBeans waiting for classes:

      MBeans waiting for other MBeans:
      [ObjectName: jboss.j2ee:jndiName=openauth.entity.AuthGroupMapping,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: java.lang.IllegalStateException: Foreign key constraint is not a
      llowed for this type of datastore]
      ---

      The datastore is HSQLDB, which does support foreign key constraints (in fact, the AuthUser bean uses one to relate to an AuthDomain bean). The error SHOULD be that the foreign key constraint cannot be created due to the fact that AuthGroupMapping needs AuthGroup to be created BEFORE it can create a foreign key into that table!

      How can I specify that JBoss should perform this deployment intelligently? That is to say, if Bean B wants to have a foreign key constrain into Bean A, then Bean A must be deployed first so there is a table "A" for the foreign key constraint to be pointed into?

      Further information... if I keep deleting the EJB-JAR file and redeploying it... eventually all the necessary tables get created, and all beans (even AuthGroupMapping) are deployed successfully). However it will be quite embarrassing to give a JBoss demo this week to my coworkers, only to have to say "ignore the error messages as I deploy the EJB-JAR 4 or 5 times..."

      I am using JBoss 3.0.4 release. Any help would be greatly appreciated!

        • 1. Re: bad error message and table create order?
          Stephen Coy Novice

          Hi,

          If you look in conf/standardjbosscmp-jdbc.xml, you will see that the hsqldb (Hypersonic) mappings contain this element:

          <fk-constraint-template/>

          which indicates that fk constraints are not set up for it. I'm not familiar enough with hsqldb to know why this is so, but you can see examples of what could be in here for the other database mappings, and see if you can make it work that way.

          If you get it to work, please let us know so that we can fix it for the next release.

          Steve

          • 2. Re: bad error message and table create order?
            Samuel Montgomery-Blinn Newbie

            Aha. So the main problem is that HSQLDB does not support the "alter table" syntax. HSQLDB does support foreign keys, but apparently only in the "create table" syntax! JBoss is set up to use "alter table" to add foreign keys. However using the "create table" syntax actually serves to exacerbate the problem of bad order of table creations.

            IMHO, JBoss should intelligently create dependent tables prior to creating the tables which reference them. Thanks for the pointer -- I'll either remove the FK constraint from my deployment or switch to a more feature-complete datasource (McKoi more than likely).

            • 3. Re: bad error message and table create order?
              Jeremy Boynes Newbie

              Defining keys in "create table" really requires that the database support "create schema", allowing multiple tables to be created in a single operation to handle circular references. Ironically anything supporting that is likely to have "alter table" support already.