New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Found duplicate (but equal) classes in multiple 3.2.0 artifacts #1117
Comments
Hmm it's definitely not intentional. When do you see this? |
@johanhaleby those warnings are from the https://github.com/basepom/duplicate-finder-maven-plugin A quick peek at the raw This was not a problem in |
@johanhaleby @ponziani it looks like this is perhaps caused by the usage of the If I'm reading this correctly [1], it looks like you're exporting classes from various packages which is effectively bundling/packaging those classes from each child into the other child JARs. Hence, the duplication. For instance, this: ...effectively copies (duplicates) classes from That doesn't seem right. Is this intentional? |
It looks like the only good solution for this issue, is a refactoring to avoid split packages. After that, the statements can be refined to only contain the packages from the bundles itselves. |
A fun thread with @johanhaleby @ponziani and @azzazzel on Twitter indicates we may have found a possible solution: |
I'm ready to make an attempt at solving this but I'm not quite sure where to start. @markkolich I had no idea that the "Sjarel" (could that be @ponziani?) suggested this on Twitter:
But what exactly do I need to rewrite? The The |
I got it to fail quite handily with a Here's a draft PR demonstrating the approach:
Exactly – that is the problem. If As a result, the The If it's really required to copy all classes in this project into a single JAR for OSGi support, perhaps repurposing |
@markkolich Thanks for your comments. I see now that I actually did get warnings (but the build didn't fail which I expected it to do so this is why I didn't notice anything). Could you make your PR a non-draft PR so that I can merge it?
During the
This sounds much better if it really is required, but I strongly suspect that it isn't. I'd be happy to remove the Anyway I'm truly grateful for all your help! |
Sure thing; done!
Understood. The This was not a problem in 3.1.1. When I upgraded to rest-assured 3.2.0, that's when the The cause of that appears to be #1063. |
Folks, I can try to clone and play with the project during the weekend. The solution seems to be rather simple (from pure OSGi perspective). However I'm not familiar with the project itself so I would need your help. Are there any tests that actually test the project behaves properly in OSGi environment? If so can you please provide some details how to run them. If not, can someone please explain what is expected when using the project in OSGi env. |
@azzazzel Would be great if you could have a look. There are tests in the /examples/rest-assured-itest-java-osgi project. They are activited with the The osgi tests are executed by travis automatically (on oraclejdk8) on every commit. |
I'm only now able to answer this thread, sorry about showing up late. Some thoughts :
@azzazzel Too bad you're not familiar with rest-assured yet, it's really great for testing REST-services. Thanks for your help ! Big fan of your talks btw... |
@azzazzel @ponziani @markkolich This is probably not the right forum but I'm trying to upgrade to Groovy 2.5.6 and the OSGi tests fails: Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.586 sec <<< FAILURE! - in io.restassured.test.osgi.XmlPathOSGiITest
getUUIDParsesAStringResultToUUID(io.restassured.test.osgi.XmlPathOSGiITest) Time elapsed: 2.567 sec <<< ERROR!
java.io.IOException: Error resolving artifact org.codehaus.groovy:groovy-all:jar:2.5.6: Could not find artifact org.codehaus.groovy:groovy-all:jar:2.5.6 in central (http://repo1.maven.org/maven2/) I don't understand why changing the version from 2.4.15 to 2.5.6 (that does indeed exist in maven central albeit the error message seem to indicate that it doesn't) would generate this error. Any ideas on how I can fix it? |
@johanhaleby Could it be because you are expecting a JAR ( |
@azzazzel Thanks for the tip. But from what I can tell there also seems to be a jar: https://search.maven.org/artifact/org.codehaus.groovy/groovy-all/2.5.6/jar |
@azzazzel But if I browse the repository I see that you're right. I guess they've removed this jar for some reason. Need to figure out how to upgrade properly. Thanks again for the hint! |
Looks like Groovy did quite a refactoring, I'm surprised they didn't up their major version number. That's exactly why the Maven property "groovy.range" has been added to RestAssured by the way. Anyway, I tried to replace the groovy-all dependency by
(The 2nd and 3rd bundle are Fragments which cannot be started) Unfortunately I don't know how to handle the error I'm getting now
I'm assuming the Fragment host (The 1st bundle I added) cannot be found, but I don't understand why. I succesfully tried accessing a package from the host bundle in the test itself and that works. By getting the groovy-json's state, I figured out it's INSTALLED, but I guess it should be RESOLVED. |
I'm sorry I don't have the time to play with it now. But basicaly the error says that "io.rest-assured.json-path" needs a package "groovy.json" which is in version range 2.5.0 >= x > 2.6.0 and can not find such package in the OSGi runtime. Most likely this is because what is on the compile classpath (which is where bnd gets the package versions from to put it in the metadata) is different from what you provide at runtime (in PaxExam statements above). |
I've tried the groovy bundle and groovy-json bundle into a standard Apache Felix and it turns out the groovy-json bundle is in status INSTALLED as well, with no logging to explain what went wrong. AFAIK a Fragment bundle should always get to status RESOLVED (is that correct @azzazzel ?), so I can only assume there is something wrong with the groovy-json bundle. |
Ah, this one was actually a tricky one ;)
that prevents the bundle from resolving unless there is support for service loader. Sadly neither Felix nor Pax Exam report the error properly! The OSGi support for service loader is provided by Aries SPI Fly project and thus one needs this bundle and the bundles providing the packages/services it depends on. At the end of the day this is what you need to make the OSGi tests pass: mavenBundle().groupId("org.apache.aries.spifly").artifactId("org.apache.aries.spifly.dynamic.bundle").version("1.2.1"),
mavenBundle().groupId("org.hamcrest").artifactId("hamcrest").version("2.1"),
mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy").version("2.5.6"),
mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy-json").version("2.5.6").noStart(),
mavenBundle().groupId("org.codehaus.groovy").artifactId("groovy-xml").version("2.5.6").noStart(), |
Impressive ! I read about this Groovy issue, but didn't see the connection with this Rest-Assured issue. After handling a Hamcrest problem I managed to get all 3 integration tests working again and created a PR. Do you feel we have enough info here to create an issue on the Felix bug tracker about the absence of proper error logging ? |
I discussed this with some far more knowledgable OSGi folks and it seams Felix behaves according to the specs. That sad, it's worth opening a feature request with Felix project to provide more detailed information for while fragments are not resolved. Technically the information should be there (in the form of Exception) it's just a matter of figuring out a way to properly deliver it to the user. |
I upgraded my project from
io.rest-assured:rest-assured
version3.1.1
to3.2.0
and my builds started complaining of duplicate classes present in multiple artifacts:Is this intentional?
CC // @larrysteinke
The text was updated successfully, but these errors were encountered: