0

When compiling a project in idea IDE, error occurs: Error:osgi: [Test] The default package '.' is not permitted by the Import-Package syntax. This can be caused by compile errors in Eclipse because Eclipse creates valid class files regardless of compile errors. The following package(s) import from the default package null

But when using Eclipse ide, it works. I've googled times, only found this post , but it's not my case. I de-compiled the produced class by OSGI, there's no class has syntax like import . Any idea for this problem?

enter image description here

4
  • Do you have any compile errors currently in your project? I.e. are there any red X markers next to the code? Commented Aug 19, 2016 at 4:17
  • @NeilBartlett I update the post. From idea IDE. Commented Aug 19, 2016 at 5:54
  • I've googled this problem for times. After observing to the original pom closely, I found that I referred two dependencies but without property <scope>provided</scope> <optional>true</optional>. The test case can run under IntellJ idea now with adding the property. I don't know why, need to deeply dig Commented Aug 19, 2016 at 6:45
  • Yes I see I misread your question initially, sorry. The message from bnd that "this can be caused by compile errors in Eclipse" is just a hint really. One reason for having references to the default package from class files is this habit of Eclipse of generating classfiles even when the sources have compilation errors. But that obviously doesn't apply if you are using a different IDE. Commented Aug 19, 2016 at 7:59

2 Answers 2

1

Can you change package of your classes? That way eclipse will create new classes after compilation. Having '.' package is not good practice anyway.

Also, prefer different workspace for eclipse and intellij. Having 3 folders is good practice, one for source, one for eclipse workspace, one for intelliJ workspace. Each IDE creates their own files

Sign up to request clarification or add additional context in comments.

Comments

0

I got this error due to a Groovy script file that had import statements, but no package name at the start of the file. I added a package name to my Groovy script, ran a clean to erase my target directory, and then the problem went away.

See answer by Hemant in this similar issue

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.