Expand my Community achievements bar.

SOLVED

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

Avatar

Level 2

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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>


View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

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>


Avatar

Level 2

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?

Avatar

Level 1

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.

Avatar

Community Advisor

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.