Details
-
Bug
-
Resolution: Fixed
-
Critical
-
7.4.2
-
None
-
Unknown
-
N/A
-
N/A
-
Description
I am trying to generate an external URL from a groovy code (Job Script) using the following code:
def url = xwiki.getXWiki().getExternalURL("Space.Page", "view", "param1=xxx¶m2=yyy", xcontext);
The problem is that sometimes in the generated URL, the domain name of the wiki that executed the code is 'localhost'
As you can see in the example bellow:
The generated url is :
http://localhost:8080/xwiki/bin/view/Space/Page?param1=xxx¶m2=yyy
instead of
http://myDomainName/xwiki/bin/view/Space/Page?param1=xxx¶m2=yyy
Unscheduling and scheduling again the job fix the problem.
-------------------------------------------------------------------------------------------------------------------------------------------------
below, a discussion started on IRC about this problem
Vvmassol (IRC)
maybe check your main wiki descriptor
see what domain you've put thereCcjd (IRC)
Is it Apache/AJP/Tomcat or Jetty ?Mmouhb
JettyCcjd (IRC)
I seem to recall there being a place to set the hostname of the server in the xwiki.cfgCClemensR (IRC)
Job script is a background job, it has to get the information from the config, as it has no current request to guess the domain nameCcjd (IRC)
but also as Vincent said, the wiki descriptor (which I take it to mean XWiki.XWikiServerXwiki) might be involvedVvmassol (IRC)
it's xwiki.home ClemensR
if defined, it's used to generate the external url
(on the main wiki)
if not defined, then the descriptor is usedEEnygma` (IRC)
vmassol: the problem M-mouhb1 is having is when sending an email. When the mail sending job generates the external URL, probably the context is not properly initialized and the context URL (the one used by the XWikiServletURLFactory#getHost when initializing the factory)Vvmassol (IRC)
indeed
we use a stub context
and it's likely it's localhost used thenEEnygma` (IRC)
now indeed, the xwiki.home parameter from xwiki.cfg is taking precedence to the context URL and to the XWikiServer defined alias
so that would be a solution
Thu 17:28
Options
the order of initializing the server now seems to be: proxy host > xwiki.home > contextURL; Once initialized, on each call if the context wiki is the same as the requested document's wiki, the initialized server is returned. If not, only then the XWikiServer descriptor is checked for the main wiki or for a subwiki to see what is defined there.
so we either change the lookup order to prioritize the wiki descriptor or we work on the context initialization and say initialize it with the external URL of the main wiki's homepage
I see that the mail sender uses the current context and it passes it to the mail prepare thread so maybe it`s actually the scheduler's fault that the scheduler context is not setting the correct URL
Attachments
Issue Links
- relates to
-
XWIKI-13963 Stop relying on the application server by default to resolve relative redirect URLs
- Closed