Hybris: Cannot Find CMSSite Associated with Current URL

I created a new Hybris extension using one of the predefined templates.
The build was successful, and I can also start the server.

But when I open a web link from the HAC, I get the error message "Cannot find the CMSSite associated with the current URL . "

Are there any suggestions for solving or investigating this problem?

+7
source share
4 answers

You need to use host file associations or use the site identifier parameter to avoid a 500 error.

enter image description here

Please follow this link.

https://wiki.hybris.com/display/accdoc/Just+One+Storefront

https://help.hybris.com/6.3.0/hcd/8ae0711f86691014877ae05249b2f5ac.html (Hybris 6)

If you have administrator rights, it is recommended that you add the following entries to the host file.

127.0.0.1 hybris.local [Example]

Modifying the host etc allows the accelerator to identify sites (CMSSites) from a URL. This makes the URL clean and clean.

After changing the host file, you can access a site like this

http: //hybris.local: 9001 / yacceleratorstorefront /

If you do not, the sites must be identified with an additional query parameter like this

http: // localhost: 9001 / yacceleratorstorefront /? site = hybris & clear = true

+16
source

In addition to the host entry, be sure to add the appropriate regular expression for your site.

A CMS site has the urlPatterns attribute. This is a list of regular expressions that match the website's CMS filters to determine which storefront the user is trying to access.

The easiest way is to add another regular expression to the CMS site, as shown below:

 (?i)^https?://[^/]*/yacceleratorstorefront((?![\?\&]site=).)* 

At run time, you can do this in the Hybris Management Console (hMC). Click the WCMS tab on the Site Properties tab and change the URL Patterns section.

To make the change permanent, add the appropriate code to the installation of the CMS site. ImpEx script is executed during the initialization phase of the project, for example. for electronics store

 # CMS Site UPDATE CMSSite;uid[unique=true];urlPatterns; ;electronics;(?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=electronics)(|\&.*)$,(?i)^https?://electronics\.[^/]+(|/.*|\?.*)$,(?i)^https?://api\.hybrisdev\.com(:[\d]+)?/rest.*$,(?i)^https?://[^/]*/yacceleratorstorefront((?![\?\&]site=).)*; 
+2
source

The error "Cannot find CMSSite associated with the current URL."

This is because you are not telling Hybris which site you want to access.

There are three ways to do this.

  1. Just pass your siteID as the request parameter (? Site = SiteID) in your first request, which helps Hybris understand which site you are trying to access. Suppose I'm trying to access the powertools site, then the URL will be https: // localhost: 9002 / yacceleratorstorefront? Site = powertools

  2. Access the site using siteID as the DNS name. You can create host 127.0.0.1 using <siteID>.local . Suppose I want to access powertools (this is the CMSSite identifier for powertools), then add an entry like 127.0.0.1 powertools.local host file and then go to your site using http: //powertools.local: 9001 / yacceleratorstorefront / local

  3. Add the new regular expression of your choice in the urlPatterns of your CMSSite. So that you can access your site as you wish. Suppose I want to access the site only at the local URL and without transfer? Site = powertools. So I need to add a new regular expression like (?i)^https?://[^/].*$ UrlPatterns from powertools CMSSite. Now I can directly open the powertools website using https: // localhost: 9002 / yacceleratorstorefront /

You can do this with Impex as well

 $siteUid=mysite # CMS Site INSERT_UPDATE CMSSite ; uid[unique=true] ; urlPatterns ; ; $siteUid ; (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$,(?i)^https?://$siteUid\.[^/]+(|/.*|\?.*)$,(?i)^https?://[^/].*$ ; 

Find a detailed answer here

+2
source

This problem usually occurs if the server was started with unsatisfied bean dependencies. Please check your server’s startup log to confirm which specific component or components failed to initialize.

0
source

Source: https://habr.com/ru/post/985863/


All Articles