Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:22:58+00:00 2026-06-07T10:22:58+00:00

I have a class which runs an Equinox framework. Now I would like to

  • 0

I have a class which runs an Equinox framework. Now I would like to get an Object (defined in one of the bundles) that is returned by a service out of the framework.

Unfortunately, I get a LinkageError and have no idea how to get rid of it. Is it even possible to let a service return a proper object to non-bundle code?

Here is the full story:

ParserDTOBundle is a bundle that defines the class ParserDTO and exports the corresponding package.

In another bundle, ParserServiceBundle, I define a service called ParserService. This bundle imports the package of the ParserDTO. The function getDTO() of ParserService creates a new ParserDTO object and returns it.

Now I created another class which starts an Equinox framework and loads both bundles from a directory:

...
EclipseStarter.setInitialProperties(frameworkPropertiesMap);
bundleContext = EclipseStarter.startup(new String[] { "-console", "-dev", "bin" }, null);

bundleContext.installBundle("file:/" + dir + "ParserDTOBundle-0.0.1-SNAPSHOT.jar");
Bundle service = bundleContext.installBundle("file:/" + dir + "ParserServiceBundle-0.0.1-SNAPSHOT.jar");
service.start();

ServiceReference serviceReference = bundleContext.getServiceReference(ParserService.class.getName());

if (serviceReference != null) {
     ParserService ps = (ParserService) bundleContext.getService(serviceReference);
     if (ps != null) {
          ParserDTO dto = ps.getDTO();
          System.out.println(dto.getValue());
     }
 }

The above described class is part of a non-bundle Maven project.
The run of the above class fails with:

Exception in thread "main" java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "de/ParserDTO"

Interestingly, I get this error at the System.out.println and not the line before.
The class loader of the ParserDTO class in my main class is obviously different from the class loader of the object dto.

How can I get the information stored in dto?? Is that even possible??
Do I have to 1.) hand my normal class loader to the bundle or 2.) use basic datatypes instead or 3.) some completly other way??

Thank you all in advance!
Sebastian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:23:00+00:00Added an answer on June 7, 2026 at 10:23 am

    So the class ParserDTO has been independently loaded by two different class loaders: the one inside your bundle, and the application classloader from your “outer” application. You need to make sure it is loaded only by one classloader.

    When this problem occurs with two ordinary bundles, the key is to make sure that one bundle exports the package and the other imports it (OR they both import it from a third bundle).

    However in this case you are interacting between the outer application and bundles inside OSGi. There is a hard rule: the OSGi framework cannot import packages from bundles inside OSGi. So the package has to be present in the outer application and exported from the system bundle by adding it to FRAMEWORK_SYSTEMPACKAGES_EXTRA. Also make sure that the bundle imports that package rather than having its own copy.

    BTW… you might want to choose a better name for the package than just de! I don’t think that you are the only Java developer in Germany, so you don’t own that namespace 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nose test that imports a file which runs a class with
I have a php file that contains class which runs some lengthy database operations.
I have a Class A which runs activity via startActivityForResult by passing Intent to
I have a class called ModelView which inherits from NSOpenGLView. When my program runs
I have class which have one public method Start , one private method and
I have class World which manages creation of object... After creation it calls afterCreation
I have class Employee which is something like this. class Emp { int EmpID;
I have a class which contains a static collection that can be used across
I have got a class which is called BaseCore which just runs all the
I have a class which is being operated on by two functions. One function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.