on 11-06-2020 7:29 PM
Hi. All
I'm quite familiar to hybris but newbie in spartacus.
I set up development environment for study purpose according to https://sap.github.io/spartacus-docs.
hybris : SAP Commerce Cloud 1905.8(including spartacussampledataaddon copied from b2c_acc_plus)
spartacus : ^2.1.2
Angular CLI: 10.2.0
Node: 10.15.3
yarn : 1.16.0
The build and initialization were successful. But I met the solr error caused by customercouponoccaddon not existing when server startup.
So, I fixed it refer to comments of this url.
I could test sotrefront via below url at first.
https://localhost:9002/yacceleratorstorefront/?site=electronics
But I couldn't connect storefront except for first several times.
I got "Server Error" message in browser.
console log is as below.
INFO [hybrisHTTP17] [RestHandlerExceptionResolver] Translating exception [java.lang.NullPointerException]: ERROR [hybrisHTTP17] [RestHandlerExceptionResolver] java.lang.NullPointerException at com.hybris.yprofile.consent.services.DefaultConsentService.getConsentReferenceFromHeader(DefaultConsentService.java:217) at com.hybris.yprofile.consent.services.DefaultConsentService.saveConsentReferenceInSessionAndCurrentUserModel(DefaultConsentService.java:193) at com.hybris.yprofile.consent.filters.OCCConsentLayerFilter.doFilterInternal(OCCConsentLayerFilter.java:45)
.
.
DefaultConsentService.java:217 is as below
final String headerName = getConfigurationService().getConfiguration().getString(CONSENT_REFERENCE_HEADER_NAME, StringUtils.EMPTY);
CONSENT_REFERENCE_HEADER_NAME is "profileservices.occ.consent.header.name".
I checked the Configuration Properties from HAC. The value is "x-consent-reference".
The value exists definitely, but I can't understand why this error occured.
I refered to https://sap.github.io/spartacus-docs/building-the-spartacus-storefront-from-libraries/ for spartacus build.
This is my app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
B2cStorefrontModule.withConfig({
backend: {
occ: {
baseUrl:
'https://localhost:9002',
prefix: '/rest/v2/'
},
},
context: {
urlParameters: ['baseSite', 'language', 'currency'],
baseSite: ['electronics-spa'],
currency: ['USD', 'GBP',]
},
i18n: {
resources: translations,
chunks: translationChunksConfig
}
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
The Build was successful.
But nothing happened in browser when I connect localhost:4200.
I found http status 400 error in developer tools.
It was occ api call as below. (I can get token via curl in windows CLI well)
General
Request URL: https://localhost:9002/rest/v2/electronics-spa/cms/pages?fields=DEFAULT&pageType=ContentPage&pageLab...
Request Method: GET
Status Code: 400
Remote Address: [::1]:9002
Referrer Policy: no-referrer-when-downgrade
Response Headers
Access-Control-Allow-Origin: http://localhost:4200
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: close
Content-Length: 66
Content-Type: application/json;charset=UTF-8
Date: Fri, 06 Nov 2020 19:10:04 GMT
Expires: 0
Pragma: no-cache
Strict-Transport-Security: max-age=16070400 ; includeSubDomains
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Anonymous-Consents: %5B%7B%22templateCode%22%3A%22MARKETING_NEWSLETTER%22%2C%22templateVersion%22%3A0%2C%22consentState%22%3Anull%7D%2C%7B%22templateCode%22%3A%22PROFILE%22%2C%22templateVersion%22%3A0%2C%22consentState%22%3Anull%7D%2C%7B%22templateCode%22%3A%22STORE_USER_INFORMATION%22%2C%22templateVersion%22%3A0%2C%22consentState%22%3Anull%7D%5D
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Sorry for long question.
What causes hybris NPE & spartacus occ call fail?
(It seems like that first error makes second error)
Even any little clue would be very helpful.
Thank you.
If I understand correctly, you deleted some impexes related to solr, based on https://github.com/SAP/spartacus/issues/5662.
When I set-up Spartacus with Hybris 1905 some time ago, I just included "customercouponoccaddon" in the recipe/gradle, and everything worked fine after that. Maybe you can try this approach instead?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I added customercouponoccaddon and tested again. Build completed well. Solr error was disappeard too.
But I failed in the end.
I changed hybris to 2005 and just changed baseUrl.prefix in app.module.ts to /occ/v2, then finally successed.
Perhaps I missed something important along the set up process of 1905.
Someday I'll try 1905 again. Thank you.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.