Ok, makes sense, but it still isn’t quite there yet.
In the features file in a module called “usl-base”, I added the following
repository definition next to a couple of existing ones:
<repository>mvn:org.hibernate/hibernate-validator-osgi-karaf-features/5.4.1.Final/xml/features</repository>
In the “usl-base” feature in that features file, I added the following
reference:
<feature>hibernate-validator-osgi-karaf-features</feature>
Looking at the actual features file that is referenced here, I noticed that I
had some redundant bundle references in this features file, so I removed them
(“hibernate-validator”, “classmate”, et cetera).
I then installed this features file, and then reran my test, and the karaf
startup failed 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]]
The “usl-fraudcheck” feature is the feature in the module with my test, which
references the “usl-base” feature. So, it seems that it couldn’t find the
“hibernate-validator-osgi-karaf-features” feature.
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"?>
<!--
~ Hibernate Validator, declare and validate application constraints
~
~ License: Apache License, Version 2.0
~ See the license.txt file in the root directory or
<http://www.apache.org/licenses/LICENSE-2.0>.
-->
<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?
From: Achim Nierbeck [mailto:[email protected]]
Sent: Monday, June 05, 2017 9:29 AM
To: [email protected]
Subject: Re: PaxExam test using hibernate validator can't find validator
hmm ... to me this artifact:
org.hibernate:hibernate-validator-osgi-karaf-features
doesn't sound like a bundle but more like a feature.
and according to this[1], it is a feature file.
So make sure you reference the "hibernate-validator" feature in your own
feature file.
if you want to define a dependency to another feature file from your own.
make sure to have a repo definition:
<repository>mvn:org.hibernate/hibernate-validator-osgi-karaf-features/5.4.1.Final/xml/features</repository>
regards, Achim
[1] -
http://search.maven.org/#artifactdetails%7Corg.hibernate%7Chibernate-validator-osgi-karaf-features%7C5.4.1.Final%7Cpom<https://urldefense.proofpoint.com/v2/url?u=http-3A__search.maven.org_-23artifactdetails-257Corg.hibernate-257Chibernate-2Dvalidator-2Dosgi-2Dkaraf-2Dfeatures-257C5.4.1.Final-257Cpom&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=As6N5mQlxUz7ghxb25q0tzD45Uu3Qj4gCD6yGyrA-0A&e=>
[2] -
https://repo1.maven.org/maven2/org/hibernate/hibernate-validator-osgi-karaf-features/5.4.1.Final/hibernate-validator-osgi-karaf-features-5.4.1.Final-features.xml<https://urldefense.proofpoint.com/v2/url?u=https-3A__repo1.maven.org_maven2_org_hibernate_hibernate-2Dvalidator-2Dosgi-2Dkaraf-2Dfeatures_5.4.1.Final_hibernate-2Dvalidator-2Dosgi-2Dkaraf-2Dfeatures-2D5.4.1.Final-2Dfeatures.xml&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=vD7BMmrrvCLY7YOfVqPdo5onjeXnQ9q9j_AqaNEre4k&e=>
2017-06-05 17:37 GMT+02:00 KARR, DAVID <[email protected]<mailto:[email protected]>>:
I'm working on a codebase that builds a bunch of OSGi modules, and deploys to
karaf.
I'm attempting to implement javax.validation using Hibernate Validator. I was
able to get the correct Maven artifacts in order for my plain unit tests to
work.
However, when I ran my PaxExam integration test, it fails with:
"Unable to create a Configuration, because no Bean Validation provider could be
found. Add a provider like Hibernate Validator (RI) to your classpath."
After some research, I determined that I needed to use the
"hibernate-validator-osgi-karaf-features" artifact. However, this just gives
me a new error:
"Could not find artifact
org.hibernate:hibernate-validator-osgi-karaf-features:jar:5.4.1.Final in
central
(http://repo1.maven.org/maven2/<https://urldefense.proofpoint.com/v2/url?u=http-3A__repo1.maven.org_maven2_&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=JD9PqtfvfGg2L4e44x_lnFbbcv5uOTKAHptpFSRH6JQ&e=>)"
Here is an excerpt of a "features.xml" file inside the definition of a feature
that is dependent feature of the main feature in the module where my
integration test is:
----------------
<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.<https://urldefense.proofpoint.com/v2/url?u=http-3A__5.4.1.&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=d4F2HBQnG0VgS87tUYGLOJNkDsHxITy2zNwXmewTGEg&e=>Final</bundle>
<bundle>wrap:mvn:org.hibernate/hibernate-validator-osgi-karaf-features/5.4.1.<https://urldefense.proofpoint.com/v2/url?u=http-3A__5.4.1.&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=d4F2HBQnG0VgS87tUYGLOJNkDsHxITy2zNwXmewTGEg&e=>Final$Bundle-Name=hibernate-validator-osgi-karaf-features&Bundle-SymbolicName=hibernate-validator-osgi-karaf-features&Bundle-Version=5.4.1.Final</bundle>
----------------
I'm guessing that part of my problem is that this is a POM artifact, not a JAR
artifact, but I don't know what to do here.
--
Apache Member
Apache Karaf
<http://karaf.apache.org/<https://urldefense.proofpoint.com/v2/url?u=http-3A__karaf.apache.org_&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=1AtAjWo20M9NtJRfUU-xC_OLufXHR3QFhz4YiqapfDU&e=>>
Committer & PMC
OPS4J Pax Web
<http://wiki.ops4j.org/display/paxweb/Pax+Web/<https://urldefense.proofpoint.com/v2/url?u=http-3A__wiki.ops4j.org_display_paxweb_Pax-2BWeb_&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=kP1598mVzEsFMyfHm97vIafC2nNKKw352TlPDPDXDm8&e=>>
Committer & Project Lead
blog
<http://notizblog.nierbeck.de/<https://urldefense.proofpoint.com/v2/url?u=http-3A__notizblog.nierbeck.de_&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=EbG7OOlXl-TpPsxTKKNdS9bQ2zlaFOoozz2XlAQBHb8&e=>>
Co-Author of Apache Karaf Cookbook
<http://bit.ly/1ps9rkS<https://urldefense.proofpoint.com/v2/url?u=http-3A__bit.ly_1ps9rkS&d=DwMFaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=OsTemSXEn-xy2uk0vYF_EA&m=Zh3YlwUBx9x6RHcJJm9-PgIOGVz9Sg3C5KBvKpkmjgA&s=1EGWETeRgV-rQez2jRl2EUk4X8ji64Lu-2iR9BcBgEo&e=>>
Software Architect / Project Manager / Scrum Master