Closed Angular-Angel closed 2 years ago
hey @Angular-Angel I'm sorry to hear you're having troubles. So in order to test this quickly I usually have multiple JVMs installed and because maven is super friendly it will adhere to what you have set for JAVA_HOME which makes testing different versions really simple:
export JAVA_HOME=/usr/lib/jvm/<vendor>8
mvn -version
mvn clean verify
Can you try doing above with JDK 8 as well as for Java 17 and return the result?
Chances are if you are using stock project as configured will give you an error since it's using super old bnd-maven-plugin
. Try upping to 6.1.0
(in root of examples directory). (meanwhile, I'll send a PR to update the bnd version and any other small changes required.)
Hmm, let me see. I'm using netbeans, but I can tell it to use java 8...
Edit: Whoops, no, my mistake, I was building something else with Netbeans. Hold up, will test.
Okay, so, outputs:
(base) angle@Sager:~/Documents/Programming/Java/osgi.enroute/examples/quickstart$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
(base) angle@Sager:~/Documents/Programming/Java/osgi.enroute/examples/quickstart$ mvn -version
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /opt/apache-maven-3.8.3
Java version: 1.8.0_312, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-99-generic", arch: "amd64", family: "unix"
(base) angle@Sager:~/Documents/Programming/Java/osgi.enroute/examples/quickstart$ mvn clean verify
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] quickstart [pom]
[INFO] rest [jar]
[INFO] app [jar]
[INFO]
[INFO] ----------< org.osgi.enroute.examples.quickstart:quickstart >-----------
[INFO] Building quickstart 0.0.2-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ quickstart ---
[INFO]
[INFO] -------------< org.osgi.enroute.examples.quickstart:rest >--------------
[INFO] Building rest 0.0.2-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rest ---
[INFO] Deleting /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/classes
[INFO]
[INFO] --- bnd-maven-plugin:5.1.2:bnd-process (default) @ rest ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rest ---
[INFO] Surefire report directory: /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.osgi.enroute.examples.quickstart.rest.UpperTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ rest ---
[INFO] Building jar: /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/rest-0.0.2-SNAPSHOT.jar
[INFO]
[INFO] --------------< org.osgi.enroute.examples.quickstart:app >--------------
[INFO] Building app 0.0.2-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ app ---
[INFO] Deleting /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/target/classes
[INFO]
[INFO] --- bnd-maven-plugin:5.1.2:bnd-process (default) @ app ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ app ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ app ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ app ---
[INFO] Building jar: /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/target/app-0.0.2-SNAPSHOT.jar
[INFO]
[INFO] --- bnd-indexer-maven-plugin:5.1.2:index (index) @ app ---
[INFO] The configured deployment repository OSGi Snapshots has the same id as one of the remote artifact repositories. It is assumed that these repositories are the same.
[INFO]
[INFO] --- bnd-indexer-maven-plugin:5.1.2:index (test-index) @ app ---
[INFO] The configured deployment repository OSGi Snapshots has the same id as one of the remote artifact repositories. It is assumed that these repositories are the same.
[INFO]
[INFO] --- bnd-export-maven-plugin:5.1.2:export (default) @ app ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for quickstart 0.0.2-SNAPSHOT:
[INFO]
[INFO] quickstart ......................................... SUCCESS [ 0.237 s]
[INFO] rest ............................................... SUCCESS [ 2.819 s]
[INFO] app ................................................ SUCCESS [ 2.680 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.996 s
[INFO] Finished at: 2022-02-11T16:04:52-07:00
[INFO] ------------------------------------------------------------------------
For Java 8, for java 17:
(base) angle@Sager:~/Documents/Programming/Java/osgi.enroute/examples/quickstart$ export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
(base) angle@Sager:~/Documents/Programming/Java/osgi.enroute/examples/quickstart$ mvn -version
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /opt/apache-maven-3.8.3
Java version: 17.0.1, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-99-generic", arch: "amd64", family: "unix"
(base) angle@Sager:~/Documents/Programming/Java/osgi.enroute/examples/quickstart$ mvn clean verify
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] quickstart [pom]
[INFO] rest [jar]
[INFO] app [jar]
[INFO]
[INFO] ----------< org.osgi.enroute.examples.quickstart:quickstart >-----------
[INFO] Building quickstart 0.0.2-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ quickstart ---
[INFO]
[INFO] -------------< org.osgi.enroute.examples.quickstart:rest >--------------
[INFO] Building rest 0.0.2-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rest ---
[INFO] Deleting /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/classes
[INFO]
[INFO] --- bnd-maven-plugin:5.1.2:bnd-process (default) @ rest ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rest ---
[INFO] Surefire report directory: /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.osgi.enroute.examples.quickstart.rest.UpperTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ rest ---
[INFO] Building jar: /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/rest/target/rest-0.0.2-SNAPSHOT.jar
[INFO]
[INFO] --------------< org.osgi.enroute.examples.quickstart:app >--------------
[INFO] Building app 0.0.2-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ app ---
[INFO] Deleting /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/target/classes
[INFO]
[INFO] --- bnd-maven-plugin:5.1.2:bnd-process (default) @ app ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ app ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ app ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ app ---
[INFO] Building jar: /home/angle/Documents/Programming/Java/osgi.enroute/examples/quickstart/app/target/app-0.0.2-SNAPSHOT.jar
[INFO]
[INFO] --- bnd-indexer-maven-plugin:5.1.2:index (index) @ app ---
[INFO] The configured deployment repository OSGi Snapshots has the same id as one of the remote artifact repositories. It is assumed that these repositories are the same.
[INFO]
[INFO] --- bnd-indexer-maven-plugin:5.1.2:index (test-index) @ app ---
[INFO] The configured deployment repository OSGi Snapshots has the same id as one of the remote artifact repositories. It is assumed that these repositories are the same.
[INFO]
[INFO] --- bnd-export-maven-plugin:5.1.2:export (default) @ app ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for quickstart 0.0.2-SNAPSHOT:
[INFO]
[INFO] quickstart ......................................... SUCCESS [ 0.087 s]
[INFO] rest ............................................... SUCCESS [ 2.569 s]
[INFO] app ................................................ SUCCESS [ 3.867 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.630 s
[INFO] Finished at: 2022-02-11T16:06:27-07:00
[INFO] ------------------------------------------------------------------------
I also tried setting the bnd run to reference java 1.8, recompiled, and reran it like that, and then I couldn't get the app or the rest endpoint working.
Oh, changing
ok, so further testing something is clearly broken somewhere. Even after I make it all work with proper resolutions and no errors, the resource aspect of Upper
(@HttpWhiteboardResource(pattern="/quickstart/*", prefix="static")
) never gets tracked by the Http Whiteboard (felix.http.jetty).
Somewhere along the line something broke and I need to investigate. Sadly right now I have to run. I'll try to dig in over the weekend. @Angular-Angel sorry about this.
a'right... so going back to the start and just add this to the Upper.java class
@org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardContextSelect("(osgi.http.whiteboard.context.name=org.osgi.service.http)")
and let me know if things start to work.
OK, so I've confirmed again after sleep and coffee that this was indeed the issue.
For some reason I do not fully comprehend somewhere along the line a difference in the Http Whiteboard (or perhaps the JAX-RS Whiteboard) makes that the resource part of Upper (@HttpWhiteboardResource(pattern="/quickstart/*", prefix="static")
) is bound the default
context which provides a ServletContext (backed by a ServletContextHelper) which has no bundle associated and therefore cannot local the static resources. By adding the suggested line above, we force Upper's resource to bind to another existing context which creates a per bundle ServletContext so that the static resource is found. I'm puzzled frankly as to how this may have previously worked.
So there were two issues for which I can send a fix:
Hey, nice! I'll take a look at these on monday, see if I can get the thing working.
Well, I cleaned and tried again with the latest version, and it behaves exactly the same. I'll wait for that pull request to go through and then try again.
I merged the PR which closed the issue but please if you continue to have issue after retest on HEAD we can reopen this to perform more investigations.
Yup, I can confirm, it works now!
Great news! thanks for the report.
So, I couldn't get the quickstart tutorial to run at all until I changed '-runee: JavaSE-1.8' to '-runee: JavaSE-17'. After I did that, and the 'mvn bnd-indexer:index bnd-indexer:index@test-index bnd-resolver:resolve' and 'mvn verify', I was able to run it, but when I try and connect to 'http://localhost:8080/quickstart/index.html' it shows 'HTTP ERROR 404 Problem accessing /quickstart/index.html. Reason: Not Found'. http://localhost:8080/rest/upper/lower however does seem to be running, and loads 'LOWER'. Does the project simply not work with Java 17 and I need to use java 11? Or is there a way to make it work? :/