I want to build a client (just a client) with Axis2. I use Maven and OSGi (Felix). I manage to successfully install it using Maven, however when I run it using PAX provision, there come a bunch of error. This is my initial configuration in the POM (plus some more dependencies of AXIOM and WSDL4j).
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
This builds fine, but when I do pax:provision I get
ERROR: Bundle axis2-transport-local [33] Error starting file:bundles/axis2-transport-local_1.6.2.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle axis2-transport-local [33]: Unable to resolve 33.0: missing requirement [33.0] osgi.wiring.package; (osgi.wiring.package=org.apache.axis2))org.osgi.framework.BundleException: Unresolved constraint in bundle axis2-transport-local [33]: Unable to resolve 33.0: missing requirement [33.0] osgi.wiring.package; (osgi.wiring.package=org.apache.axis2)
Has anyone experienced something good with Axis2, OSGi, and Maven? ;-)
Is this axis2 jar already a osgi bundle? If not you need to create one, or find one already transformed. How about CXF? It's known to be working great with OSGi.
Since your using Pax provisioning you might alos try to use the wrap command for wrapping the axis jar as a osgi bundle.
Related
I am trying to use akamai edgegrid API for invalidating akamai chache. I have added below dependency in my pom.xml, but my bundle keeps in installed state. Below are more details-
pom.xml dependency-
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-apache-http-client</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
Bundle is in installed state, on felix console it says-
Imported Packages com.akamai.edgegrid.signer -- Cannot be resolved
error.log says -
Unable to resolve 497.82: missing requirement [497.82] osgi.wiring.package; (osgi.wiring.package=com.akamai.edgegrid.signer)
You have used <scope>provided</scope> , it means this jar will be used during compile time and during run time it will use the jar available on the run time environment. Unfortunately edgegrid-signer-apache-http-client-2.1.0.jar is not available on the AEM instance.
To resolve the issue, Do not use <scope>provided</scope> .
Updated POM -
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-apache-http-client</artifactId>
<version>2.1.0</version>
</dependency>
Before deploying the bundle on AEM, extract the jar and check edgegrid-signer-apache-http-client.jar , edgegrid-signer-core.jar, httpclient.jar, httpcore.jar should be part of the bundle.
Hopefully it will solve your issue. All the best.
Please let me know if you still face any issue.
-Mrutyunjaya
I've implemented some code using javax.validation and Hibernate Validator. The unit tests using validation are working fine. The build produces OSGi bundles and features, and runs in Karaf.
When I run my PaxExam integration test, I get "Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath." As far as I can tell, I AM adding it to my classpath. I have a features.xml file that I've been incrementally adding dependencies to. It finally got past Karaf bundle resolution, but now it's failing with an exception with this message:
"Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath."
I would include the stacktrace, but it doesn't look useful to me. Most of it is in my code, junit, and paxexam.
I'm attempting to use version 5.4.1.Final of HV. Note again that the unit tests doing validation are working fine. It took a while to get the dependencies correct to get that far (like using version "3.0.1-b08" of "javax.el".
I've seen some mentions of a "hibernate-validator-osgi-karaf-features" artifact, but I'm not sure if that's relevant. I'm attempting to use both the hibernate-validator artifact and the hibernate-validator-annotation-processor artifact.
I don't know that it's going to matter, but here's an excerpt of my POM dependencies:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>
hibernate-validator-annotation-processor
</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b08</version>
</dependency>
The following is an excerpt of a "features.xml" file from a bundle that is a dependency (by feature) of the bundle containing the test class:
<bundle start-level="100">wrap:mvn:javax.validation/validation-api/1.1.0.Final$Bundle-Name=javax.validation&Bundle-SymbolicName=javax.validation&Bundle-Version=1.1.0.Final</bundle>
<bundle>mvn:org.hibernate/hibernate-validator/5.4.1.Final</bundle>
<bundle start-level="100">wrap:mvn:org.hibernate/hibernate-validator-annotation-processor/5.4.1.Final$Bundle-Name=hibernate-validator-annotation-processor&Bundle-SymbolicName=hibernate-validator-annotation-processor&Bundle-Version=5.4.1.Final</bundle>
What else can I do at this point?
Update:
I've made some changes according to the answer that refers to the "hibernate-validator-osgi-karaf-features" artifact, but I'm now getting a different unexpected error.
In the pom dependencies I added the following:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>
hibernate-validator-osgi-karaf-features
</artifactId>
<version>5.4.1.Final</version>
<type>pom</type>
</dependency>
In the base features.xml file that is referred to by the features.xml file in my module, I removed the annotation-processor, and added this:
<bundle>wrap:mvn:org.hibernate/hibernate-validator-osgi-karaf-features/5.4.1.Final$Bundle-Name=hibernate-validator-osgi-karaf-features&Bundle-SymbolicName=hibernate-validator-osgi-karaf-features&Bundle-Version=5.4.1.Final</bundle>
I tried not having the "wrap:" and everything after the "$", but the result was the same.
When I ran my test, I saw this:
Caused by: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.hibernate:hibernate-validator-osgi-karaf-features:jar:5.4.1.Final in central (http://repo1.maven.org/maven2/)
at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)[7:org.ops4j.pax.url.mvn:2.4.7]
at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)[7:org.ops4j.pax.url.mvn:2.4.7]
at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)[7:org.ops4j.pax.url.mvn:2.4.7]
at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)[7:org.ops4j.pax.url.mvn:2.4.7]
at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)[7:org.ops4j.pax.url.mvn:2.4.7]
at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)[7:org.ops4j.pax.url.mvn:2.4.7]
at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)[7:org.ops4j.pax.url.mvn:2.4.7]
... 16 more
It's curious that it says it can't find it in central. I can verify the artifact is my local maven cache, because my build likely copied it there after I added the maven dependency as described above.
Update:
I'm guessing that part of my problem is that this artifact is a POM artifact, not a JAR artifact, but I don't understand how I need to reference it.
Update:
Someone on karaf-user pointed out that I need to reference it as a feature, not a bundle, so I now replaced my bundle references with the following:
<feature>hibernate-validator-osgi-karaf-features</feature>
Along with the following repository definition next to two other repository definitions:
<repository>mvn:org.hibernate/hibernate-validator-osgi-karaf-features/5.4.1.Final/xml/features</repository>
However, after installing the features file and then rerunning my test, it fails with this:
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=usl-fraudcheck; type=karaf.feature; version="[2.5.0.SNAPSHOT,2.5.0.SNAPSHOT]"; filter:="(&(osgi.identity=usl-fraudcheck)(type=karaf.feature)(version>=2.5.0.SNAPSHOT)(version<=2.5.0.SNAPSHOT))" [caused by: Unable to resolve usl-fraudcheck/2.5.0.SNAPSHOT: missing requirement [usl-fraudcheck/2.5.0.SNAPSHOT] osgi.identity; osgi.identity=usl-base; type=karaf.feature [caused by: Unable to resolve usl-base/2.5.0.SNAPSHOT: missing requirement [usl-base/2.5.0.SNAPSHOT] osgi.identity; osgi.identity=hibernate-validator-osgi-karaf-features; type=karaf.feature]]
As I'm used to now, the last identity referenced here is the thing it can't find, unsurprisingly this new feature I'm referencing.
I then verified that the following file exists:
~/.m2/repository/org/hibernate/hibernate-validator-osgi-karaf-features/5.4.1.Final/hibernate-validator-osgi-karaf-features-5.4.1.Final-features.xml
However, I found it curious that it begins with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="hibernate-validator-osgi-features"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0">
The “name” property of the top-level features element is “hibernate-validator-osgi-features”, not “hibernate-validator-osgi-karaf-features”. Is that a problem?
Update:
I now understand that my features file has to reference a feature named "hibernate-validator", which is defined in that "hibernate-validator-osgi-karaf-features" artifact. That appears to have resolved my Karaf package resolution problems. However, that simply puts me back to my original problem of:
Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
I tried changing the "LogLevel" in my Pax Exam config from WARNING to DEBUG. This gave me a lot more karaf debug output, but it didn't give me any significant info about why HV is not found in the classpath.
Is there some other debugging I can configure, or configuration in Pax Exam, that can help here?
Just take a look at our Karaf integration tests for the 5.4 branch:
https://github.com/hibernate/hibernate-validator/tree/5.4/osgi/integrationtest
We also use Pax Exam. You should be able to make it work if you follow what we did.
BTW, I see you mention the annotation processor in your dependency for the 2nd time, it's not something you need at runtime. The annotation processor is used to check that the annotations you used make sense at compile time. You should only enable it when you build your project.
See the Maven example here: https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#validator-annotationprocessor-commandline .
This solved it for me:
https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.2/html/apache_cxf_development_guide/Validation#Validation-Intro-Resolver
Read from "Configuring the validation provider explicitly in OSGi"
The problem is that in OSGI CXF has trouble to find the provider automatically so you have to resolve manually by passing the hibernate validator as a constructor argument to the CXF Bean Validation Provider.
Hope this helps :)
I'm having a slight problem with incorporating the appropriate maven dependencies into my project for sling models.
When I deploy my bundle, I get the following import that can't be resolved:
org.apache.sling.models.annotations,version=[1.1,2) -- Cannot be resolved
I believe I have included this with the following dependencies:
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.impl</artifactId>
</dependency>
I tried using:
<Embed-Transitive>true</Embed-Transitive>
<Import-Package>*</Import-Package>
in my bundle compile instructions, but this has just resulted in a ton of other dependencies not being resolved.
Surely I've gone down the garden path here somewhere. Any help would be greatly appreciated.
The org.apache.sling.models.api V1.0.2 bundle does export the following packages:
javax.inject,version=0.0.0
org.apache.sling.models.annotations,version=1.1.0
org.apache.sling.models.annotations.injectorspecific,version=1.0.0
org.apache.sling.models.spi,version=1.0.0
org.apache.sling.models.spi.injectorspecific,version=1.0.0
So if that bundle is active in your Sling instance, the org.apache.sling.models.annotations,version=[1.1,2) import should resolve.
Note that adding bundles to your maven dependencies might not be sufficient to install them in the running instance, what matters is whether the models.api bundle is active as seen from /system/console/bundles
Using Embed-Transitive is almost always a terrible idea. It traverses the entire transitive dependency hierarchy in Maven and pulls each one of those JARs into your own JAR. As a result you inherit all the package dependencies of all that crap you have dragged in.
When you have a bundle such as yours that requires an import -- in this case org.apache.sling.models.annotations -- the best solution is to find another bundle already available that exports the same package.
I have followed this CXF Proxy Example and it runs successfully as described.
Now I want to deploy the CXF Proxy Example into JBoss-Fuse as OSGI Bundle. I am following this instruction Deploying the Apache Camel Route. But this popping me out with this error:
JBossFuse:admin#root> install -s mvn:org.apache.camel/camel-example-cxf-proxy/2.12.2
Bundle ID: 281
Error executing command: Error installing bundles:
Unable to start bundle mvn:org.apache.camel/camel-example-cxf-proxy/2.12.2:
Unresolved constraint in bundle org.apache.camel.camel-example-cxf-proxy [281]: Unable
to resolve 281.0: missing requirement [281.0] osgi.wiring.package;
(&(osgi.wiring.package=org.apache.camel.spring)(version>=2.12.0)(!(version>=2.13.0)))
JBossFuse:admin#root>
I didn't change anything. Just used their example as it is. They have this on their pom.xml
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>examples</artifactId>
<version>2.12.2</version>
</parent>
I tried this by changing the version into 2.9.0.fuse-70-097 But the error is same(just with a changed version number)
osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel.spring)
(version>=2.9.0)(!(version>=2.10.0)))
I randomly tried with several versions by replacing it in pom.xml and suddenly it worked for me when i hit the following version:
<version>2.10.0</version>
I don't know why it worked for me. But, just found me lucky!
I have a Maven project that's building fine, and I'm attempting to add a reference to twitter4j.
So I add this to the pom:
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.2,)</version>
<type>jar</type>
<optional>false</optional>
<scope>compile</scope>
</dependency>
When I build (mvn clean install) I get:
[ERROR] Error building bundle net.stevex.tweetfetcher:tweetfetcher-bundle:bundle:1.0-SNAPSHOT : Unresolved references to [twitter4j] by class(es) on the Bundle-Classpath[Jar:dot]: [net/stevex/tweetfetcher/impl/TweetFetcherImpl.class]
This makes sense .. the twitter4j package isn't embedded in the bundle. So I add an Embed-Dependency to the maven-bundle-plugin's instructions:
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
And now when I build, I get:
[ERROR] Error building bundle net.stevex.tweetfetcher:tweetfetcher-bundle:bundle:1.0-SNAPSHOT : Unresolved references to [dalvik.system, javax.crypto, javax.crypto.spec, javax.management, javax.management.openmbean, org.apache.commons.logging, org.apache.log4j, org.slf4j.impl, twitter4j.internal.http.alternative] by class(es) on the Bundle-Classpath[Jar:dot, Jar:twitter4j-core-2.2.3.jar]: [twitter4j/internal/logging/CommonsLoggingLogger.class, twitter4j/internal/logging/Log4JLoggerFactory.class, twitter4j/auth/OAuthToken.class, twitter4j/internal/http/HttpClientFactory.class, twitter4j/auth/OAuthAuthorization.class, twitter4j/internal/logging/Log4JLogger.class, twitter4j/conf/ConfigurationBase.class, twitter4j/TwitterAPIMonitor.class, twitter4j/internal/logging/CommonsLoggingLoggerFactory.class, twitter4j/management/APIStatisticsOpenMBean.class, twitter4j/internal/logging/Logger.class]
I don't understand why the twitter4j classes are missing, and I don't understand the references to dalvik.system, javax.crypto, etc. What's wrong here?
The problem is that the twitter4j project requires all of the packages listed in the error list. When you use it does not include all transitive dependencies. There is an Embed Transitive instruction for the maven-bundle-plugin that will embed all transitive dependencies
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
However, this kind of defeats the purpose of OSGi. This leaves you with two options that I know of:
Search for the packages in the second in the SpringSource EBR. You simply enter the package name in the search box, and the results will include the xml for your POM file. The SpringSource bundles will include references to other bundles in the EBR, eliminating the problem of transitive dependencies.
Use the bundle-all goal of the maven-bundle-plugin. This goal will run the maven bundle plugin for every dependency of your project, and place the resulting bundles into your target directory. You could then install these bundles into your local repository.
I would recommend using option 1 for as many of the bundles as you can find, then defaulting to option 2 when SpringSource doesn't have them.