Java Webstart and Servlet containers

This week there was an issue reported concerning the code that enables the download of the InteractiveClient via Java Webstart. According to the report the code was not able to find the relevant jar files.

In short some context: JnlpHelper.java retrieves information of the location of eXist and the jar files by calling ConfigurationHelper.getExistHome() which -somehow- does not always return the right value. Since we had some issues before with this class, I wanted to try something else.

According to the servlet specification the best way of retrieving the location of files in a servlet context (on server extracted from war-file) is calling getServletContext().getResource("/") ; this should return a styled URL to the toplevel directory of exist.

Unfortunately this does not work for tomcat. Tomcat does actually return a type URL which cannot be resolved to a 'real' directory. There are several reports on this subject and is for us a dead end.

The other servlets of eXist-db use another construction to get the application directory information: getServletContext().getRealPath("/") but (quote: javadoc)

The real path returned will be in a form appropriate to the computer and operating system on which the servlet container is running, including the proper path separators. This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).

There were some discussions on this a few years ago on the ML, but in the end it turns out that we do not have a real alternative than using getRealPath().

The consequence of this decision is that eXist-db cannot run in webcontainers that

  • do not expand the war files when installed
  • block access to the local filesystem. (This does not make sense anyhow, because exist does actually need to write data to 'some' file location.)

The webstart fix is now part of 1.3/trunk and 1.2.5.