Hybris: cannot find CMSSite associated with current URL
Asked Answered
R

4

9

I created a new Hybris extension using one of the given templates.
The build was successful and I am able to start the server, too.

But when opening the weblink from the HAC I get the error "Cannot find CMSSite associated with current URL".

Are there suggestions to solve or investigate this issue?

Renown answered 24/4, 2015 at 9:43 Comment(0)
S
20

You need to use hosts file mappings or use the site-ID parameter to avoid a 500 error.

enter image description here

Please follow these 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 a good idea to add the following entries in your host file.

127.0.0.1 hybris.local [Example]

The etc hosts modification allows the accelerator to identify sites (CMSSites) from the url. This makes the URL neat and clean.

After host file change, You can access the site like this

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

If you don't do this, the sites would need to be identified with an additional request parameter like this

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

Snowblind answered 24/4, 2015 at 13:10 Comment(0)
G
7

Error "Cannot find CMSSite associated with current URL".

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

There are three ways to do that

  1. Simply pass your siteID as a request parameter(?site=SiteID) in your first request which helps the Hybris to understand which site you are trying to access. Let's say I'm trying to access powertools site then URL would be https://localhost:9002/yacceleratorstorefront?site=powertools

  2. Access site with siteID as DNS name. You can make 127.0.0.1 host with <siteID>.local. Let's say I want to access a powertools (It's CMSSite id for powertools), then add an entry like 127.0.0.1 powertools.local in your host file and then access your site using http://powertools.local:9001/yacceleratorstorefront/ instead of localhost

  3. Add a new regular expression of your choice in the urlPatterns of your CMSSite. So that you can access your site as you want. Let's say I want to access site using localhost URL only and without passing ?site=powertools ever. So I need to add a new regex like (?i)^https?://[^/].*$ to urlPatterns of powertools CMSSite. Now I can directly open powertools site using https://localhost:9002/yacceleratorstorefront/

You can do that using 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 the detailed answer here

Galloot answered 11/4, 2018 at 5:24 Comment(0)
I
3

In addition to the host entry, make sure to add the appropriate regular expression for your website.

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

The simplest thing is to add a further regular expression to the CMS site like the one below:

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

At run time, you can can do it in the hybris Management Console(hMC). Navigate to WCMS Website Your Site Name Properties tab and edit URL Patterns section.

To make the change permanent, add the appropriate code to the CMS site setup ImpEx script run during the project data phase of initialization e.g. for electronics storefront

# 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=).)*;
Inextricable answered 25/3, 2016 at 14:25 Comment(0)
M
1

This issue usually comes up if the server was started with unsatisfied spring bean dependencies. Please check your server startup log to confirm which particular bean or beans failed to initialise.

Matisse answered 20/2, 2019 at 10:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.