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

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open In Progress In Progress
          17d 5h 46m 1 Donald Woods 08/Mar/10 22:36
          In Progress In Progress Resolved Resolved
          13d 20h 39m 1 Donald Woods 22/Mar/10 19:15
          Resolved Resolved Closed Closed
          7d 4h 2m 1 Donald Woods 30/Mar/10 00:17
          Donald Woods made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Donald Woods made changes -
          Fix Version/s 2.0.0-beta3 [ 12314857 ]
          Fix Version/s 2.0.0 [ 12314019 ]
          Donald Woods made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          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.
          Donald Woods made changes -
          Link This issue relates to OPENJPA-1593 [ OPENJPA-1593 ]
          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"?
          Donald Woods made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          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)"/>
          Donald Woods made changes -
          Field Original Value New Value
          Assignee Donald Woods [ drwoods ]
          Fix Version/s 2.0.0 [ 12314019 ]
          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.
          Timothy Ward created issue -

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development