AEM CIF: Unable to fetch custom product attributes from Magento - aem

I am not able to fetch custom attributes which are created in Magento using AEM Commerce Integration Framework (CIF). If you see the logs below, my custom attribute is not present in any of the graph QL queries that are being fired. And, my custom product model is initiated after the all queries are fired. I am able to fetch the same custom attribute when I manually query for the attribute (thru postman).
There are no queries fired at any point after this line is executed:
productRetriever.extendProductQueryWith(p -> p.addCustomSimpleField("custom_attribute")
com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Try to get a graphql client from the resource at /content/demoproject/us/en/products/product-page
14.08.2021 10:05:12.907 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Crafting a configuration resource and attempting to get a GraphQL client from it...
14.08.2021 10:05:12.907 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl Executing GraphQL query: {products(filter:{url_key:{eq:"prod-name"}}){items{__typename,sku,url_key}}}
##### Main Product Query Happens Here ####
14.08.2021 10:05:13.673 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl Executing GraphQL query: {products(filter:{sku:{eq:"1234"}}){items{__typename,sku,name,description{html},image{label,url},thumbnail{label,url},url_key,stock_status,meta_description,meta_keyword,meta_title,price_range{minimum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}},media_gallery{__typename,disabled,url,label,position},categories{__typename,uid,name,image},... on ConfigurableProduct{price_range{maximum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}},configurable_options{label,attribute_code,values{value_index,label}},variants{attributes{code,value_index},product{sku,name,description{html},image{label,url},thumbnail{label,url},url_key,stock_status,color,price_range{minimum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}},media_gallery{__typename,disabled,url,label,position},categories{__typename,uid,name,image},staged}}},... on GroupedProduct{items{position,qty,product{__typename,sku,name,price_range{minimum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}}}}},... on BundleProduct{price_range{maximum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}}},staged}}}
##### My Custom Product Model is initialized Here ####
14.08.2021 10:05:16.950 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl Inside init method:::::::1234
14.08.2021 10:05:16.950 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl extending query
14.08.2021 10:05:16.951 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl Outside if
14.08.2021 10:05:16.953 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl Inside custom attribute get method
### After this there are no graphql queries fired ###

You may be coming across the same issue I've just managed to resolve with the help of the developers of the core-cif-components:
https://github.com/adobe/aem-core-cif-components/issues/504
This issue is that the out of the box model was being initialized first in the PageMetadataImpl.java. This is then cached so that it's not fired again with the custom query.
It turns out that I just needed to add the original Product.class as an adaptable in the annotations in my custom class. That way it's used as the model implementation in PageMetadataImpl.java. It wasn't how it was done in the tutorial I was following which was why it was a bit confusing.

This issue got resolved updating to a recent version of Magento connector and CIF core components.

Related

Web Tracker Apache Unomi

I'm working on a project that uses the Apache Unomi, I had installed all the requirements installation for the Apache Unomi and created a profile and some rules, and all worked well.
But, when I tried to test the web tracker example provided in the Apache Unomi documentation.
I got the following error before pressing the submit button
[UNOMI] XML request error: Unsupported Media Type (415) unomi-tracker.js:16068:29
onreadystatechange http://localhost:8181/tracker/unomi-tracker.js:16068
and after the submitting, I got those errors
XHRPOSThttp://localhost:8181/cxs/context.json
[HTTP/1.1 415 Unsupported Media Type 4ms]
[UNOMI] XML request error: Unsupported Media Type (415) unomi-tracker.js:16068:29
onreadystatechange http://localhost:8181/tracker/unomi-tracker.js:16068
(Async: EventHandlerNonNull)
ajax http://localhost:8181/tracker/unomi-tracker.js:16053
loadContext http://localhost:8181/tracker/unomi-tracker.js:15788
initialize http://localhost:8181/tracker/unomi-tracker.js:15622
initialize http://localhost:8181/tracker/unomi-tracker.js:4064
initialize http://localhost:8181/tracker/unomi-tracker.js:1433
baseEach http://localhost:8181/tracker/unomi-tracker.js:595
each http://localhost:8181/tracker/unomi-tracker.js:633
initialize http://localhost:8181/tracker/unomi-tracker.js:1409
exports http://localhost:8181/tracker/unomi-tracker.js:5500
callback http://localhost:8181/tracker/?firstName=John&lastName=Doe&email=johndoe#acme.com#:84
load http://localhost:8181/tracker/?firstName=John&lastName=Doe&email=johndoe#acme.com#:112
(Async: EventListener.handleEvent)
load http://localhost:8181/tracker/?firstName=John&lastName=Doe&email=johndoe#acme.com#:110
(Async: EventListener.handleEvent)
http://localhost:8181/tracker/?firstName=John&lastName=Doe&email=johndoe#acme.com#:128
http://localhost:8181/tracker/?firstName=John&lastName=Doe&email=johndoe#acme.com#:143
Because of the errors, the event is not sent to the Apache Unomi.

