Adding a second webapp

对着背影说爱祢 提交于 2019-12-25 04:52:10

问题


I am struggling to setup a public website in Moqui, I am trying to have (dev-)www.example.net as the public marketing site and signup forms. Then the tennants on [tennant-name].example.net I have setup a basic component and then edited MoquiDevConf.xml, modified the webapp-list as shown below:

<webapp-list>
    <webapp name="webpublic" http-port="8080" https-enabled="false">
        <root-screen host="dev-www.example.net" location="component://webpublic/screen/webpublic.xml"/>
    </webapp>
    <webapp name="webroot" http-port="8080" https-enabled="false">
        <root-screen host="^((?!dev-www.example.net).)*$" location="component://webroot/screen/webroot.xml"/>
    </webapp>
</webapp-list>

I have restarted the app for the changes to take effect but all I get is an error 500 when I try and visit http://dev-www.example.net:8080/

org.moqui.BaseException: Could not find root screen for host [dev-www.example.net]

As far as I can tell Moqui is finding the component as I see this in the logs:

Added component [webpublic] at [file:/Volumes/MacHDD/Sources/atlas-moqui/runtime/component/webpublic] 

Non dev-www hosts still work and I get the customary login screen so I am not sure what I am missing as this is almost a direct copy of the existing webroot?

Thanks for any help! Sam


回答1:


You probably using the same port number. Try different one (e.g. 8081) for the second one. All used ports should be different. Please see my comment as well.




回答2:


My guess about why your particular configuration is not working is that the root-screen.@host attribute is always a regular expression and the URL you are using contains special characters including '-' and '.'. It should work if you escape these characters with a '\', i.e. use '.' and '-'.

That said, if you want to support virtual hosts with the same webapp root for multiple tenants you shouldn't need to declare the virtual hosts this way, this is only needed if you want a different webapp root screen (which may be what you eventually want to do).

UPDATE: With the configuration snippet above the issue is that there are multiple webapp-list.webapp elements, one with name=webroot which is the webapp used (as specified in the web.xml file in the moqui-name context-param) and the other with name=webpublic which is ignored because the configuration is found based on the name from the web.xml file.

The solution is to put both root-screen elements under the webapp element with name=webroot. Basically the way these are looked up is not arbitrary, it is explicit for the webapp name (the moqui-name context-param). If you have multiple webapps deployed they should have different moqui-name values to refer to different configurations. This would best be done in something other that Winstone, something like Tomcat. It would also stray from the documented ways of deploying Moqui, so a bit more work would need to be done. There isn't any really point in doing this, better to run everything in the same webapp with multiple root-screen elements and multiple root screens as needed.



来源:https://stackoverflow.com/questions/28293902/adding-a-second-webapp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!