Trying to understanding OSGi resolution errors - maven

I'm fairly new to OSGi and I've run into what has to be a very simple, beginner's error.
When I added a BundleActivator to my Bundle, I get the following resolution error:
[INFO] Building jar: C:\projects\osgi.enroute-master\projects\testproject\app\target\app-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- bnd-indexer-maven-plugin:4.0.0:index (index) # app ---
[INFO]
[INFO] --- bnd-indexer-maven-plugin:4.0.0:index (test-index) # app ---
[INFO]
[INFO] --- bnd-export-maven-plugin:4.0.0:export (default) # app ---
[ERROR] Resolution failed. Capabilities satisfying the following requirements could not be found:
[<<INITIAL>>]
? osgi.identity: (osgi.identity=org.foo.examples.service.impl)
? [org.foo.examples.service.impl version=0.0.1.201806070724]
? osgi.wiring.package: (&(osgi.wiring.package=org.osgi.framework)(&(version>=1.9.0)(!(version>=2.0.0))))
? [org.osgi.framework version=1.9.0.201802012106]
? osgi.wiring.package: (&(osgi.wiring.package=org.osgi.dto)(&(version>=1.1.0)(!(version>=2.0.0))))
The following requirements are optional:
[org.apache.felix.scr version=2.1.0]
? osgi.wiring.package: (&(osgi.wiring.package=org.osgi.service.cm)(&(version>=1.6.0)(!(version>=2.0.0))))
? osgi.wiring.package: (&(osgi.wiring.package=org.apache.felix.service.command)(&(version>=1.0.0)(!(version>=2.0.0))))
? osgi.wiring.package: (&(osgi.wiring.package=org.apache.felix.shell)(&(version>=1.0.0)(!(version>=1.1.0))))
? osgi.wiring.package: (&(osgi.wiring.package=org.osgi.service.log)(&(version>=1.3.0)(!(version>=2.0.0))))
? osgi.wiring.package: (&(osgi.wiring.package=org.osgi.service.metatype)(&(version>=1.2.0)(!(version>=2.0.0))))
I'm using the OSGi enRoute example on GitHub, which uses maven plugins and custom archetypes to setup the project and different kinds of bundles. It also uses the Bndtools which - as far as I understand - is supposed to automatically resolve exactly these kinds of bundle dependencies. I cannot rule out that underneath the OSGi dependency issue is a Maven dependency as well.
Is there any documentation on how to parse and understand this types of errors?
I know this question is vague, I currently lack the understanding to even precisely formulate the problem :)

For resolution errors you first look into the innermost resolution that fails. In your case it is:
osgi.wiring.package: (&(osgi.wiring.package=org.osgi.dto)(&(version>=1.1.0)(!(version>=2.0.0))))
This can be translated you are missing a bundle that provides an export of the package "org.osgi.dto" with a version of [1.1.0,2.0.0). This package is provided by
https://mvnrepository.com/artifact/org.osgi/org.osgi.dto
So you could try to install this bundle.

Related

How to get CodenameOne Maven Project Running in Netbeans

