Jump to content
OpenSplice DDS Forum
jonathanknez

DDS Within Java OSGi

Recommended Posts

I am trying to use DDS in a java application running in an OSGi environment. I keep running into class loading and link errors. We have everything working correctly in a standalone non-OSGi java application. I know OpenSplice supports OSGi so hopefully this is a quick problem to solve.

Background on our system

  1. Builds using maven
  2. Our application runs in Apache ServiceMix, which uses Apache Felix as the OSGi runtime.
  3. Using Vortex OpenSplice HDE Release 6.7.1705230SS, date 2017-06-05
  4. Running on CentOS 7
  5. Java JDK 1.8

Here is what we did

  1. Used maven to manually deploy the dcpssaj5.jar and dcpssaj.jar into the local maven repository so that we could include them in our project’s pom.xml file
  2. Updated our pom.xml file to depend on those jars. This allowed us to build our code without issues
  3. Loaded the bcpssaj5 bundle. Successfully loaded in Felix.
  4. Loaded our freshly build application bundle
  5. Initially got class loader errors as “org.opensplice.dds.core.OsplServiceEnvironment” was not found.
  6. Updated our code to manually create an OsplServiceEnvironment object. This hack got rid of the class loader errors but now we get link errors on org.opensplice.dds.dcps.ReportStack.

Our code is pretty simple

public DdsIpcController (int inDomainId)
{
	// force loading of needed class
	OsplServiceEnvironment temp = new OsplServiceEnvironment();
	
  	System.setProperty(ServiceEnvironment.IMPLEMENTATION_CLASS_NAME_PROPERTY, "org.opensplice.dds.core.OsplServiceEnvironment");

  	// Instantiate a DDS ServiceEnvironment
	env = ServiceEnvironment.createInstance(this.getClass().getClassLoader());
	// Get the DomainParticipantFactory
	dpf = DomainParticipantFactory.getInstance(env);
	// Create a DomainParticipant with default domainID
	domainParticipant = dpf.createParticipant(inDomainId);
	// Create Reliability and Durability QoS
	reliability = PolicyFactory.getPolicyFactory(env).Reliability().withReliable();
	durability = PolicyFactory.getPolicyFactory(env).Durability().withTransient();
}

So clearly we are not using dds correctly in an OSGi environment. I would appreciate any insights anyone has into this problem. Perhaps there is a tutorial or example that shows how to get it working.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×