3 Replies Latest reply on May 27, 2004 12:41 PM by sbv_chris

    jboss/oracle/xdoclet auto-increment

    sbv_chris

      Hi,

      I have an oracle 9i table set up with a sequence and trigger to support auto-increment. I've tried to enable this functionality on the entity bean in jboss using xdoclet tags but can't seem to get it right.


      Bean level tags:

      * @jboss.unknown-pk
       * class="java.lang.Object"
       * column-name="news_id"
       * auto-increment="true"
       *
      * @jboss.entity-command name="oracle-sequence"
      * jboss.entity-command-attribute name="sequence" value="news_increment"
      


      Method level:
      removed the primary key cmp fields from the bean class.

      I get the following error message:

      2004-05-26 10:17:12,703 ERROR [org.jboss.ejb.EntityContainer] Starting failed
      org.jboss.deployment.DeploymentException: Couldn't create entity command: ; - nested throwable: (java.lang.NullPointerException)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityCommand(JDBCCommandFactory.java:158)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDBCStoreManager.java:466)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:388)
       at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:152)
       at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:342)
       at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
       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:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
       at $Proxy14.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:394)
       at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy132.start(Unknown Source)
       at org.jboss.ejb.EjbModule.startService(EjbModule.java:331)
       at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
       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:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
       at $Proxy14.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:394)
       at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy12.start(Unknown Source)
       at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:544)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:824)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
       at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy6.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
       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.keygen.JDBCOracleCreateCommand.initInsertSQL(JDBCOracleCreateCommand.java:53)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.init(JDBCAbstractCreateCommand.java:95)
       at org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand.init(JDBCOracleCreateCommand.java:38)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityCommand(JDBCCommandFactory.java:150)
       ... 56 more
      2004-05-26 10:17:12,703 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:jndiName=NewsDetails,service=EJB
      org.jboss.deployment.DeploymentException: Couldn't create entity command: ; - nested throwable: (java.lang.NullPointerException)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityCommand(JDBCCommandFactory.java:158)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDBCStoreManager.java:466)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:388)
       at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:152)
       at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:342)
       at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
       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:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
       at $Proxy14.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:394)
       at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy132.start(Unknown Source)
       at org.jboss.ejb.EjbModule.startService(EjbModule.java:331)
       at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
       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:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
       at $Proxy14.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:394)
       at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy12.start(Unknown Source)
       at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:544)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:824)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
       at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy6.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
       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.keygen.JDBCOracleCreateCommand.initInsertSQL(JDBCOracleCreateCommand.java:53)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.init(JDBCAbstractCreateCommand.java:95)
       at org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand.init(JDBCOracleCreateCommand.java:38)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityCommand(JDBCCommandFactory.java:150)
       ... 56 more
      


      I've also tried to get the "TEST_SEQUENCE" defined in standardjbosscmp-jdbc.xml defined in oracle and use it, though getting the same results.
      Thanks again for taking the time.

      Regards,
      Sunil.

      P.S. Is there a simple example/tutorial on how to get the auto-increment feature of oracle to work with jboss entity beans (using xdoclet tags) available online?

        • 1. Re: jboss/oracle/xdoclet auto-increment
          ironbird
          • 2. Re: jboss/oracle/xdoclet auto-increment
            lafr

            I have it working with this tags:
            at bean level I have e.g.:
            * @jboss.entity-command name="oracle-sequence"
            * @jboss.entity-command-attribute name="sequence" value="mbi_afsta_seq"

            for the primary key field then I have:
            * @jboss.auto-increment

            The PK-field is defined as usual in the bean.

            The insert-command generated by jboss looks like this then:
            [org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand.MbiAfsta.initInsertSQL] Insert Entity SQL: {call INSERT INTO AFSTA (afsta_serial, vg_comp_nr, vg_lfd_nr, vg_tf1_nr, vg_tf2_nr, auf_art_nr, aus_art_nr, v_aus_art_nr, tf1_max, tf2_max, debitor_nr, d_adress_nr, objekt_no, avis_nr, verband_nr, v_adress_nr, r_adress_nr, regulierer, a_adress_nr, kdsbe_adress_nr, dvksb_adress_nr, erf_dat, best_dat, eing_dat, prs_bez_dat, txt_bez_dat, stat_knz, aend_nr, sperr_knz_nr, sperr_knz_sb, sprach_nr, land_nr, fw_nr, fw_rech_knz, waehr_p, kurs, forder_code, versart_nr, prl_nr, liefbed_nr, sped_nr, kfz_knz, tour_nr, tour_rang_nr, wunsch_term1, wunsch_term2, lieft_norm, lieft_kurz, lief_term1, lief_term2, termfind_dat, lief_termbmk, fert_term1, fert_term2, ltz_aenddat, ltz_aendbmk, zahlbed_knz, zahlbed_nr, skonto_nr, skonto_tage1, skonto_proz1, skonto_tage2, skonto_proz2, tage_netto, valuta_tage, valuta_dat, faellig_dat, vk_abt_nr, vk_sa_bear_1, vk_sa_bear_2, beleg_nr, beleg_dat, buch_dat, knz_verarb, knz_teillief, ltg_teillief, gewicht_netto, gewicht_brutto, volumen_cbm, prod_st, skontofaeh_lw, auft_netto_lw, auft_brutto_lw, festpr_ne_lw, preise_inc, skontofaeh_lw_inc, auft_netto_lw_inc, auft_brutto_lw_inc, festpr_ne_lw_inc, montage_knz, deb_erl_grp_nr, lager_nr_zug, lager_nr_abg, deb_best_nr, aend_dr_nr, musterk_knz, sammrech_kunde, rech_stellung, sort_nr, knz, x_kdsbe_mail, x_anz_verladepos) VALUES (mbi_afsta_seq.NEXTVAL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING afsta_serial INTO ? }

            You'll have to call ejbCreate with PK-Value 0.
            After EjbCreate the PK-field is filled with the value from the sequence.

            What did you mean with "trigger" ? A DB-Trigger on insert ?
            This would probably disturb the above action. Drop it.
            Or at least, make sure the trigger fills the PK-field only if value is 0.

            • 3. Re: jboss/oracle/xdoclet auto-increment
              sbv_chris

              Thanks, that helped a lot. The sequence is being used now to auto-increment. and yes, the trigger isn't needed. Thanks again for the precise help!

              Regards,
              Sunil.

              "lafr" wrote:
              I have it working with this tags:
              at bean level I have e.g.:
              * @jboss.entity-command name="oracle-sequence"
              * @jboss.entity-command-attribute name="sequence" value="mbi_afsta_seq"

              for the primary key field then I have:
              * @jboss.auto-increment

              The PK-field is defined as usual in the bean.

              ...

              You'll have to call ejbCreate with PK-Value 0.
              After EjbCreate the PK-field is filled with the value from the sequence.