You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by "Dr. Hans-Peter Störr" <sp...@planet.ms> on 2021/04/14 10:33:19 UTC

Kickstart: starting from feature archive without network / maven repo not possible

Hi!

I'm trying to run our Sling-application from a JAR that embeds a feature archive without it needing any network access / an existing maven repository. So my first try is to use the https://github.com/apache/sling-org-apache-sling-kickstart project for this, which already includes a feature archive with a version of Sling Starter 12. So I was expecting that

java -jar org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar start

could start without taking anything from maven or the net since there is a sling feature archive included. But actually it takes a lot from there, if not everything. If I start it with debugging (-v) it logs "Found artifact file" for 399 files saying it takes them from my maven repository. If I try to run it in docker while blocking network access (e.g. with

docker run -ti --rm --network none  -v `pwd`/target:/app -w /app openjdk:12-jdk /bin/bash

and executing the java start command there) it fails with the following errors, though the URL for the FAR seems correct - at least I can open it from a jshell. Am I doing something wrong here? If that matters: I'm running it from MacOS, in the Docker image with OpenJDK 12. 

I also tried to switch the kickstarter to the newest org.apache.sling.feature.launcher.version , but that didn't help. When I try to use the original Sling feature launcher with the FAR created by kickstarter, that works to some extend:

java -jar org.apache.sling.feature.launcher-1.1.19-SNAPSHOT.jar -f org.apache.sling.kickstart-0.0.13-SNAPSHOT-oak_tar_far.far -u 'jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT-oak_tar_far.far!'

This retrieves many artefacts from the FAR but fails when it tries to retrieve org.apache.felix.framework-7.0.0.jar . But it seems kickstarter doesn't give that option to the sling starter it calls, and there also doesn't seem to be an option to kickstarter to set the repositories it tries to retrieve artefacts from. (The problem with the felix framework version is possibly one it inherits from Sling Starter itself - when I grab a org.apache.sling.starter-12-SNAPSHOT-oak_tar_far.far from there, the same thing happens.)

Thank you very much!

Best regards,

Hans-Peter Störr


Attachment- the output from within docker is:

Before Launching Feature Launcher, arguments: [-f, jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.far, -v]
 Starting Apache Sling in null-----------
 Start Command: 'start'
 Apache Sling Control Listener started//root/.m2/repository, https://repo.maven.apache.org/maven2, https://repository.apache.org/content/groups/snapshots]
 [INFO] Assembling final feature model...
 [INFO] Apache Sling Application Launcher:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.far
 [INFO] ---------------------------------ile:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.far
 [INFO] Initializing...o be local file jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.far
 [INFO] Artifact Repositories: [file:///root/.m2/repository, https://repo.maven.apache.org/maven2, https://repository.apache.org/content/groups/snapshots]
 [INFO] Assembling final feature model...rg.apache.sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/slingosgifeature/oak_tar
 [DEBUG] Reading feature archive jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.farSHOT-oak_tar.slingosgifeature
 [DEBUG] Trying to get artifact for jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.far0.13-SNAPSHOT/org.apache.sling.kicks [DEBUG] Checking url to be local file jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.far
 [DEBUG] Checking remote url jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT.jar!/default/org.apache.sling.kickstart.farg.apache.sling.kickstart-0.0.13-SNAPSHOT-oa [DEBUG] Trying to get artifact for mvn:org.apache.sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/slingosgifeature/oak_tar
 [DEBUG] Querying repositories for org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/org.apache.sling.kickstart-0.0.13-SNAPSHOT-oak_tar.slingosgifeature
 [DEBUG] Checking DefaultArtifactHandler to get artifact from file:///root/.m2/repository/org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/org.apache.sling.kicks [DEBUG] Checking url to be local file file:///root/.m2/repository/org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/org.apache.sling.kickstart-0.0.13-SNAPSHOT-oa [DEBUG] Trying to get artifact for file:///root/.m2/repository/org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/maven-metadata.xml
 [DEBUG] Checking url to be local file file:///root/.m2/repository/org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/maven-metadata.xmle.sling.kickstart-0.0.13-SN [DEBUG] Checking DefaultArtifactHandler to get artifact from https://repo.maven.apache.org/maven2/org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/org.apache.sl [DEBUG] Checking url to be local file https://repo.maven.apache.org/maven2/org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/org.apache.sling.kickstart-0.0.13-SN [DEBUG] Checking remote url https://repo.maven.apache.org/maven2/org/apache/sling/org.apache.sling.kickstart/0.0.13-SNAPSHOT/org.apache.sling.kickstart-0.0.13-SNAPSHOT-oak [INFO] Artifact not found in one repository
 java.net.UnknownHostException: repo.maven.apache.org
         at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:220)
         at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
