Skip to content
This repository was archived by the owner on Mar 16, 2021. It is now read-only.
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Some exist demo apps do not work using docker #8

Open

Description

@rogerwalt

Demo Apps do not work in Docker Image

E.g. the XForms examples.

Steps to reproduce

  • Run the docker image, tag exist-db:eXist-3.6.1 using the command as documented in the readme docker run -it -p 9080:8080 -p 9443:8443 evolvedbinary/exist-db:eXist-3.6.1
  • Log in as admin (use the login to monitoring, login on dashboard does not work in exist when run natively either)
    image
  • Go to Package Manager
  • Install DemoApps
    image
  • Open the Demo Apps and navigate to XForms and RestXQ
  • First error: There is no example data shown here. In the container:
    image as opposed to when installed natively:
    image
    Also one can not add a new address (similar error).

Analysis

The error can be found when looking at the network requests. The request to http://localhost:9080/exist/Flux/call/plaincall/Flux.init.dwr contains an error:

        contextInfo: {
            targetName: "submission",
            targetId: "load",
            "response-body": "",
            "resource-uri": "http://localhost:9080/exist/restxq/address",
            "response-reason-phrase": "java.net.ConnectException: Connection refused (Connection refused)",
            "location-path": "/",
            "error-type": "resource-error",
            "response-status-code": NaN
        },

Dump

throw 'allowScriptTagRemoting is false.';
(function(){
var r=window.dwr._[0];
//#DWR-INSERT
//#DWR-REPLY
r.handleCallback("1","0",[{bubbles:true,cancelable:false,contextInfo:{defaultinfo:null,targetName:"model",targetId:"C1"},currentTarget:null,eventPhase:1,propertyNames:["defaultinfo","targetName","targetId"],target:null,timeStamp:1517300468711,type:"xforms-model-construct"},{bubbles:true,cancelable:false,contextInfo:{defaultinfo:null,targetName:"model",targetId:"C1"},currentTarget:null,eventPhase:1,propertyNames:["defaultinfo","targetName","targetId"],target:null,timeStamp:1517300468724,type:"xforms-model-construct-done"},{bubbles:true,cancelable:false,contextInfo:{defaultinfo:null,targetName:"model",targetId:"C1"},currentTarget:null,eventPhase:1,propertyNames:["defaultinfo","targetName","targetId"],target:null,timeStamp:1517300468733,type:"xforms-ready"},{bubbles:true,cancelable:false,contextInfo:{targetName:"submission",targetId:"load","response-body":"","resource-uri":"http://localhost:9080/exist/restxq/address","response-reason-phrase":"java.net.ConnectException: Connection refused (Connection refused)","location-path":"/","error-type":"resource-error","response-status-code":NaN},currentTarget:null,eventPhase:1,propertyNames:["targetName","targetId","response-body","resource-uri","response-reason-phrase","location-path","error-type","response-status-code"],target:null,timeStamp:1517300468772,type:"xforms-submit-error"}]);
})();

Activity

  1. Sincopy commented on Jan 30, 2018

    @Sincopy
    Contributor

    It's a betterForm issue, or at least it's present in the betterForm Demo and Reference XForms module as well.
    Where did you get that contextInfo from? If it's server-side context, betterForm should not be querying for data at localhost:9080, but rather 127.0.0.1:8080. If it's browser-side, then it's probably OK.

    Can you follow up from on this?

    btw. For me the /restxq/address RestXQ endpoint works as expected when queried directly.

  2. rogerwalt commented on Jan 30, 2018

    @rogerwalt
    Author

    @Sincopy The JSON I posted (the dump) is the response the client receives from the server. I captured it using the Chrome Developer Tools (Network Tab, Response). The contextInfo is in there, but you only find it when pretty printing it.
    image
    image
    http://localhost:9080/exist/restxq/address works for me as well:
    image

    As you mentioned, the port on the serverside should be 8080, since the container internally provides exist on port 8080. Either the demos should probably be modified, or the container should be used on port 8080 (e.g. maybe change the readme accordingly).

    I verified that it works correctly when the exposed port is changed to 8080.

    What do you suggest?

  3. Sincopy commented on Jan 30, 2018

    @Sincopy
    Contributor

    First: the one way I can get it to work (without touching the code) is to access the demo directly via:
    http://localhost:9080/exist/apps/demo/examples/xforms/demo.html?restxq=http://127.0.0.1:8080/exist/restxq/

    They way I see it, you are probably facing three problems:
    a) betterForms resolves relative paths in the outside context. It seems to be getting information from the browser-side that data is located at the IP:port where the client sees it, rather that where the data/service resides. Since betterForm is (mainly?) a server-side solution, this is perhaps a bit unexpected, though it might be by design.
    This means you'd have to provide it with the right context from eXistDB, which is exactly what the controller.xql does, but only as far as paths go. It doesn't 'fix' the server/port issue.

    b) eXistDB is unable to provide the local hostname and port either. At least I couldn't find a proper function in the request library module. The request:get-server-name and get-server-port return localhost:9080, which is exactly what you don't want in this case. I'd say this is by design as most applications will need the outside context from these functions.

    c) 'localhost' is not resolved to an IP address inside the container because this works;
    http://localhost:9080/exist/apps/demo/examples/xforms/demo.html?restxq=http://127.0.0.1:8080/exist/restxq/
    and this doesn't:
    http://localhost:9080/exist/apps/demo/examples/xforms/demo.html?restxq=http://localhost:8080/exist/restxq/
    I guess this is due to /etc/hosts being empty (default on the distroless image being used) and I can't get the --add-host docker option to change that.

  4. rogerwalt commented on Jan 30, 2018

    @rogerwalt
    Author

    My gut tells me that controller.xql should use a config in where the host (incl. name and port) can be changed. We could then inject that into the container using an environment variable.

    Or (but this isn't a fix): We change the default exposed port on the host to 8080 and mention that if it is changed, that demo stuff with betterForms doesn't work, and why.

  5. Sincopy commented on Jan 30, 2018

    @Sincopy
    Contributor

    It will work, simply if you can get this address and port (known by jetty) into the controller.xql:
    image
    so that it provides:
    http://localhost:9080/exist/apps/demo/examples/xforms/demo.html?restxq=http://172.17.0.2:8080/exist/restxq/

    It's also only a fix for this one example. It doesn't fix the betterForm demos (ie. FeatureExplorer)

  6. adamretter commented on Feb 14, 2018

    @adamretter
    Member

    We will be removing betterForm in the near furture, so I will likely wait for that to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions