code: @Override
      public EntityManagerFactory getEntityManagerFactory(ServiceDomain domain) {
          try {
              final Bundle bundle = getApplicationBundle(domain);
              if (bundle != null) {
                  Collection<ServiceReference<EntityManagerFactory>> refs = bundle.getBundleContext().getServiceReferences(EntityManagerFactory.class,
                                                                                                                           "(osgi.unit.name=org.jbpm.persistence.jpa)");
                  if (refs != null && refs.size() > 0) {
                      EntityManagerFactory emf = bundle.getBundleContext().getService(refs.iterator().next());
                      if (emf != null) {
                          return emf;
                      }
                  }
              }
          } catch (Exception e) {
              e.fillInStackTrace();
          }
          // try the default
          return super.getEntityManagerFactory(domain);
      }
docs: {@inheritDoc}