...

Re: Aw: Re: Kickstart: starting from feature archive without network / maven repo not possible

Posted by Robert Munteanu <ro...@apache.org>.
On Tue, 2021-04-20 at 14:50 +0200, Dr. Hans-Peter Störr wrote:
> Hi Robert and Ruben!
> 
> Thank you for the prompt answers!
> 
> Maybe it's not 100% clear what I'm trying to do. I'd like to create a
> very low bar of entry for our Composum application: there should be a
> single starter JAR that contains the whole of Sling and a basic
> version of our application, that can be run on any machine with a JDK
> - and should not even require an internet connection to download more
> artefacts, and of course should not require a maven installation as
> it is not only meant for developers. Basically similar to what a
> Sling Starter version <= 11 would do with added provisioning for our
> own application.
> 
> Currently I didn't find it easy to use the sling feature launcher or
> kickstart that way for two reasons.
> 
> 1. Even when I supply a feature archive, it seems that the feature
> launcher accesses the network (that is, the central maven
> repo.maven.apache.org!) for each of the hundreds of artifacts, even
> if they are contained in the feature archive. If I start this
>    java -jar org.apache.sling.feature.launcher.jar -f
> org.apache.sling.starter-12-SNAPSHOT-oak_tar_far.far -v
>    without network access, lots of java.net.UnknownHostException,
> though these seem to be ignored. Isn't that a bug of the feature
> launcher?

I am not a feature model expert, but I think it is a bug. If the
artifacts are present there should be no network access.

> 
> 2. The framework (felix-framework-6.0.3 or felix-framework-7.0.0 and
> dependencies) is not present in the FAR (and it probably shouldn't be
> there, right?), so the feature launcher tries to retrieve that from
> $HOME/.m2/repository or, failing that, from the central repository.
> (That applies to both to the separate call fo the feature launcher,
> and to the call of the feature launcher within kickstart-0.0.12.) If
> the framework cannot be retrieved, it aborts.

What I usually do it to copy over the framework jar in the right
location under the repository cache ( -c argument to the feature
launcher ) and that works. Have you tried that?

> 
> BTW:
> Since there is the content-packages extension for features, I'm
> trying to add our application to the FAR with a feature like
> {
> "content-packages:ARTIFACTS|required": [
> "com.composum.platform:composum-platform-
> package:zip:${composum.platform.version}",
> "com.composum.pages:composum-pages-
> package:zip:${composum.pages.version}", ...]
> }
> That leads to problems, though, since the packages aren't installed
> in the proper order and the included bundles are given a start level
> 1 instead of the usual 20. Is there something I can do to set the
> start level and to control the ordering of the packages? I tried
> converting them with the sling-feature-converter-maven-plugin, too,
> but didn't succeed so far and am hoping for a simpler solution. :-)


... that is too much out of my area of expertise, sorry :-)

Thanks,
Robert


Aw: Re: Kickstart: starting from feature archive without network / maven repo not possible

Posted by "Dr. Hans-Peter Störr" <ha...@email.de>.
Hi Robert and Ruben!

Thank you for the prompt answers!

Maybe it's not 100% clear what I'm trying to do. I'd like to create a very low bar of entry for our Composum application: there should be a single starter JAR that contains the whole of Sling and a basic version of our application, that can be run on any machine with a JDK - and should not even require an internet connection to download more artefacts, and of course should not require a maven installation as it is not only meant for developers. Basically similar to what a Sling Starter version <= 11 would do with added provisioning for our own application.

Currently I didn't find it easy to use the sling feature launcher or kickstart that way for two reasons.

1. Even when I supply a feature archive, it seems that the feature launcher accesses the network (that is, the central maven repo.maven.apache.org!) for each of the hundreds of artifacts, even if they are contained in the feature archive. If I start this
   java -jar org.apache.sling.feature.launcher.jar -f org.apache.sling.starter-12-SNAPSHOT-oak_tar_far.far -v
   without network access, lots of java.net.UnknownHostException, though these seem to be ignored. Isn't that a bug of the feature launcher?