Jenkins CORS Filter plugin not adding Access-Control-Allow-Origins header

I am trying to add CORS support to my Jenkins server so I could access the REST API from the browser. From looking around, the recommended approach is to use the CORS Filter plugin.
I have installed it, enable it, and add http://localhost to the Access-Control-Allow-Origins field, as well as GET to Access-Control-Allow-Methods field. However, these headers are not showing up in my requests.
This plugin has not been updated in a few years, so I'm not sure if it's compatible with the latest version of Jenkins. I'm running version 2.172.
In the Jenkins system log, I see these errors, not sure if it's related/ relevant
Caught exception evaluating: descriptor.getPropertyType(instance,field).itemTypeDescriptorOrDie in /configure. Reason: java.lang.reflect.InvocationTargetException
java.lang.AssertionError: class hudson.ivy.IvyBuildTrigger$IvyConfiguration is missing its descriptor in public hudson.ivy.IvyBuildTrigger$IvyConfiguration[] hudson.ivy.IvyBuildTrigger$DescriptorImpl.getConfigurations(). See https://jenkins.io/redirect/developer/class-is-missing-descriptor
Caught exception evaluating: h.filterDescriptors(it,attrs.descriptors) in /configure. Reason: java.lang.NullPointerException: Descriptor list is null for context 'class hudson.model.Hudson' in thread 'Handling GET /configure from 100.71.26.18 : qtp589873731-14 Jenkins/configure.jelly GlobalLibraries/config.jelly LibraryConfiguration/config.jelly SCMRetriever/DescriptorImpl/config.jelly MultiSCM/DescriptorImpl/config.jelly'
java.lang.NullPointerException: Descriptor list is null for context 'class hudson.model.Hudson' in thread 'Handling GET /configure from 100.71.26.18 : qtp589873731-14 Jenkins/configure.jelly GlobalLibraries/config.jelly LibraryConfiguration/config.jelly SCMRetriever/DescriptorImpl/config.jelly MultiSCM/DescriptorImpl/config.jelly'
These errors have at org.jenkinsci.plugins.corsfilter.AccessControlsFilter.doFilter(AccessControlsFilter.java:79) in their stack trace.
Does anyone know of a good way to enable CORS support for Jenkins REST API?
Jenkins version 2.303 and I struggle with the same issue. I would recommend to add the port number on the localhost URI you defined in the plugin settings, even though I'm pretty sure that won't change anything.
It actually seems the plugin is having no effect at all.
Probably the best solution is to set up your own proxy which would take care of CORS. Here is a good and well document example Build a Node.js Proxy Server in Under 10 minutes!

Pass Arraylist in post request to neo4j

I want to pass an array list to post request to Neo4j server, instead I get an warning at startup when I try run systemctl status neo4j.
WARN Failed to load plugin [ServerPlugin[KShortestPaths]]:
Unsupported parameter type: java.util.ArrayList
I want to pass something like:
{
"concept1":"C0000039",
"vocabulary": ["MSH", "NDFRT"]
}

Getting null TagManager in AEM 6.1

Trying to fetch the list of all the resources tagged with the specific tag. Following is the line used to fetch the TagManager from ResourceResolver
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
But getting null TagManager.
Also, when I am trying to bind JcrTagManagerFactory, the service is failing as the JcrTagManagerFactory could not be bind. I could see JcrTagManagerFactory service running in console.
#Reference
JcrTagManagerFactory jcrTagManagerFactory;
Any suggestions? Am I missing anything?

Getting error while saving morphia model to mongodb using CRUD interface

During generic save action of morphia model using CRUD interface I recieve following error:
Oops: NullPointerException An unexpected error occured caused by
exception NullPointerException: null
play.exceptions.UnexpectedException: Unexpected Error at
play.modules.morphia.Model.edit(Model.java:219) at
play.modules.morphia.MorphiaPlugin.bind(MorphiaPlugin.java:607)
...
I've found that similiar error was in version 1.2.4a and was fixed in 1.2.4b.
I downoladed the latest version of morphia. On app start I recieve followind log:
12:18:59,036 INFO ~ Module morphia is available (C:\play-1.2.4\samples-and-tests\test1\modules\ morphia-1.2.4b )
12:18:59,037 INFO ~ Module secure is available (C:\play-1.2.4\modules\secure)
12:18:59,978 WARN ~ You're running Play! in DEV mode
12:19:00,110 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
12:19:11,680 INFO ~ Connected to jdbc:mysql://localhost/test1?useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci
12:19:14,869 INFO ~ MorphiaPlugin-1.2.4a> initialized
So, now I can't understad what version of morphia I actually use and can't understand how to fix the error.
Please, advice me something about my issue.
I got the problem, in this day morphia doesn't work with play 1.2.4 crud module. You have to rollback to 1.2.3.