com.google.common.base.MoreObjects not found by com.adobe.granite.osgi.wrapper.guava | Community
Skip to main content
Level 2
January 23, 2024
Solved

com.google.common.base.MoreObjects not found by com.adobe.granite.osgi.wrapper.guava

  • January 23, 2024
  • 2 replies
  • 3888 views

In my project, I'm trying to use com.google.auth. However, this is requiring me to add dependency of com.google.guava. Even with this dependency added and exported via bnd-maven-plugin, I'm getting error:

 

  • Caused by: java.lang.ClassNotFoundException: com.google.common.base.MoreObjects not found by com.adobe.granite.osgi.wrapper.guava

 

Following some other people's post related to this issue, I've tried changing order of com.adobe.acs and uber-jar to ensure version of guava I want is found first, but haven't had any luck.

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 Raja_Reddy

Hi @keno6396 

Add below dependency in root pom.xml

<dependencyManagement>
 <dependencies>
   <dependency>
	<groupId>com.google.guava</groupId>
	<artifactId>guava</artifactId>
	<version>20.0</version>
   </dependency>
 </dependencies>
</dependencyManagement>

 core pom.xml

<dependencies>
   <dependency>
	<groupId>com.google.guava</groupId>
	<artifactId>guava</artifactId>
    </dependency>
</dependencies>

in all module's pom.xml

<project>
<build>
        <plugins>
            <!-- ====================================================================== -->
            <!-- V A U L T   P A C K A G E   P L U G I N S                              -->
            <!-- ====================================================================== -->
            <plugin>
                <groupId>org.apache.jackrabbit</groupId>
                <artifactId>filevault-package-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <group><com.project...></group>
                    <packageType>container</packageType>
                    <properties>
                        <cloudManagerTarget>all</cloudManagerTarget>
                    </properties>
                    <!-- skip sub package validation for now as some vendor packages like CIF apps will not pass -->
                    <skipSubPackageValidation>true</skipSubPackageValidation>
                    <embeddeds>
                       
                        <embedded>
                            <groupId>com.google.guava</groupId>
                            <artifactId>guava</artifactId>
                            <target>/apps/<project-name-packages/application/install</target>
                        </embedded>
            
​                    </embeddeds>
					
                </configuration>
            </plugin>
        </plugins>
    </build>
	<dependencies>
	<dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
    </dependencies>
</project>

2 replies

Raja_Reddy
Community Advisor
Raja_ReddyCommunity AdvisorAccepted solution
Community Advisor
January 23, 2024

Hi @keno6396 

Add below dependency in root pom.xml

<dependencyManagement>
 <dependencies>
   <dependency>
	<groupId>com.google.guava</groupId>
	<artifactId>guava</artifactId>
	<version>20.0</version>
   </dependency>
 </dependencies>
</dependencyManagement>

 core pom.xml

<dependencies>
   <dependency>
	<groupId>com.google.guava</groupId>
	<artifactId>guava</artifactId>
    </dependency>
</dependencies>

in all module's pom.xml

<project>
<build>
        <plugins>
            <!-- ====================================================================== -->
            <!-- V A U L T   P A C K A G E   P L U G I N S                              -->
            <!-- ====================================================================== -->
            <plugin>
                <groupId>org.apache.jackrabbit</groupId>
                <artifactId>filevault-package-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <group><com.project...></group>
                    <packageType>container</packageType>
                    <properties>
                        <cloudManagerTarget>all</cloudManagerTarget>
                    </properties>
                    <!-- skip sub package validation for now as some vendor packages like CIF apps will not pass -->
                    <skipSubPackageValidation>true</skipSubPackageValidation>
                    <embeddeds>
                       
                        <embedded>
                            <groupId>com.google.guava</groupId>
                            <artifactId>guava</artifactId>
                            <target>/apps/<project-name-packages/application/install</target>
                        </embedded>
            
​                    </embeddeds>
					
                </configuration>
            </plugin>
        </plugins>
    </build>
	<dependencies>
	<dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
    </dependencies>
</project>
keno6396Author
Level 2
January 23, 2024

I had added root pom and core pom, but was missing all pom. I made sure all are added and ran mvn clean install -PautoInstallPackage, but error persists. One thing I'm noticing is that in the core bundle, instead of com.google.common.* being resolved from com.google.guava or core bundle, they are being resolved by com.adobe.granite.osgi.wrapper.guava. How can I make them get resolved by com.google.guava dependency I'm adding in?

January 29, 2024

Hi @raja_reddy  ,

 

Has the dependency issue with the Guava bundle been resolved? If yes, could you please share the steps you've taken to address it?

 

Thanks,

Sudhakar.

Raja_Reddy
Community Advisor
Community Advisor
January 30, 2024

Hi @sudha2351 @keno6396 
Check Manifest Headers: Make sure that the MANIFEST.MF file in your bundle specifies the correct imports for the Guava packages.

Import-Package: com.google.common.base;version="20.0",

  1. Order of Bundle Execution: If the issue persists, try adjusting the order in which your bundles are started. OSGi resolves dependencies based on the order in which bundles are started. You may want to ensure that your bundle is started before any other bundles that may interfere with Guava.

  2. Check Felix Console: Access the Apache Felix Web Console in your AEM environment (http://localhost:4502/system/console) and navigate to the "Bundles" tab. Look for your bundle and check its dependencies. Verify that Guava is resolved and active.

  3. Embedding Guava: It seems you are embedding Guava using the filevault-package-maven-plugin. Make sure that the embedded Guava bundle is being created and included in your project correctly. Check the resulting content of the /apps/<project-name-packages/application/install directory to ensure that the Guava JAR is present.