Hi,
I done a small application with Javafx that start an Embedded Jetty. All works fine in Windows also with native package. Instead in Mac it works only before native packaging. Seems that the problem is how relative path are considered.
The tree of the content is this:
myfile.jar
webapp (folder)
libs (folder)
Look at this code:
String webAppDir = "webapp";
File f = new File(webAppDir);
log.debug("Path webapp folder: " + f.getAbsolutePath());
if (!f.exists())
throw new Exception("The folder " + f.getAbsolutePath() + " doesn't exist");
if (!f.canRead())
WebAppContext context = new WebAppContext();
context.setContextPath("/myapp");
context.setResourceBase("webapp");
context.setDescriptor("WEB-INF" + File.separator + "web.xml");
context.setSessionHandler(new SessionHandler(sessionManager));
throw new Exception("The folder " + f.getAbsolutePath() + " is not readable");
The problem is that before the packaging in Mac the relative path is that where the main .jar is located an so the code works because the webapp folder is found. Instead after the bundle the path became /Users/MyUser/webapp and of course the folder is not found because it is bundled inside the file.app near the libs folder.
I post this question on JavaFx forum but nobody answered so I don't understand if it is a bug or it is a desiderable behaviour.
Thanks
I done a small application with Javafx that start an Embedded Jetty. All works fine in Windows also with native package. Instead in Mac it works only before native packaging. Seems that the problem is how relative path are considered.
The tree of the content is this:
myfile.jar
webapp (folder)
libs (folder)
Look at this code:
String webAppDir = "webapp";
File f = new File(webAppDir);
log.debug("Path webapp folder: " + f.getAbsolutePath());
if (!f.exists())
throw new Exception("The folder " + f.getAbsolutePath() + " doesn't exist");
if (!f.canRead())
WebAppContext context = new WebAppContext();
context.setContextPath("/myapp");
context.setResourceBase("webapp");
context.setDescriptor("WEB-INF" + File.separator + "web.xml");
context.setSessionHandler(new SessionHandler(sessionManager));
throw new Exception("The folder " + f.getAbsolutePath() + " is not readable");
The problem is that before the packaging in Mac the relative path is that where the main .jar is located an so the code works because the webapp folder is found. Instead after the bundle the path became /Users/MyUser/webapp and of course the folder is not found because it is bundled inside the file.app near the libs folder.
I post this question on JavaFx forum but nobody answered so I don't understand if it is a bug or it is a desiderable behaviour.
Thanks
- duplicates
-
JDK-8094300 [packager] Working directory for Mac OS bundles is always home directory, not app directory
- Resolved