I am using adobe CIF add-on on AEM cloud and created a cutomproduct(resource super type - core/cif/components/commerce/product/v3/product) component which has its own CustomProductImpl and CustomProduct.
CustomProductImpl tries to make use MagentoGraphQLClient. However, this object never gets initialized or injected. Any help here in resolving this issue is highly appreciated.
Some observations,
1. When we try to work on vanilla instance on top of venia project using this custom component. Everything works fine. However, when we add CustomProductImp in our project codebase, it starts giving null value on debugging MagentoGraphQLClient.
2. Under OSGI component list, I see some instances of GraphQLClientImpl in active state and some in satisfies state. Active state OSGI component's are used by adobe bundles and satisfied state by OSGI components of the project bundles. I am suspecting some problem here. Screenshot attached.
3. The issue is intermittent in local, but in AEM cloud dev, this issue occurs consistently.
4. Exception in logs are mostly around
Caused by: java.lang.ClassCastException: class com.adobe.cq.commerce.core.components.internal.client.MagentoGraphqlClientImpl cannot be cast to class com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient (com.adobe.cq.commerce.core.components.internal.client.MagentoGraphqlClientImpl is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @55cfca83; com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @6f97aac3)
Some checks which we already did.
1. GraphQL OSGI configuration is correct.
2. Added all dependencies in main pom.xml and embedded everything in all/pom.xmlcorrectly as mentioned in venia project.
3. GraphQL url is public, so all good.
4. COMMERCE_ENDPOINT variable is configured correctly in cloud manager.
P.S. we are not looking for product picker or catalog picker functionality to work, just focusing on showing product detail page to end users, however custom product ends up giving null value for MagentoGraphQLClient.
Sample code base for CustomProductImpl
Solved! Go to Solution.
Views
Replies
Total Likes
This error occurs when the class is loaded through two different class loaders (bundles). It appears that the class is being loaded through your custom bundle as well as the CIF core components module.
Please verify and remove any instances where you are exporting (Export-Package) the com.adobe.cq.commerce.core.components.client
or any parent package in your core module (pom.xml
). Ensure that the package is directly utilized from the CIF Core Components bundle.
Regards
Albin
Views
Replies
Total Likes
This error occurs when the class is loaded through two different class loaders (bundles). It appears that the class is being loaded through your custom bundle as well as the CIF core components module.
Please verify and remove any instances where you are exporting (Export-Package) the com.adobe.cq.commerce.core.components.client
or any parent package in your core module (pom.xml
). Ensure that the package is directly utilized from the CIF Core Components bundle.
Regards
Albin
Views
Replies
Total Likes
Thanks, Albin. That solved the issue. Appreciate your inputs.