Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Google enterprise captcha integration

Avatar

Avatar
Validate 1
Level 1
harishk_Myst
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
harishk_Myst
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
harishk_Myst
Level 1

21-07-2021

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.

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

564 likes

Total Posts

706 posts

Correct Reply

234 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

564 likes

Total Posts

706 posts

Correct Reply

234 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile
Vijayalakshmi_S
MVP

22-07-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>