Thx to Steve for the CN1 ant to maven migration tool and video here. - Has anyone been able to run the Kitchen Sink project in Netbeans after migration? I follow the video instructions with the migration tool and migrate successfully and it runs from command line with ./run.sh but when I go to run it in NetBeans, I had a lot of 501 (https needed) errors. Added umer's code from here and that solved the 501 errors but now get:
Invalid POM for com.codenameone:codenameone-javase:jar:7.0.23, and
No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
while locating org.apache.maven.plugin.surefire.SurefirePlugin.
Note invalid POM warning...
------------------------------------------------------------------------
Building kitchensink-common 1.0-SNAPSHOT
------------------------------------------------------------------------
--- properties-maven-plugin:1.0.0:read-project-properties (default) # kitchensink-common ---
--- codenameone-maven-plugin:7.0.23:generate-gui-sources (generate-gui-sources) # kitchensink-common ---
The POM for com.codenameone:codenameone-javase:jar:7.0.23 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Generating GUI sources
No GUI Entries available
Running from command line, invalid POM warning disappears:
[INFO] -----------< com.codename1.demos.kitchen:kitchensink-common >-----------
[INFO] Building kitchensink-common 1.0-SNAPSHOT [4/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- properties-maven-plugin:1.0.0:read-project-properties (default) # kitchensink-common ---
[INFO]
[INFO] --- codenameone-maven-plugin:7.0.23:generate-gui-sources (generate-gui-sources) # kitchensink-common ---
Generating GUI sources
No GUI Entries available
Running on apache-maven-3.8.1 on MacOSX
Java version: 1.8.0_172
Suggestions welcomed.
Thx, Mike
I think perhaps the method I'm using to detect the latest version of cn1 has issues. It picked 7.0.23 which was released this morning. But then it was unable to find some of the jars.
Probably it will work if you just try running the project again as it should be fully propagated to maven central now.
Problem was solved updating from Netbeans 8.2 to latest Netbeans version (currently 12.3).

Maven install beanstalk error

I am starting out with Maven, following a book. I'm using 3.2.1 on Ubuntu. I have run the following commands:
mvn archetype:generate -DgroupId=org.sonatype.mavenbook.ch03 -DartifactId=simple -DpackageName=org.sonatype.mavenbook
mvn install
I then get a beanstalk error. Essentially, I don't have Amazon credentials. I understand the concepts surrounding Maven. What if I don't want to use Amazon services? Is this really necessary?
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.sonatype.mavenbook.ch03:simple:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 143, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- beanstalk-maven-plugin:0.2.8:expose-security-credentials (expose-security-credentials) # simple ---
[WARNING] FAILURE
java.lang.IllegalArgumentException: Settings for serverId ('aws.amazon.com') not found. See http://beanstalker.ingenieux.com.br/beanstalk-maven-plugin/security.html for more information
You probably used the elasticbeanstalk archetypes. A short reason (as it seems you're just learning Maven) is to edit your pom and remove the <plugin/> sections for br.com.ingenieux groupId.
Hope it helps
For those who care about the little details on why did it fail
Since release 1.3.x (a few weeks ago), we dropped the usage of aws.accessKey and aws.secretKey. The warnings were there for more than two years in fact :)
Reason: Many projects on github were leaking AWS Keys
Instead, set those as environment variables (AWS_ACCESS_KEY_ID) and (AWS_SECRET_ACCESS_KEY) or use encryption - see this doc for an overview

Maven release:prepare-with-pom non-interactive

I'm trying to release a project with Maven.
My project POM is containing -SNAPSHOT dependencies, so in order to perform the release automatically, I want to use the following maven command, based on the "maven-release-plugin" goals: mvn release:prepare-with-pom in order to prepare the project's pom.xml for releasing and resolve dependencies -SNAPSHOT versions automatically without edit them by hand.
Unfortunately I found this is working only in interactive mode from command line. The idea is that I'm wondering if this can be done without any manual interaction. I am using Bamboo as CI Server and I want to have this into a plan and perform this project releasing automatically. The --non-interactive or -B argument isn't working, actually if I'm using -B or --non-interactive argument the maven goal is failing.
This is the output for mvn release:prepare-with-pom:
H:\APPS\dev\cmtest\test-dependency\trunk>mvn release:prepare-with-pom -DdryRun=t
rue
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building test-dependency 0.0.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.0:prepare-with-pom (default-cli) # test-depend
ency ---
[INFO] Resuming release from phase 'check-dependency-snapshots'
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.: Do you want to resolve th
em now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Depe
ndencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Resolve Project Dependency Snapshots.: '${artifactGroup}:${artifactId}' set to releas
e? (yes/no) yes: : yes
What is the next development version? (0.1.3-SNAPSHOT) 0.1.3-SNAPSHOT: :
'${artifactGroup}:${artifactId1}_1' set to release? (yes/no) yes: : yes
What is the next development version? (0.0.2-SNAPSHOT) 0.0.2-SNAPSHOT: :
'${artifactGroup}:parent-pom' set to release? (yes/no) yes: : yes
What is the next development version? (0.0.3-SNAPSHOT) 0.0.3-SNAPSHOT: :
What is the release version for "test-dependency"? (${artifactGroup}:${artifactId1}_2) 0.0.4: :
What is SCM release tag or label for "test-dependency"? (${artifactGroup}:${artifactId1}_2) test-dependency-0.0.4: :
What is the new development version for "test-dependency"? (${artifactGroup}:${artifactId1}_2) 0.0.5-SNAPSHOT: :
[INFO] Transforming '${artifactId1}_2'...
[INFO] Updating ${artifactId1}_1 to 0.0.1
[INFO] Updating ${artifactId1} to 0.1.2
[INFO] Generating release POMs...
[INFO] Generating release POM for 'test-dependency'...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
So, can you help me please to find a trick in order to perform this maven command in non-interactive mode?
Thanks a lot
While your pom refers to snapshot releases I don't believe non-interactive is possible (maybe a fancy 'expect' script but that might be a bit much).
Releasing a library that relies on snapshots is very dangerous because the libraries can change from under your feet. Anyone using your library is going to assume that every time they use it they're getting the same jars, with the same SHAs, but in reality that's not the case. That's why maven makes it nearly impossible do to this.
I'd recommend concentrating on moving your dependencies to released versions, or if that's not an option, keeping your library as a snapshot. Keeping your library as a snapshot means that your clients are at least aware that the libraries they're using can change without their knowledge.

Jenkins (hudson) plugin development meet maven-enforcer-plugin:1.1-SNAPSHOT issue

I try to develop one jenkins (a.k.a hudson) plugin, and follow the Tutorial, and generated source code tree after mvn -cpu hpi:create command.
While when I do "mvn package", it reports error like
[INFO] Building Unnamed - com.example.jenkins:redmine2:hpi:1.0-SNAPSHOT
[INFO] task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.apache.maven.plugins:maven-enforcer-plugin
Reason: Error getting POM for 'org.apache.maven.plugins:maven-enforcer-plugin' from the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.
org.apache.maven.plugins:maven-enforcer-plugin:pom:1.1-SNAPSHOT
from the specified remote repositories:
nexus (http://maven.nexus.local:8888/nexus/content/groups/public)
for project org.apache.maven.plugins:maven-enforcer-plugin
From my nexus server, it has maven-enforcer-plugin:1.0 version only, but this dependence is generated from jenkins by default, anyone can help me to solve it ?
(How) Can I change to plugin-1.0 version.
what can I add in nexus server
I just have basic knowledge of maven.
I fixed it by myself by doing two things.
1. Added Apache snapshot from here into my nexus repo group besides those setting in Tutorial
2. It seems my local maven repo is messed up as well, so I can clean it up and reload from nexus.
And it still use maven-enforcer-plugin:pom:1.1-SNAPSHOT plugins.
Hope it helps you as well.

Maven site error with version range

I have a Maven project that declares a dependency on another Maven artifact using an open ended version range, such as this:
<dependency>
<groupId>org.terracotta.toolkit</groupId>
<artifactId>terracotta-toolkit-1.0</artifactId>
<version>[1.0.0-SNAPSHOT,]</version>
</dependency>
(I know that it is to some degree asking for trouble using such version ranges, but for this particular project we have very good reason for doing so.)
For the most part this works fine, but when trying to generate the project web site with "mvn site", I get the following error when it tries to create the Dependency Management Report:
[INFO] Generating "Dependency Management" report. Downloading: http:/XXXXXXXXXX/content/groups/public/org/terracotta/toolkit/terracotta-toolkit-1.0/[1.0.0-SNAPSHOT,]/terracotta-toolkit-1.0-[1.0.0-SNAPSHOT,].pom
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Invalid uri 'http://XXXXXXXXXX/content/groups/public/org/terracotta/toolkit/terracotta-toolkit-1.0/[1.0.0-SNAPSHOT,]/terracotta-toolkit-1.0-[1.0.0-SNAPSHOT,].pom': escaped absolute path not valid
[INFO] ------------------------------------------------------------------------
[INFO] Trace java.lang.IllegalArgumentException: Invalid uri 'http://XXXXXXXXXX/content/groups/public/org/terracotta/toolkit/terracotta-toolkit-1.0/[1.0.0-SNAPSHOT,]/terracotta-toolkit-1.0-[1.0.0-SNAPSHOT,].pom': escaped absolute path not valid
As you can see from the message, it tries to construct a URI with the open ended version range specification instead of the resolved version number, which of course fails.
Can anyone tell me if there is a workaround?
Does it work properly if you fix the version of the terracotta artifact to 1.0.0?
Also, which version of Maven are you using? As per this link:
https://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html
if you are using Maven 3.x, you will have issues with mvn site.
This turned out to be a bug in Maven 2.2.0 that was fixed in Maven 2.2.1. I was mistaken that I was using Maven 2.2.1 already.

Resources