Google enterprise captcha integration | Community
Skip to main content
Level 2
July 21, 2021
Solved

Google enterprise captcha integration

  • July 21, 2021
  • 1 reply
  • 5636 views

hi there..Hope everyone is sound and safe !! . I am trying to integrate google enterprise libraries in my code. I tried adding in pom like this:

 

 

<dependencyManagement> <dependencies> <dependency> <groupId>com.google.cloud</groupId> <artifactId>libraries-bom</artifactId> <version>20.8.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-recaptchaenterprise</artifactId> </dependency> </dependencies>

 

 

But the bundle remains in installed state. Here is the error:

 

 

21.07.2021 19:06:21.047 *ERROR* [qtp1013065474-2273] org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Unable to resolve com.sample.poc [627](R 627.1): missing requirement [com.sample.poc [627](R 627.1)] osgi.wiring.package; (&(osgi.wiring.package=javax.annotation)(version>=1.3.0)(!(version>=2.0.0))) Unresolved requirements: [[com.sample.poc [627](R 627.1)] osgi.wiring.package; (&(osgi.wiring.package=javax.annotation)(version>=1.3.0)(!(version>=2.0.0)))]) org.osgi.framework.BundleException: Unable to resolve com.sample.poc [627](R 627.1): missing requirement [com.sample.poc [627](R 627.1)] osgi.wiring.package; (&(osgi.wiring.package=javax.annotation)(version>=1.3.0)(!(version>=2.0.0))) Unresolved requirements: [[com.sample.poc [627](R 627.1)] osgi.wiring.package; (&(osgi.wiring.package=javax.annotation)(version>=1.3.0)(!(version>=2.0.0)))] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149)

 

 

Then i tried installing javax.annotation bundle version 1.3.2 in the osgi console. But then I am getting this error this error:

21.07.2021 19:09:37.026 *ERROR* [qtp1013065474-2273] org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve resource com.sample.poc [com.sample.poc [627](R 627.1)] because it is exposed to package 'javax.annotation' from resources javax.annotation-api [javax.annotation-api [628](R 628.0)] and org.apache.felix.framework [org.apache.felix.framework [0](R 0)] via two dependency chains. Chain 1: com.sample.poc [com.sample.poc [627](R 627.1)] import: (&(osgi.wiring.package=javax.annotation)(version>=1.3.0)(!(version>=2.0.0))) | export: osgi.wiring.package: javax.annotation javax.annotation-api [javax.annotation-api [628](R 628.0)] Chain 2: com.sample.poc [com.sample.poc [627](R 627.1)] import: (&(osgi.wiring.package=com.adobe.acs.commons.genericlists)(version>=1.0.0)(!(version>=2.0.0))) | export: osgi.wiring.package=com.adobe.acs.commons.genericlists; uses:=javax.annotation com.adobe.acs.acs-aem-commons-bundle [com.adobe.acs.acs-aem-commons-bundle [624](R 624.0)] import: (osgi.wiring.package=javax.annotation) | export: osgi.wiring.package: javax.annotation org.apache.felix.framework [org.apache.felix.framework [0](R 0)] Unresolved requirements: [[com.sample.poc [627](R 627.1)] osgi.wiring.package; (&(osgi.wiring.package=com.adobe.acs.commons.genericlists)(version>=1.0.0)(!(version>=2.0.0)))]) org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve resource com.sample.poc [com.sample.poc [627](R 627.1)] because it is exposed to package 'javax.annotation' from resources javax.annotation-api [javax.annotation-api [628](R 628.0)] and org.apache.felix.framework [org.apache.felix.framework [0](R 0)] via two dependency chains. Chain 1: com.sample.poc [com.sample.poc [627](R 627.1)] import: (&(osgi.wiring.package=javax.annotation)(version>=1.3.0)(!(version>=2.0.0))) | export: osgi.wiring.package: javax.annotation javax.annotation-api [javax.annotation-api [628](R 628.0)] Chain 2: com.sample.poc [com.sample.poc [627](R 627.1)] import: (&(osgi.wiring.package=com.adobe.acs.commons.genericlists)(version>=1.0.0)(!(version>=2.0.0))) | export: osgi.wiring.package=com.adobe.acs.commons.genericlists; uses:=javax.annotation com.adobe.acs.acs-aem-commons-bundle [com.adobe.acs.acs-aem-commons-bundle [624](R 624.0)] import: (osgi.wiring.package=javax.annotation) | export: osgi.wiring.package: javax.annotation org.apache.felix.framework [org.apache.felix.framework [0](R 0)] Unresolved requirements: [[com.sample.poc [627](R 627.1)] osgi.wiring.package; (&(osgi.wiring.package=com.adobe.acs.commons.genericlists)(version>=1.0.0)(!(version>=2.0.0)))] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149)

i tried adding adding dependencies in embed-dependencies also ,tried <import-package> and <export-package> options also. But still the bundle remains in installed state. Also tried osgification of recaptcha jar but still the issue remains.

Please let me know what I am missing here and let me know the correct steps if someone has.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Vijayalakshmi_S

Hi @harishk_myst,

Use this pom.xml to build google recaptcha dependency as OSGi bundle - Use command mvn package install

This would build the dependency as OSGi bundle using maven-bundle-plugin and install to felix console via sling-maven-plugin (update the instance details accordingly in properties)

 

