0 Replies Latest reply on Aug 30, 2004 5:38 AM by blondie21

    JBoss 3.2.6RC1 + PostgreSQL 7.4.1 + CMR + auto-increment pri

    blondie21 Newbie

      Hi,
      I'm trying to implement a 1:N relationship between two CMP EJBs. Each of them should have an auto-increment uid field and the Requirement EJB should have a field with a foreign key being the RequirementSpecification uid.
      For some reason I can't implement this, I'm getting NPE as follows:

      11:06:21,621 ERROR [EntityContainer] Starting failed jboss.j2ee:jndiName=ejb/Req
      uirementSpecification,service=EJB
      java.lang.NullPointerException
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$CMRJDBCType.
      (JDBCCMRFieldBridge.java:1960)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$CMRJDBCType.
      (JDBCCMRFieldBridge.java:1941)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.initializeFo
      reignKeyFields(JDBCCMRFieldBridge.java:1690)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.resolveRelat
      ionship(JDBCCMRFieldBridge.java:304)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.resolveRelatio
      nships(JDBCEntityBridge.java:278)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.resolveRelationships(
      JDBCStoreManager.java:455)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
      r.java:382)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManag
      er.java:147)
      at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:337)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:271)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:221)
      at sun.reflect.GeneratedMethodAccessor127.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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:837)
      at $Proxy17.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:367)
      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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy759.start(Unknown Source)
      at org.jboss.ejb.EjbModule.startService(EjbModule.java:367)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:271)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:221)
      at sun.reflect.GeneratedMethodAccessor127.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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:837)
      at $Proxy17.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:367)
      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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy14.start(Unknown Source)
      at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:570)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:836)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:645)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
      at sun.reflect.GeneratedMethodAccessor14.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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy7.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
      tScanner.java:304)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:478)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:201)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      loop(AbstractDeploymentScanner.java:212)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      run(AbstractDeploymentScanner.java:191)
      11:06:21,621 WARN [ServiceController] Problem starting service jboss.j2ee:jndiN
      ame=ejb/RequirementSpecification,service=EJB
      RuntimeMBeanException: java.lang.NullPointerException
      Cause: java.lang.NullPointerException
      at org.jboss.mx.server.ReflectedDispatcher.handleInvocationExceptions(Re
      flectedDispatcher.java:82)
      at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:64)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:837)
      at $Proxy17.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:367)
      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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy759.start(Unknown Source)
      at org.jboss.ejb.EjbModule.startService(EjbModule.java:367)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:271)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:221)
      at sun.reflect.GeneratedMethodAccessor127.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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:837)
      at $Proxy17.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:367)
      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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy14.start(Unknown Source)
      at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:570)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:836)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:645)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
      at sun.reflect.GeneratedMethodAccessor14.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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy7.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
      tScanner.java:304)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:478)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:201)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      loop(AbstractDeploymentScanner.java:212)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      run(AbstractDeploymentScanner.java:191)
      Caused by: java.lang.NullPointerException
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$CMRJDBCType.
      (JDBCCMRFieldBridge.java:1960)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$CMRJDBCType.
      (JDBCCMRFieldBridge.java:1941)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.initializeFo
      reignKeyFields(JDBCCMRFieldBridge.java:1690)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.resolveRelat
      ionship(JDBCCMRFieldBridge.java:304)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.resolveRelatio
      nships(JDBCEntityBridge.java:278)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.resolveRelationships(
      JDBCStoreManager.java:455)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
      r.java:382)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManag
      er.java:147)
      at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:337)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:271)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:221)
      at sun.reflect.GeneratedMethodAccessor127.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.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
      ... 65 more
      11:06:21,668 INFO [EJBDeployer] Deployed: file:/C:/cygwin/usr/src/jboss/jboss-3
      .2.6RC1-src/build/output/jboss-3.2.6RC1/server/default/deploy/ses.jar
      11:06:21,715 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
      MBeans waiting for other MBeans:
      ObjectName: jboss.j2ee:jndiName=ejb/RequirementSpecification,plugin=pool,service
      =EJB
      state: CREATED
      I Depend On:
      Depends On Me:
      ObjectName: jboss.j2ee:jndiName=ejb/RequirementSpecification,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: RuntimeMBeanException: java.lang.NullPointerException
      Cause: java.lang.NullPointerException

      MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM:
      ObjectName: jboss.j2ee:jndiName=ejb/RequirementSpecification,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: RuntimeMBeanException: java.lang.NullPointerException
      Cause: java.lang.NullPointerException
      ObjectName: jboss.j2ee:jndiName=ejb/RequirementSpecification,plugin=pool,service
      =EJB
      state: CREATED
      I Depend On:
      Depends On Me:


      This is a listing of relevant elements from my jbosscmp-jdbc.xml file:



      <jbosscmp-jdbc>

      java:/PostgresDS
      <datasource-mapping>PostgreSQL 7.2</datasource-mapping>
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <fk-constraint >true </fk-constraint >
      <unknown-pk>
      <unknown-pk-class>java.lang.Long</unknown-pk-class>
      <field-name>uid</field-name>
      <column-name>c_uid</column-name>
      <jdbc-type>BIGINT</jdbc-type>
      <sql-type>SERIAL</sql-type>
      <auto-increment/>
      </unknown-pk>
      <entity-command name="postgresql-fetch-seq"/>



      <enterprise-beans>

      <ejb-name>RequirementSpecification</ejb-name>
      <table-name>TEJBT_RequirementSpecification</table-name>
      <cmp-field>
      <field-name>uid</field-name>
      <column-name>c_uid</column-name>
      </cmp-field>




      <ejb-name>Requirement</ejb-name>
      <table-name>TEJBT_Requirement</table-name>

      <cmp-field>
      <field-name>uid</field-name>
      <column-name>c_uid</column-name>
      </cmp-field>

      ...... (other cmp-fields)









      <ejb-relation>
      <ejb-relation-name>Requirement-RequirementSpecificationrequirement</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Requirement
      </ejb-relationship-role-name>

      <key-fields>
      </key-fields>



      <ejb-relationship-role>
      <ejb-relationship-role-name>
      requirement
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>

      <field-name>uid</field-name>
      <column-name>fk_uid</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>INTEGER</sql-type>

      </key-field>
      </key-fields>

      </ejb-relationship-role>
      </ejb-relation>


      ....
      </jbosscmp-jdbc>


      And these are the relevant elements in my ejb-jar.xml file:

      <ejb-jar>




      <ejb-name>RequirementSpecification</ejb-name>
      <local-home>ejb.LocalRequirementSpecificationHome</local-home>
      ejb.LocalRequirementSpecification
      <ejb-class>ejb.RequirementSpecificationBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Object</prim-key-class>


      <query-method>
      <method-name>findAll</method-name>
      <method-params></method-params>
      </query-method>

      <ejb-ql>
      <![CDATA[SELECT OBJECT(a) FROM RequirementSpecification a]]>
      </ejb-ql>





      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>RequirementSpecification</abstract-schema-name>

      <cmp-field>
      <field-name>uid</field-name>
      </cmp-field>

      <resource-ref>
      PostgreSQL DS
      <res-ref-name>jdbc/PostgresDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      (the Requirement Bean is specified in the same way)

      <ejb-relation>
      <ejb-relation-name>Requirement-RequirementsubReq</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Requirement
      </ejb-relationship-role-name>
      Many
      <cascade-delete/>
      <relationship-role-source>
      <ejb-name>Requirement</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>
      subReq
      </ejb-relationship-role-name>
      One

      <relationship-role-source>
      <ejb-name>Requirement</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>
      subReq
      </cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>


      </ejb-jar>



      Thanks in advance for any help.
      Bl.