Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user.dir should point to a directory owned by the user executring the application #361

Closed
elbosso opened this issue Nov 27, 2020 · 5 comments
Assignees

Comments

@elbosso
Copy link

elbosso commented Nov 27, 2020

When an application is started via openwebstart, the SystemProperty "user.dir" should point to a directory owned by the user who initiated that applications execution - or at least in a directory where said user has read/write privileges.

Some applications assume this and try to create files in the current working directory - one notable example being JasperReports:

net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error saving expressions class file: /opt/OpenWebStart/sQLshell__generated__design_1606490862466_624354.java.
        at net.sf.jasperreports.engine.design.JRAbstractCompiler.getSourceFile(JRAbstractCompiler.java:325)
        at net.sf.jasperreports.engine.design.JRAbstractCompiler.createCompileUnit(JRAbstractCompiler.java:291)
        at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:179)
        at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:357)
        at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:617)
        at de.netsysit.util.jasper.Utilities.generateReport(Utilities.java:364)
        at de.netsysit.util.jasper.ReportPreviewer.run(ReportPreviewer.java:78)
        at de.netsysit.util.threads.Synchronizer.run(Synchronizer.java:19)
        at de.netsysit.util.threads.ThreadManagerHelper.run(ThreadManagerHelper.java:43)
Caused by: net.sf.jasperreports.engine.JRException: Error saving expressions class file: /opt/OpenWebStart/sQLshell__generated__design_1606490862466_624354.java.
        at net.sf.jasperreports.engine.util.JRSaver.saveClassSource(JRSaver.java:174)
        at net.sf.jasperreports.engine.design.JRAbstractCompiler.getSourceFile(JRAbstractCompiler.java:321)
        ... 8 more
Caused by: java.io.FileNotFoundException: /opt/OpenWebStart/sQLshell__generated__design_1606490862466_624354.java (Permission denied)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:187)
        at java.base/java.io.FileWriter.<init>(FileWriter.java:96)
        at net.sf.jasperreports.engine.util.JRSaver.saveClassSource(JRSaver.java:166)
        ... 9 more

This problem (and many similar ones) would disappear if the SystemProperty "user.dir" would be set as mentioned above

@sclassen
Copy link
Member

sclassen commented Dec 3, 2020

According to the Oracle Java spec
The user.dir points to the location the application was called from (i.e. the current working directory).
Thus it may or may not be writable by the user.
The question is what the current working directory is for an application which was launched by double clicking a shortcut or by opening a link in a web browser...

But in any case it is not a good practice to make any assumptions about the current working dir

@elbosso
Copy link
Author

elbosso commented Dec 5, 2020

Well, ok lets say the oracle spec is a bit unclear on this point. However: user.dir is the current working dir and at times where webstart came from sun, oracle an later on icedtea it always was the users home directory. It is not that uncommon to expect a java desktop application - and webstart apps are exactly that from a users perspective - to start with a current working dir that belongs to the user executing it. The obvious suspect in that case being that users home directory.

Believe me - I came not here to get lectured about good programming practice. I came here because I thought I found a way to prolong the life of java applications that bet on webstart. When i stumbled onto OpenWebstart i naturally assumed it would try and behave like the original webstart as a drop in replacement - if that is not the case, please state so clearly on the Website and the github readme!

@FelixJongleur42
Copy link

I agree with you from the compatibility perspective. Regardless on how useful „user.dir“ is, OWS should try and mimic Oracles behavior as closely as possible.

@Jamila891 Jamila891 assigned janakmulani and unassigned sclassen Dec 10, 2020
@janakmulani
Copy link
Contributor

Some observations on Windows:

Oracle JWS : Dbl-Clk On JNLP : user.dir = dir in which JNLP is contained.
Oracle JWS : Rt-Clk Open with On JNLP : user.dir = c:\windows\system32
Oracle JWS : From commandline >javaws : user.dir = current dir when javaws command was invoked

OWS : All of above cases : user.dir = OWS installation dir where OWS javaws.exe is contained.

Thanks for pointing this out.

We will discuss and create an issue to track internally - either to fix or to document.

@sclassen
Copy link
Member

fixed in 1.3.2

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

No branches or pull requests

5 participants