1

RDF4J is an apache open source graph db that i use often on my PC.
It comes with 2 webApp : RDF4J-server and RDF4J-workbench (a user interface)
On my PC i push the 2 wars in the same Tomcat and everything is ok.
I begin an experiment to push these apps in the Bluemix Cloud (which is a cloud foundry)
The java-tomcat boilerplate wants a single War in order to associate it with the URL of the new container, so i create 2 separate apps in 2 java containers :
1 for RDF4J-Server,
1 for RDF4J-WB.
Both apps are running and i can access to default pages.
In WB, the form 'connect to server' allows you to give the URL of the server you want to work with.
I enter the URL https://rdf4jmyserver.mybluemix.net. WB finds the server but loops on the form, unable to open a db.

I suppose first that a split in 2 containers can be an issue, but i do the following test :
-run RD4J workbench in a local Tomcat on my machine
-connect to the rdf4Jmyserver on the cloud
-> Everything is ok !
So the pb is not to run in 2 separate places.

I investigate a bit more, dowload the source code (thanks open source) and recompile with more and more debug traces .

After a long day, i found the bug in the Workbench code, despite the fact this code is as old as the previous version Sesame: Nobody catch it .

Philosophy for today :
Bluemix works well, but pushing an app in the cloud can reveal old weakness !

I will give the patch in a next post.

pirela
  • 498
  • 6
  • 15

1 Answers1

1

Explanation : When the selected server by workbench is not the default one ( which is supposed to be on the same root url ), the program establish a new cookie to keep trace of the new choice.

The wrong code is here , in CookieHandler.java :

private void initCookie(final Cookie cookie, final HttpServletRequest req) {
    final String context = req.getContextPath();
     cookie.setPath(null == context ? "/" : context);
    }
}

The url is something like https://rdf4j-mywb.mybluemix.net
So, when there is no context for the cookie, the software wants to add a / .
But this code is false.

Going back to the java API, one can see :

public java.lang.String getContextPath()

Returns the portion of the request URI that indicates the context of the request.
The context path always comes first in a request URI.
The path starts with a "/" character but does not end with a "/" character.
For servlets in the default (root) context, this method returns "".
The container does not decode this string.

So this old buried bug can be fixed by :

// cookie.setPath(null == context ? "/" : context);
cookie.setPath(context.isEmpty()? "/" : context);

And now, Workbench works well on Bluemix !

HTH

PS: as rdf4Jserver runs also in a cloud container, datas on disk can disappear when container is reset. Another job has to be done : using an objectstore service in Bluemix. ( another day)

pirela
  • 498
  • 6
  • 15