opendaylight:karaf: how to overide dependency of the parent pom - apache-karaf

I am writing an ODL app where I want to use openstack4j. I am running into the following problem when I load the feature:
Error executing command: Unable to resolve root: missing requirement
[root] osgi.identity; osgi.identity=features-vlan; type=karaf.feature;
version="[0.1.0,0.1.0]"; filter:="(&(osgi.identity=features-vlan)
(type=karaf.feature)(version>=0.1.0)(version<=0.1.0))" [caused by:
Unable to resolve features-vlan/0.1.0: missing requirement [features-
vlan/0.1.0] osgi.identity; osgi.identity=odl-vlan; type=karaf.feature;
version="[0.1.0,0.1.0]" [caused by: Unable to resolve odl-vlan/0.1.0:
missing requirement [odl-vlan/0.1.0] osgi.identity;
osgi.identity=com.github.fge.jackson-coreutils; type=osgi.bundle;
version="[1.6.0,1.6.0]"; resolution:=mandatory [caused by: Unable to
resolve com.github.fge.jackson-coreutils/1.6.0: missing requirement
[com.github.fge.jackson-coreutils/1.6.0] osgi.wiring.package;
filter:="(&(osgi.wiring.package=com.google.common.base)
(version>=16.0.0)(!(version>=17.0.0)))"]]]
Apparently jackson-coreutils wants version 16.0.0 whereas the effective pom specifies version 22.
So I tried the following hack in my impl pom :
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Embed-Dependency>openstack4j;inline=true</Embed-Dependency>
<!-- same as in bundles4-test/pom.xml: -->
<Import-Package>*</Import-Package>
</instructions>
</configuration>
</plugin>
I was hoping that the dependency openstack4j would be added statically in the bundle but it did not work. How can I proceed?
Thanks.

So jackson-coreutil depends on a much older version of guava than odlparent (22). Maybe there's a newer version of jackson-coreutil? If not then I think you need to install the older 16.x guava version to satisfy jackson-coreutil. Hopefully versions 16.x and 22 can co-exist peacefully in the same karaf container. If you embed the openstack4j dependency, then try also embedding guava 16.x or set Embed-Transitive to true assuming openstack4j pulls it in transitively.

Related

NoClassDefFoundError for a class due to the interrelative dependencies in karaf

Consider the below scenario where i am getting an unexpected error and unable to fix it.
In Opendaylight architype project, I just used a class(Say test.class from io-example dependency) when I just declared only one dependency (i.e io-example) in the pom.xml, there is no error.
But if i add one more dependency (io-example-api) in the pom.xml, I am getting java.lang.NoClassDefFoundError: io/example/test.class
at org.opendaylight.gnmi.impl.base.OpenconfigInter
..................................................
..................................................
Caused by: java.lang.ClassNotFoundException: io.example.Test cannot be found by org.opendaylight
I found that io.example-api has the io-example as the dependency.. Summarize the issue, If i have the io-example alone in the pom.xml, there is no issue. If I have both io-example and io-example-api in the pom.xml, I am getting the NoclassDef error.
Even I have tried the exclusion option in the dependency section, Nothing works.
Thanks in advance...
Edited:
classname : io.grpc.Context
Dependencies :
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-context</artifactId>
<version>1.38.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>1.38.0</version>
</dependency>
In karaf container, I ran the "package:exports" commands and the results are,
opendaylight-user#root>package:exports -p io.grpc
io.grpc 0.0.0 354 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-api_1.38.0_grpc-api-1.38.0.jar
io.grpc 0.0.0 355 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-context_1.38.0_grpc-context-1.38.0.ja
opendaylight-user#root>package:exports -d
io.grpc 0.0.0 354 355
You can see that, io.grpc package exported by two bundles (354 and
355)..
A common cause for ClassNotFoundException in OSGi and Karaf is that multiple bundles export the same package with the same version. This causes only one of them be imported which may or may not contain your Test class.
Check which packages export io.example with package:exports command:
packages:exports -p io.example
I am guessing that adding the dependency causes your bundle to import the package io.example from io-example-api instead of io-example.
Solution for this would be to make sure only one bundle exports io.example package.
[Edit] I am unfamiliar with grpc but there seems to be issue on github about this and some workarounds that you could look in to.
You could also try creating a bundle that embeds these problematic dependencies and exports the packages for other bundles to use.
Create a new bundle project using archetype karaf-bundle-archetype
Add grpc-context and grpc-api dependencies
Configure maven-bundle-plugin to emped the grpc dependencies and export io.grpc package along with its sub packages.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>com.example.Activator</Bundle-Activator>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Export-Package>
io.grpc*;-split-package:=merge-first
</Export-Package>
<Emped-Dependency>
grpc-context;scope=compile|runtime;inline=true,
grpc-api;scope=compile|runtime;inline=true
</Emped-Dependency>
</instructions>
</configuration>
</plugin>
Managed to install the bundle successfully to Karaf 4.2.11 and "use" the exported io.grpc.Context class in the bundle and in another bundle.
Simply called this from the Activator of two bundles
Context grpcContext = Context.current();
System.out.println(grpcContext.getClass().getName());

Karaf wants optional imports?

I'm trying to use org.eclipse.persistence.moxy 2.7.4 in Karaf.
Karaf 4.2.6 is saying:
Error executing command: Error executing command on bundles:
Error starting bundle 71: Unable to resolve HelloWorld [71](R 71.0): missing requirement [HelloWorld [71](R 71.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.codemodel) Unresolved requirements: [[HelloWorld [71](R 71.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.codemodel)]
I think this is because moxy's META-INF includes:
Manifest-Version: 1.0
Bundle-SymbolicName: org.eclipse.persistence.moxy
Require-Bundle: org.eclipse.persistence.core;bundle-version="2.7.4";visibility:=reexport,org.eclipse.persistence.asm;bundle-version="7.0.0" ;resolution:=optional
Bundle-ManifestVersion: 2
Bundle-Vendor: Eclipse.org - EclipseLink Project
Import-Package: com.sun.xml.bind;resolution:=optional,com.sun.xml.bind.annotation;resolution:=optional,com.sun.xml.bind.api;resolution:=optional,com.sun.xml.bind.api.impl;resolution:=optional,com.sun.codemodel;resolution:=optional;version="[2.2.11,3)"
Bundle-Name: EclipseLink MOXy
Bundle-Version: 2.7.4.v20190115-ad5b7c6b2a
Note com.sun.codemodel;resolution:=optional;version="[2.2.11,3)
But it says "resolution:=optional". So why is this an unresolved requirement, and how can I make karaf treat it as optional?
Note that here, it's not moxy that complains about not finding that package, but your own service. Check your Import-Package in your META-INF/MANIFEST.MF, it's possible that if you use maven-bundle-plugin, the dependency is scanned thanks to your pom.xml and then inferred in your Import-Package clause.

Flutter - Error after include cloud firestore dependency.[Resolved]

I'd like a help to resolve this Issue. I cannot build my flutter application after insert the cloud firestore dependency at the pubspec.yaml
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.4.3+2
cloud_firestore: ^0.13.0+1
Error description:
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
Could not resolve io.grpc:grpc-core:[1.21.0].
Required by:
project :app > io.grpc:grpc-okhttp:1.21.0
Failed to list versions for io.grpc:grpc-core.
Unable to load Maven meta-data from https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml.
Could not HEAD 'https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml'.
Connection reset
Failed to list versions for io.grpc:grpc-core.
Unable to load Maven meta-data from https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml.
Could not HEAD 'https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml'.
Connection reset
Failed to list versions for io.grpc:grpc-core.
Unable to load Maven meta-data from https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml.
Could not HEAD 'https://jcenter.bintray.com/io/grpc/grpc-core/maven-metadata.xml'.
Connection reset
This seems to be an internet connection problem, so please check your network.
This is more looking as if some connection issues are present,but if not then
First of all checkout your .gradle version it should be greater than 5
If you have created your project recently or under one month then you may need to check this step.
Then go to android/build.gradle and check your dependencies It should look like
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
If you donot use kotlin support then no need to write that classpath.Its for those who has kotlin support enabled by default.
In android/gradle.properties
you should have
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
in app level build.gradle
defaultConfig {
minSdkVersion 23
}
and most importantly you should have downloaded your google-services.json file in your android project folder. For Firebase you also require sha1 or sometimes sha256 keys.
Now it should run properly.
May it helped you :)
`

How to have access to ServletRequestAware on struts2-core 2.3.16.1?

I changed my struts2 version from 2.3.14 to 2.3.16.1, it seems that newest version does not support ServletRequestAware and ServletResponseAware anymore, what should I do? I could not find anything online.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.16.1</version>
<type>jar</type>
</dependency>
Code
import org.apache.struts2.interceptor.ServletRequestAware;
public class MyExample implements ServletRequestAware, ServletResponseAware {
Error
package org.apache.struts2.interceptor does not exist.
When I try to find a dependency for it Maven shows the latest version of Struts2 which is supporting it is 2.3.14!
You probably have some problem with the libraries included in your project;
Be sure to erase all the old JARs from the classpath (your WAR / EAR and shared libs on the AS;
run Clean Project in your IDE;
download Struts2.3.16.1 from Maven or manually from here;
check out the ServletRequestAware and ServletResponseAware Interfaces at
/struts-2.3.16.1/src/core/src/main/java/org/apache/struts2/interceptor/
, exactly where they were before ;)
E.g., output from 2.3.16.3 distribution:
$ jar tvf struts2-core-2.3.16.3.jar | grep ServletRequest
223 Fri May 02 17:23:44 EDT 2014 org/apache/struts2/interceptor/ServletRequestAware.class
It's also in the 2.3.16.1 jars.
At the Step 3 of Welcome to Struts2 add the following dependency to your pom.xml
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>X.X.X.X</version>
</dependency>
Check the file version X.X.X.X is available in the repository and downloaded to your hard drive.

java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException in JBoss AS 7

I am testing JBoss AS 7 prior to deployment with a .war file of an app running in a different server.
I get this error when I try to log onto the database via the app:
SEVERE [] (http--0.0.0.0-8080-4) java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException from [Module "deployment.app.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
In some forums, they suggest adding the commons-codec jar, but I already have it in JBoss, right? (in here: jboss-as-7.1.1.Final/modules/org/apache/commons/codec/main/commons-codec-1.4.jar)
OSGi is not activated, frankly I have no idea to what purpose it serves, but when I try to activate it it messes with my war as it fails to deploy...
I have JDK, but no JRE if that's any help.
JBoss AS 7 does not use OSGi by default for modular class loading. It uses JBoss Modules so this has nothing to do with OSGi.
What you need to do if you want to use the commons-codec provided with JBoss AS 7 is add a dependency to your deployment.
Modules are not visible by your artefact classes automatically. You have three possibilities:
Define a global module in your standalone.xml
http://javahowto.blogspot.de/2012/09/how-to-create-global-modules-in-jboss.html
This module will be used by all artefacts you are deploying on Jboss.
Put it into your war artefact, into the lib folder. You can do that with Maven.
Define an explicit dependency within your Manifest. https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7
Section Dependencies: Manifest Entries

Resources