2. The framework (felix-framework-6.0.3 or felix-framework-7.0.0 and dependencies) is not present in the FAR (and it probably shouldn't be there, right?), so the feature launcher tries to retrieve that from $HOME/.m2/repository or, failing that, from the central repository. (That applies to both to the separate call fo the feature launcher, and to the call of the feature launcher within kickstart-0.0.12.) If the framework cannot be retrieved, it aborts.

As a workaround, I embedded the felix-framework with the assembly plugin in repository style in the starter JAR
called the feature launcher from a main class in our application with the arguments
-f jar:file:.../composum-launcher-feature-composumstarter-1.2.1-SNAPSHOT-oak_tar-starter.jar!/far/embedded.far
-u jar:file:.../composum-launcher-feature-composumstarter-1.2.1-SNAPSHOT-oak_tar-starter.jar!/repository/
You could do something like that into the kickstarter.jar, too - at least as an additional repository URL that would make it independent of the network. (That wouldn't, solve problem 1, though).


BTW:
Since there is the content-packages extension for features, I'm trying to add our application to the FAR with a feature like
{
"content-packages:ARTIFACTS|required": [
"com.composum.platform:composum-platform-package:zip:${composum.platform.version}",
"com.composum.pages:composum-pages-package:zip:${composum.pages.version}", ...]
}
That leads to problems, though, since the packages aren't installed in the proper order and the included bundles are given a start level 1 instead of the usual 20. Is there something I can do to set the start level and to control the ordering of the packages? I tried converting them with the sling-feature-converter-maven-plugin, too, but didn't succeed so far and am hoping for a simpler solution. :-)


On 4/14/2021, Robert Munteanu wrote:
> Have you tried copying over the felix framework jar to
> $HOME/.m2/repository in the container image, or wherever the feature
> launcher looks for it?

That'd work for our docker images, but not for a single starter JAR containing everything. I gave the docker command line mostly as an easy way to verify what happens when you don't have a maven repository and have no internet connection.

> I do however not understand why the feature launcher would copy files
> from the far file into the local .m2 repository

That was a misunderstanding - it doesn't copy anything there, it just tries to get the artifacts from there and the central repository.


Thank you very much,

Hans-Peter


Re: Kickstart: starting from feature archive without network / maven repo not possible

Posted by Ruben Reusser <rr...@headwire.com>.
hi

On 4/14/2021 3:33 AM, Dr. Hans-Peter Störr wrote:
> Hi!
>
> I'm trying to run our Sling-application from a JAR that embeds a feature archive without it needing any network access / an existing maven repository. So my first try is to use the https://github.com/apache/sling-org-apache-sling-kickstart project for this, which already includes a feature archive with a version of Sling Starter 12. So I was expecting that

it seems to be easier to test such issues with the feature launcher and 
the sling-starter [1] as the kickstarter uses the feature launcher and 
the starter project creates a set of far files. I also noticed it looks 
like there will be a docker image for the feature launcher soon [2].

I do however not understand why the feature launcher would copy files 
from the far file into the local .m2 repository (why not mount the far 
file as a repository) as this makes the docker images unnecessary bigger 
if you need a sling instance in the docker image that has been started 
once.

Ruben

[1] https://github.com/apache/sling-org-apache-sling-starter
[2] 
https://github.com/apache/sling-org-apache-sling-feature-launcher/tree/master/src/main/docker


Re: Kickstart: starting from feature archive without network / maven repo not possible

Posted by Robert Munteanu <ro...@apache.org>.
Hi,

On Wed, 2021-04-14 at 12:33 +0200, Dr. Hans-Peter Störr wrote:
> I also tried to switch the kickstarter to the newest
> org.apache.sling.feature.launcher.version , but that didn't help.
> When I try to use the original Sling feature launcher with the FAR
> created by kickstarter, that works to some extend:
> 
> java -jar org.apache.sling.feature.launcher-1.1.19-SNAPSHOT.jar -f
> org.apache.sling.kickstart-0.0.13-SNAPSHOT-oak_tar_far.far -u
> 'jar:file:/app/org.apache.sling.kickstart-0.0.13-SNAPSHOT-
> oak_tar_far.far!'
> 
> This retrieves many artefacts from the FAR but fails when it tries to
> retrieve org.apache.felix.framework-7.0.0.jar . But it seems
> kickstarter doesn't give that option to the sling starter it calls,
> and there also doesn't seem to be an option to kickstarter to set the
> repositories it tries to retrieve artefacts from. (The problem with
> the felix framework version is possibly one it inherits from Sling
> Starter itself - when I grab a org.apache.sling.starter-12-SNAPSHOT-
> oak_tar_far.far from there, the same thing happens.)

Have you tried copying over the felix framework jar to
$HOME/.m2/repository in the container image, or wherever the feature
launcher looks for it?

Thanks,
Robert