Skip to content
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

Added OSGi support #1063

Merged
merged 4 commits into from
Sep 9, 2018
Merged

Added OSGi support #1063

merged 4 commits into from
Sep 9, 2018

Conversation

ponziani
Copy link
Contributor

@ponziani ponziani commented Sep 8, 2018

I've OSGi-ed the 4 main modules of Rest Assured and added some integration tests to check the correct OSGi behaviour (using the techniques you already know form awaitility).

This makes https://github.com/ops4j/org.ops4j.pax.tipi/tree/master/rest-assured-3.0.2 obsolete. I've tried using the new OSGi-ed version in a project of my own and the tests were succesful.

Please have a look ..

@ponziani ponziani closed this Sep 8, 2018
@ponziani ponziani reopened this Sep 8, 2018
@johanhaleby
Copy link
Collaborator

Thanks a lot, excellent!

@johanhaleby johanhaleby merged commit 9e64f1a into rest-assured:master Sep 9, 2018
@ponziani
Copy link
Contributor Author

ponziani commented Sep 9, 2018

You're welcome.

Any plans for a 3.1.2 release at the moment?

@johanhaleby
Copy link
Collaborator

johanhaleby commented Sep 13, 2018 via email

@johanhaleby
Copy link
Collaborator

@ponziani I'm trying to release REST Assured now but I have trouble getting the OSGi tests working with Java 11. I get this error when I run from Maven (it works from Intellij):


ERROR: Bundle jaxb-api [22] Error starting file:/var/folders/9z/tqq6c03j3l33pv9k1c24hsnw0000gn/T/1539936843065-0/pax-exam-downloads/jaxb-api_2.2.12.jar (org.osgi.framework.BundleException: Unable to resolve jaxb-api [22](R 22.0): missing requirement [jaxb-api [22](R 22.0)] osgi.wiring.package; (osgi.wiring.package=javax.activation) Unresolved requirements: [[jaxb-api [22](R 22.0)] osgi.wiring.package; (osgi.wiring.package=javax.activation)])
org.osgi.framework.BundleException: Unable to resolve jaxb-api [22](R 22.0): missing requirement [jaxb-api [22](R 22.0)] osgi.wiring.package; (osgi.wiring.package=javax.activation) Unresolved requirements: [[jaxb-api [22](R 22.0)] osgi.wiring.package; (osgi.wiring.package=javax.activation)]
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4362)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2277)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1535)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:834)
ERROR: Bundle io.rest-assured [24] Error starting file:/var/folders/9z/tqq6c03j3l33pv9k1c24hsnw0000gn/T/1539936843065-0/pax-exam-downloads/io.rest-assured_3.1.2.SNAPSHOT.jar (org.osgi.framework.BundleException: Unable to resolve io.rest-assured [24](R 24.0): missing requirement [io.rest-assured [24](R 24.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.xml.bind.annotation)(version>=2.2.0)(!(version>=3.0.0))) [caused by: Unable to resolve jaxb-api [22](R 22.0): missing requirement [jaxb-api [22](R 22.0)] osgi.wiring.package; (osgi.wiring.package=javax.activation)] Unresolved requirements: [[io.rest-assured [24](R 24.0)] osgi.wirorg.osgi.framework.BundleException: Unable to resolve io.rest-assured [24](R 24.0): missing requirement [io.rest-assured [24](R 24.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.xml.bind.annotation)(version>=2.2.0)(!(version>=3.0.0))) [caused by: Unable to resolve jaxb-api [22](R 22.0): missing requirement [jaxb-api [22](R 22.0)] osgi.wiring.package; (osgi.wiring.package=javax.activation)] Unresolved requirements: [[io.rest-assured [24](R 24.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.xml.bind.annotation)(version>=2.2.0)(!(version>=3.0.0)))]
ing.package; (&(osgi.wiring.package=javax.xml.bind.annotation)(version>=2.2.0)(!(version>=3.0.0)))])
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4362)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2277)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1535)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:834)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.523 sec <<< FAILURE! - in io.restassured.test.osgi.RestAssuredOSGiITest

Do you know how to solve this?

@johanhaleby
Copy link
Collaborator

Managed to work-around it by adding:

wrappedBundle(mavenBundle("javax.activation", "activation").version("1.1.1"))

but no I get other exceptions:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.678 sec <<< FAILURE! - in io.restassured.test.osgi.RestAssuredOSGiITest
restAssured(io.restassured.test.osgi.RestAssuredOSGiITest)  Time elapsed: 4.666 sec  <<< ERROR!
java.lang.ClassNotFoundException: Unable to load class 'jdk.internal.reflect.ConstructorAccessorImpl'
	at org.apache.felix.framework.BundleWiringImpl$1.loadClass(BundleWiringImpl.java:91)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1541)
	at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at org.codehaus.groovy.runtime.callsite.CallSiteClassLoader.loadClass(CallSiteClassLoader.java:54)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.loadClass(ClassLoaderForClassArtifacts.java:59)
	at java.base/jdk.internal.misc.Unsafe.defineClass0(Native Method)
	at java.base/jdk.internal.misc.Unsafe.defineClass(Unsafe.java:1192)
	at java.base/jdk.internal.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
	at java.base/jdk.internal.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:400)
	at java.base/jdk.internal.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:394)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/jdk.internal.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:393)
	at java.base/jdk.internal.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:92)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:55)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.codehaus.groovy.reflection.CachedMethod.createStaticMetaMethodSite(CachedMethod.java:306)
	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.createStaticMetaMethodSite(StaticMetaMethodSite.java:114)
	at groovy.lang.MetaClassImpl.createStaticSite(MetaClassImpl.java:3421)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:76)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:197)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)
	at io.restassured.internal.RequestSpecificationImpl.header(RequestSpecificationImpl.groovy:935)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
	at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:47)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:177)
	at io.restassured.internal.RequestSpecificationImpl.newFilterContext(RequestSpecificationImpl.groovy:1147)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
	at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:47)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
	at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1742)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
	at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:47)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
	at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1750)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:822)
	at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:47)
	at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
	at io.restassured.internal.RequestSpecificationImpl.get(RequestSpecificationImpl.groovy:171)
	at io.restassured.internal.RequestSpecificationImpl.get(RequestSpecificationImpl.groovy)
	at io.restassured.test.osgi.RestAssuredOSGiITest.restAssured(RestAssuredOSGiITest.java:68)

which looks like a problem with Apache Felix?

@ponziani
Copy link
Contributor Author

Hi Johan,

Were you able to fix it for 3.2.0? I can try myself during the weekend if needed ..

@johanhaleby
Copy link
Collaborator

@ponziani I couldn't get it working with Java 11, but it works fine with Java 8. So I changed the travis integration to only include the osgi tests when using Java 8. So I'm not sure if it's a Java 11 issue or if it's just an issue with the tests. Would be great if you could check it out and provide some feedback.

@ponziani
Copy link
Contributor Author

Hi Johan,

  • It looks like it's a Felix issue indeed, not ready for java 11 (yet).
  • Your solution to exclude the OSGi-module, has caused a mismatching version-number for the module. You can find the reason why and how to fix that here.

@johanhaleby
Copy link
Collaborator

Thanks for pointing out the version mismatch, I guess that's because I need to include it when I make the release.

@ponziani
Copy link
Contributor Author

I guess you could choose for the module to be part of the build by default, which makes you cannot forgot about it, but you need to exclude it manually when using java11.

@johanhaleby
Copy link
Collaborator

johanhaleby commented Oct 28, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants