OpenJPA
  1. OpenJPA
  2. OPENJPA-1524

ManagedRuntime does not work for OSGi

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-beta
    • Fix Version/s: 2.0.0-beta3
    • Component/s: osgi
    • Labels:
      None

      Description

      In an OSGi runtime there is no TransactionManager registered in JNDI

      It is possible to use an osgi:services/ lookup, but it is much safer, and better practice to look up the resource in the OSGi service registry.

        Issue Links

        There are no Sub-Tasks for this issue.

          Activity

          Hide
          Timothy Ward added a comment -

          One implementation suggestion would be to use a ServiceTracker to keep track of the JTA services. This would allow for lazy lookup and also provide a notification if the service is unregistered.

          This should then be possible to implement as a relatively simple subclass of RegistryManagedRuntime that overrides getTransactionManager(). I don't know if you have a nice mechanism to pass a BundleContext yet, but I don't think that should pose a significant problem.

          Show
          Timothy Ward added a comment - One implementation suggestion would be to use a ServiceTracker to keep track of the JTA services. This would allow for lazy lookup and also provide a notification if the service is unregistered. This should then be possible to implement as a relatively simple subclass of RegistryManagedRuntime that overrides getTransactionManager(). I don't know if you have a nice mechanism to pass a BundleContext yet, but I don't think that should pose a significant problem.
          Hide
          Joe Bohn added a comment -

          To work around this I've added the following property to my persistence.xml - so you will need to use a name similar to this.

          <property name="openjpa.ManagedRuntime" value="jndi(TransactionManagerName=aries:services/javax.transaction.TransactionManager)"/>

          Show
          Joe Bohn added a comment - To work around this I've added the following property to my persistence.xml - so you will need to use a name similar to this. <property name="openjpa.ManagedRuntime" value="jndi(TransactionManagerName=aries:services/javax.transaction.TransactionManager)"/>
          Hide
          Donald Woods added a comment - - edited

          The r920553 change to include the Aries specific JNDI lookup is working, but I'd like to create a generic OSGiManagedRuntime class that would work for other vendors too. But as I'm looking at the Aries transaction module, I'm not seeing how it is being registered in the ServiceRegistry with a common OSGi name that isn't Aries specific.

          transaction/transaction-manager/target/sources/org/apache/aries/transaction/Activator.java:45 -
          props.put(Constants.SERVICE_PID, getName());
          bundleContext.registerService(ManagedServiceFactory.class.getName(), this, props);

          where getName() is -
          public String getName()

          { return "org.apache.aries.transaction"; }

          Shouldn't the Aries TransactionManagerService also be registered as "javax.transaction.TransactionManager"?

          Show
          Donald Woods added a comment - - edited The r920553 change to include the Aries specific JNDI lookup is working, but I'd like to create a generic OSGiManagedRuntime class that would work for other vendors too. But as I'm looking at the Aries transaction module, I'm not seeing how it is being registered in the ServiceRegistry with a common OSGi name that isn't Aries specific. transaction/transaction-manager/target/sources/org/apache/aries/transaction/Activator.java:45 - props.put(Constants.SERVICE_PID, getName()); bundleContext.registerService(ManagedServiceFactory.class.getName(), this, props); where getName() is - public String getName() { return "org.apache.aries.transaction"; } Shouldn't the Aries TransactionManagerService also be registered as "javax.transaction.TransactionManager"?
          Hide
          Donald Woods added a comment -

          JNDI solution was added back on March 8th and will be in 2.0.0-beta3.
          Opened OPENJPA-1593 as a subtask to look at adding an OSGiManagedRuntime in 2.1.

          Show
          Donald Woods added a comment - JNDI solution was added back on March 8th and will be in 2.0.0-beta3. Opened OPENJPA-1593 as a subtask to look at adding an OSGiManagedRuntime in 2.1.

            People

            • Assignee:
              Donald Woods
              Reporter:
              Timothy Ward
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development