JUnit: Service-Component entry can not be located in JAR: OSGI-INF/component.xml



whenever I run a JUnit from IntelliJ shortcut I get the following error:

"Service-Component entry can not be located in JAR: OSGI-INF/component.xml"

I tried to open the produced jar and actually there is no OSGI-INF/compoment.xml file in it, but I never had the necessity to change the pom.xml to run JUnit or something.

References: https://www.jetbrains.com/help/idea/performing-tests.html#add-testing-libraries 

This is a maven project which is correctly producing the build (jar) and performs all the JUnit tests during the build. I tried to do the same (similar approach) on another IDE and I have no problem.

I'm dealing with OSGi and for some reason I cannot run tests anymore since few days. I installed these two plugins but even removing them, no luck!

  • Eclipse PDE Partial
  • OSGi

I also have:

  • Unit File Support (systemd)
  • SonarLint
  • GitToolBox

and many more which I think they are bundled with IntelliJ setup.

Could somebody help me please?



If possible can you please create a sample project where you experience the problem and attach it to the issue created at: https://youtrack.jetbrains.com/issues/IDEA

Thank you 



I have found a solution.

  1. Go to Select Run/Debug Configuration combobox
  2. Select Edit Configuration
  3. Under the JUnit configuration Select Modify Options and enable "Do not build before run"
  4. After that, I run again the test and bumped into the following error: Error running "MyClassNameTest". Command Line is too long. Shorten the command line via JAR manifest or via a classpath file and rerun.
  5. Clicked on "classpath file" above (something has been done automatically by IntelliJ)
  6. Run again JUnit - same error at point 4
  7. Clicked on "JAR manifest" on the popup, and this time IntelliJ did something which I don't know, that fixed the problem and let me run the tests

Basically, such build before run, was breaking JUnit Tests.


Hello everyone!

I have found the final solution for this problem.

Go to module settings -> Project Settings -> Facets -> (select the OSGi bundle) -> Under Bundle Creation just select "Create manifest from facet settings and bundle using facet configuration":

Hope it helps someone else!


Please sign in to leave a comment.