We are explicitly mentioning what needs to be exported from Google recaptcha dependency in Export-Package entry instead of "*" (using * would result in dependency chain issue like the one you have posted in the query as it will export everything which when deployed in AEM instance might clash with bundles that are available OOTB)

Based on the code you have written making use of Google recaptcha, make sure to include those package family in Export-Package list. (If there is anything that is apart from the ones that I have mentioned)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.aem.demoproject</groupId> <artifactId>thirdparty</artifactId> <version>0.0.1</version> <packaging>bundle</packaging> <name>Demo Project Third party Dependency</name> <url>http://maven.apache.org</url> <description>Demo Project Third party Dependency as OSGI bundle using maven-bundle-plugin</description> <properties> <aem.host>localhost</aem.host> <aem.port>4502</aem.port> <sling.user>admin</sling.user> <sling.password>admin</sling.password> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- Google Recaptcha --> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-recaptchaenterprise</artifactId> <version>1.0.10</version> <!-- Use the desired version --> </dependency> </dependencies> <build> <plugins> <plugin> <!-- Builds the dependency as OSGi bundle --> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Import-Package>*;resolution:=optional</Import-Package> <Export-Package> com.google.recaptchaenterprise.v1.*, com.google.auth.*, com.google.api.gax.*, com.google.cloud.recaptchaenterprise.v1.* </Export-Package> <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> </instructions> </configuration> </plugin> <plugin> <!-- Installs the build OSGi bundle into specified AEM instance's felix console --> <groupId>org.apache.sling</groupId> <artifactId>sling-maven-plugin</artifactId> <executions> <execution> <id>install-bundle</id> <goals> <goal>install</goal> </goals> <configuration> <slingUrl>http://${aem.host}:${aem.port}/system/console</slingUrl> <refreshPackages>true</refreshPackages> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>

 

1 reply

Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
Level 10
July 22, 2021

Hi @harishk_myst,

Use this pom.xml to build google recaptcha dependency as OSGi bundle - Use command mvn package install

This would build the dependency as OSGi bundle using maven-bundle-plugin and install to felix console via sling-maven-plugin (update the instance details accordingly in properties)

 

We are explicitly mentioning what needs to be exported from Google recaptcha dependency in Export-Package entry instead of "*" (using * would result in dependency chain issue like the one you have posted in the query as it will export everything which when deployed in AEM instance might clash with bundles that are available OOTB)

Based on the code you have written making use of Google recaptcha, make sure to include those package family in Export-Package list. (If there is anything that is apart from the ones that I have mentioned)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.aem.demoproject</groupId> <artifactId>thirdparty</artifactId> <version>0.0.1</version> <packaging>bundle</packaging> <name>Demo Project Third party Dependency</name> <url>http://maven.apache.org</url> <description>Demo Project Third party Dependency as OSGI bundle using maven-bundle-plugin</description> <properties> <aem.host>localhost</aem.host> <aem.port>4502</aem.port> <sling.user>admin</sling.user> <sling.password>admin</sling.password> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- Google Recaptcha --> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-recaptchaenterprise</artifactId> <version>1.0.10</version> <!-- Use the desired version --> </dependency> </dependencies> <build> <plugins> <plugin> <!-- Builds the dependency as OSGi bundle --> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Import-Package>*;resolution:=optional</Import-Package> <Export-Package> com.google.recaptchaenterprise.v1.*, com.google.auth.*, com.google.api.gax.*, com.google.cloud.recaptchaenterprise.v1.* </Export-Package> <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> </instructions> </configuration> </plugin> <plugin> <!-- Installs the build OSGi bundle into specified AEM instance's felix console --> <groupId>org.apache.sling</groupId> <artifactId>sling-maven-plugin</artifactId> <executions> <execution> <id>install-bundle</id> <goals> <goal>install</goal> </goals> <configuration> <slingUrl>http://${aem.host}:${aem.port}/system/console</slingUrl> <refreshPackages>true</refreshPackages> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>

 

Vijayalakshmi_S
Level 10
July 26, 2021

@harishk_myst,

Can you amend the plugin as below

  • Export-Package entry -
    • Add this - "com.google.protobuf.nano"  and remove "com.sample.poc.*" 
    • The packages from google recaptchaenterprise dependency which are not resolved, you keep adding that alone in Export-Packages list. (By simply using * here would resolve the bundle but at times based on what we have in our AEM instance + dependency we are using, there exist a chance of dependency clash. Hence the need for adding the required/unresolved ones explicitly)
  • Include-Resource is not needed explicitly (That too when you are using {maven-resources} which will be included by default)
Level 2
October 11, 2022

Hello @mukesh4 

yes, the issue is resolved for me.

 

I added the below configuration to resolve the bundle resolution issue.

For the bundle plugin configuration, i have exported following packages

 

com.google.cloud.recaptchaenterprise.v1.*,
com.google.recaptchaenterprise.v1.*


Hi @nitish-jain@vijayalakshmi_s 

We tried to export the packages mentioned by you in our POM, but we still see the bundle in installed state.

 

Moreover the version picked for google api's is showing same as our project version.

Can you please let us know if there was a need to install the google api's as a separate bundle in AEM or it was all done via POM in your case.

 

Also, can you please help us in sharing the exact pom.xml changes you made for making the enterprise recaptcha work.

Please note we are not using maven-bundle-plugin for importing and exporting packages but use maven-bundle-plugin.