6 Replies Latest reply: Sep 4, 2013 6:01 AM by ILya Cyclone RSS

    Set Up Primary Key Generation for MySQL -> TransactionManager not found

    ILya Cyclone

      Hello.

      ADF Essentials application on MySQL and GlassFish.

      Simple application with create row functionality.

      As there is no Sequence in MySQL we need something for key generation.

       

      Concerning this article: http://www.oracle.com/technetwork/developer-tools/jdev/multidatabaseapp-085183.html

      It says:

      Set Up Primary Key Generation

      Follow these steps if you need to generate unique identifiers for primary keys.

      1. Create a Unique Id Table
      ADF BC's unique id generation feature uses a database table to specify the range of ids that may be used, as well as the latest id in the sequence.  Create a database table named S_ROW_ID and add one row of data to the table, using the following format:

      Column NameData TypeComments
      START_IDNUMERIC(38,0)Starting id in the range. To avoid duplicate key errors, you must make sure this value is higher than any existing primary key values in your database.
      NEXT_IDNUMERIC(38,0)Next available id within current range (optional).
      MAX_IDNUMERIC(38,0)Maximum id in the range
      AUX_START_IDNUMERIC(38,0)Starting id in auxiliary block range (use 0 if no auxiliary block is available).
      AUX_MAX_IDNUMERIC(38,0)Maximum id in the auxiliary block range (use 0 if no auxiliary block is available).

       

      2. Create a Connection to the Table
      In your application, create a database connection named ROWIDAM_DB that points to the database containing your S_ROW_ID table. Alternatively, edit your BC project's properties and add the following Java option to the project's run configuration:
      -Djbo.rowid_am_conn_name= appconnection

      where appconnection is the name of a database connection that points to the S_ROW_ID table.


      3. Configure the Primary Key Attributes
      To generate a unique id for a primary key attribute, edit the entity object attribute and enter the following expression for the attribute's value:
      oracle.jbo.server.uniqueid.UniqueIdHelper.getNextId()

      Limitations of Primary Key Generation
      Since all primary keys are generated from a single row in the S_ROW_ID table, all entity objects in your application share the same sequence of keys. 

      --------------------------------------------------------------------------------

      Ok.

      1. Created S_ROW_ID table: https://www.dropbox.com/s/e6v6gsoyx9filw1/01.%20s_row_id.png

      Inserted one row.

      2. Created ROWIDAM_DB application DB connection: https://www.dropbox.com/s/qicx3ip2zzk0f07/02.%20rowidam_db.png

      3. Set PK value to oracle.jbo.server.uniqueid.UniqueIdHelper.getNextId() : https://www.dropbox.com/s/5k24druf8cfcsnp/03.%20primary%20key.png

       

      On runtime after CreateInsert click I get the followinf exceptions:

       

      javax.transaction.TransactionManager not found

      javax.naming.NamingException: Lookup failed for 'javax.transaction.TransactionManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: javax.transaction.TransactionManager not found]

      ...

      Caused by: javax.naming.NameNotFoundException: javax.transaction.TransactionManager not found

       

      I can edit data without problems but not creating it.

       

      JDev+ADFes 11.1.2.3, GlassFish 3.1.2.2, MySQL 5.6

      SQL flavor = SQL92, Type Map = Java

      Application and ViewProject deployment platform = GlassFish

       

      Any ideas what have I done wrong?

       

      Here is a simple application: https://www.dropbox.com/s/yr5h6umtzbkot9a/CreateRowTest.zip

       

      Thanks.