renatoathaydes / osgi-run

Osgi-Run - A Gradle plugin to make the development of modular applications using OSGi completely painless
Apache License 2.0
54 stars 13 forks source link

Cannot execute runOSGI task under gradle 7.3.3 #70

Closed Angular-Angel closed 2 years ago

Angular-Angel commented 2 years ago

When I try, I get the following errors:

Problem creating boot delegation class loader: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.security.SecureClassLoader(java.lang.ClassLoader) accessible: module java.base does not "opens java.security" to unnamed module @2957fcb0
org.osgi.framework.BundleException: Unable to resolve jline [1](R 1.0): missing requirement [jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5)) Unresolved requirements: [[jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5))]
ERROR: Bundle jline [1] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/jline-2.14.2.jar (org.osgi.framework.BundleException: Unable to resolve jline [1](R 1.0): missing requirement [jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5)) Unresolved requirements: [[jline [1](R 1.0)] osgi.ee; (&(osgi.ee=JavaSE)(version=1.5))])
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.base/java.lang.Thread.run(Thread.java:833)
org.osgi.framework.BundleException: Unable to resolve org.apache.felix.scr [2](R 2.0): missing requirement [org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8))) Unresolved requirements: [[org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8)))]
ERROR: Bundle org.apache.felix.scr [2] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/org.apache.felix.scr-2.0.12.jar (org.osgi.framework.BundleException: Unable to resolve org.apache.felix.scr [2](R 2.0): missing requirement [org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8))) Unresolved requirements: [[org.apache.felix.scr [2](R 2.0)] osgi.ee; (|(&(osgi.ee=JavaSE)(version=1.6))(&(osgi.ee=JavaSE/compact1)(version=1.8)))])
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.base/java.lang.Thread.run(Thread.java:833)
org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-api [4](R 4.0): missing requirement [com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)]
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
ERROR: Bundle com.athaydes.osgiaas.cli-api [4] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/osgiaas-cli-api-0.7.jar (org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-api [4](R 4.0): missing requirement [com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.cli-api [4](R 4.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)])
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.base/java.lang.Thread.run(Thread.java:833)
ERROR: Bundle com.athaydes.osgiaas.cli-core [5] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/osgiaas-cli-core-0.7.jar (org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-core [5](R 5.0): missing requirement [com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0))) [caused by: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)] Unresolved requirements: [[com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0)))])
org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.cli-core [5](R 5.0): missing requirement [com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0))) [caused by: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)] Unresolved requirements: [[com.athaydes.osgiaas.cli-core [5](R 5.0)] osgi.wiring.package; (&(osgi.wiring.package=com.athaydes.osgiaas.api.env)(version>=0.7.0)(!(version>=1.0.0)))]
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.base/java.lang.Thread.run(Thread.java:833)
ERROR: Bundle com.athaydes.osgiaas.common [6] Error starting file:/home/angle/Documents/Programming/Java/OSGIGradleSandbox/build/osgi/bundle/osgiaas-common-0.7.jar (org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)])
org.osgi.framework.BundleException: Unable to resolve com.athaydes.osgiaas.common [6](R 6.0): missing requirement [com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation) Unresolved requirements: [[com.athaydes.osgiaas.common [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation)]
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4148)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2118)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1372)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.base/java.lang.Thread.run(Thread.java:833)
> Task :runOsgi

This is without adding any bundle to the project, and only using the default osgiRuntime.

renatoathaydes commented 2 years ago

Hi. This plugin has not been updated in a long time, unfortunately, so it can't run with newer versions of Gradle (which keeps changing, causing this kind of problem).

I do want to get back to this project at some point, but I can't promist I will fix this soon. If you have time to submit a PR, i would be happy to help merge a fix.

renatoathaydes commented 2 years ago

Actually , looking at the errors, it seems more related to Java 11? I never tried to run this on JDK11. I think that should be easy to fix.

renatoathaydes commented 2 years ago

@Angular-Angel I have been able to get things running by upgrading all dependencies.

Try something like this and it should work:

plugins {
    id 'com.athaydes.osgi-run'
}

repositories {
    mavenCentral()
}

def GOGO_BUNDLES = [
        'org.apache.felix:org.apache.felix.gogo.runtime:1.1.4',
        'org.apache.felix:org.apache.felix.gogo.shell:1.1.4',
        'org.apache.felix:org.apache.felix.gogo.command:1.1.2',
].collect { [ dependency: it, transitive: false ] }.asImmutable()

runOsgi {
    osgiMain = "org.apache.felix:org.apache.felix.main:7.0.1"
    bundles = GOGO_BUNDLES
}

The error you reported about the annotations missing could be fixed with this (if running on Felix):

runOsgi {
    osgiMain = "org.apache.felix:org.apache.felix.main:7.0.1"
    bundles = GOGO_BUNDLES
    config += [ 'org.osgi.framework.system.packages.extra': 'javax.annotation' ]
}

I will try to publish an updated version of the plugin, but as lots of things have changed recently, it's not a trivial amount of work.

Angular-Angel commented 2 years ago

Hmm, gotcha. I'll try and figure something out on monday, will get back to you then!

renatoathaydes commented 2 years ago

I am pushing some code on the dev branch. I think I got both Felix and Equinox working again, but have to enable all test projects still to be sure.

Please try the dev branch to see if everything works for you.

renatoathaydes commented 2 years ago

I published version 2.0 of the plugins, built against Gradle 7.4.

It's already on Maven Central and should be soon in the Gradle Plugin Repository.

Let me know if you run into problems.

Angular-Angel commented 2 years ago

Okay, so it looks like it works now? Except when I use the 'runOsgi' task, it gives me:

Feb 14, 2022 12:13:34 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)

And then when I try the various commands in terminal, it doesn't seem to respond? But if I run 'stop 0' then a couple seconds later it will give some kind of error and shut down, so maybe it's getting the commands and responding to them, but just not giving me any output from them? :/

I found this other issue with the same error message, which was fixed by this commit, which updated the version of jline and added jansi, so maybe that's the issue? Though, I tried doing this on my end via adding those dependencies and it didn't change anything, even when I excluded any versions from osgi-run. :/

Edit: Oh, also, the text of that error I eventually get on telling it to 'exit' or 'stop 0':


Exception in thread "Thread-410" java.io.IOException: Stream closed
    at java.base/java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:168)
    at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:289)
    at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:343)
    at java.base/java.io.FilterInputStream.read(FilterInputStream.java:106)
    at java_io_FilterInputStream$read.call(Unknown Source)
    at com.athaydes.gradle.osgi.RunOsgiTask$_consume_closure1.doCall(RunOsgiTask.groovy:90)
    at com.athaydes.gradle.osgi.RunOsgiTask$_consume_closure1.doCall(RunOsgiTask.groovy)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:274)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1035)
    at groovy.lang.Closure.call(Closure.java:412)
    at groovy.lang.Closure.call(Closure.java:406)
    at groovy.lang.Closure.run(Closure.java:493)
    at java.base/java.lang.Thread.run(Thread.java:833)
Angular-Angel commented 2 years ago

Oh, should I make a new issue for this?

renatoathaydes commented 2 years ago

Please try running it like this:

./gradlew createOsgi

chmod +x build/osgi/run.sh
build/osgi/run.sh

It seems like your terminal was not detected when running the run task... so try running it directly as shown above. If you still have issues, send me the contents of your osgi/bundle directory.

renatoathaydes commented 2 years ago

Also, what OS are you using? And what terminal?

Angular-Angel commented 2 years ago

Huh, yeah, okay, it works like that. I'm using Xubuntu 20.04 (focal), running the thing via netbeans. Works fine when I run it via xfce4-terminal. So, it must be a problem due to netbeans, good to know. :/

Angular-Angel commented 2 years ago

Huh, wait though. When I do './gradlew runOsgi' in xfce4-terminal, I get the same issue. So it's not just netbeans. :/

Angular-Angel commented 2 years ago

I created a new issue: https://github.com/renatoathaydes/osgi-run/issues/71