AccessControlException loading drools class in webstart application - java

I have a webstart application that loads/evaluates drools rules. When I run the application as a standalone client, the code works fine. But when run as webstart application (Java 1.7u21), I get the following exception.
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.ClassLoader.getParent(Unknown Source)
at org.drools.rule.JavaDialectRuntimeData$PackageClassLoader.loadClass(JavaDialectRuntimeData.java:581)
at java.lang.ClassLoader.loadClass(Unknown Source)
This may be related to https://issues.jboss.org/browse/JBRULES-3540.
I have signed all the jars and in my JNLP I have all-permissions.
<security>
<all-permissions/>
</security>
Appreciate any pointers.

Provide the value for codebase as * in your jnlp file then try again.
<jnlp spec="1.0+" codebase="*" href="">
It works for me.

Related

Java Web Start Offline mode not possible with JRE 8u171

Does anyone still uses Java Web Start? Well I certanly have to.
I have an application that needs to run in online and offline mode. Online for getting updates, but the actual use case is offline.
Up to jre8u161 that worked fine. But with the current Updates 171 and 172 the application won't start in offline mode.
If I force it to offline mode with the Java Cache Viewer I get the exception:
com.sun.deploy.net.FailedDownloadException: Ressource kann nicht heruntergeladen werden. System ist offline. (Resource can not be downloaded. System is offline.)
at com.sun.deploy.cache.ResourceProviderImpl.checkUpdateAvailable(Unknown Source)
at com.sun.deploy.cache.ResourceProviderImpl.isUpdateAvailable(Unknown Source)
at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
at com.sun.deploy.model.ResourceProvider.getResource(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If I start it with javaws -offline <jnlp-file> I get the message "Anwedung im Offlinebetrieb nicht verfügbar" (Application in offline mode not available).
I created a minimal application with this jnlp-file:
<jnlp spec="7.0" codebase="<URL>" href="<jnlp-file>"
<information>
<title>Base Test</title>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<jar href="<jar-file>"/>
</resources>
<application-desc main-class="test.BaseTest"/>
</jnlp>
But this also won't start in offline mode.
What else can I do?
This is a know bug of JDK 8 171
https://bugs.openjdk.java.net/browse/JDK-8203272
This is fixed in later version of JAVA (able to launch jnlp in offline mode with java 10 )
There is no way to launch JNLP in off line mode with 8-171 java update.
FOR DESKTOP SHORTCUT LAUNCH
One of the work around would be(It is just a hack)
1. create 2 different jnlp one for java 8-171 and another for launch jnlp in offline mode for other java versions.
Create a launcher jnlp app which detect version of java on client local and launch respective jnlp.
(I am current working on it will update code when done)
USE this config in JNLP
JAVA 8 171
<offline-allowed/>
<shortcut>
<desktop/>
</shortcut>
JAVA OTHER version
`<offline-allowed/>
<shortcut online="false">
<desktop/>
</shortcut>`

Java webstart on glassfish server 4.1

I'm building an application on Glassfish 4.1. The application is a Rest API. For the client part, I have created a java JFrame class with a number of classes underlying to use the Rest API using Jaxb. Lots to do still but that's off topic.
I'm using Netbeans for the development. For testing my JFrame class, I simply run it from out of Netbeans (Select class, menu Run > Run File). I want to take it a step further though and deliver the client application by means of java webstart. I use other apps which also do this and I think it is a neat way to deliver your java gui to a client (alternatives welcome?). Maybe I'll go to a browser based solution later but that's not a goal in the near future.
Now the webstart. I have tried 2 methods:
following the java tutorials: https://docs.oracle.com/javase/tutorial/deployment/webstart/index.html
Within the project of my Rest API, I created an index.html file containing the following line:
<script>
deployJava.launchWebStartApplication("launch.jnlp")
</script>
Then the launch.jnlp:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="http://<hostname>:8080/" href="launch.jnlp" spec="1.0+">
<information>
<title>ClientTool</title>
<vendor>Bla</vendor>
<homepage href=""/>
<description>Bla</description>
<description kind="short">Bla</description>
<icon href="bla.png" kind="default"/>
<offline-allowed/>
</information>
<update check="background"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+"/>
<jar href="ClientTool.jar" main="true"/>
</resources>
<application-desc main-class="gui.ClientFrame">
</application-desc>
</jnlp>
I have deployed this, the index.html opens and starts the launch.jnlp. So far so good, but not really:
com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://<hostname>:8080/ClientTool.jar
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Makes sense because I don't have a Jar file explicitly created. I obviously need to do this, but how? Must I create a seperate project in NetBeans to create the JAR? And where to put it exactly on the glassfish host?
by creating a new project in Netbeans, type Enterprise application client.
This works really well, You get a webstart out of the box, deploy it on glassfish and you're done. Well not really, because since Java 7 21, security has been enhanced and the way Glassfish creates the webstart config, it does not work.
See following threads for this issue. It is a reported bug but nog handled since months. And the alternative to use a lower version than Java 7 21 is simply not ok imo. Version 7 cannot even be downloaded anymore.
Signed Java web start application with Glassfish 4.1 and Java7
https://java.net/jira/browse/GLASSFISH-21305
Still investigating a bit further on what is going wrong exactly, the following trace was what I found:
java.lang.SecurityException: JAR manifest codebase mismatch for http://<hostname>:8080/___JWSappclient/___app/ClientGUI/ClientGUIClient.jar
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
So apparently glassfish is doing something wrong with the codebase config.
Any thoughts please on how to get Glassfish and Java webstart to work?
Sapphron

PropertyPermission access denied in JWS launch

I new to web-start and We are using exe4j to create executable from One-jar. In-order to make a "web start version" of our application I am trying to lunch One-JAR using web start with the specified Main-Class but I am getting the following error -
java.security.AccessControlException: access denied (java.util.PropertyPermission one-jar.main-class read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at com.simontuffs.onejar.Boot.run(Boot.java:186)
at com.simontuffs.onejar.Boot.main(Boot.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
JNLP contains --
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
<information>
<title>Applet Takes Params</title>
<vendor>Protype example</vendor>
</information>
<resources>
<!-- Application Resources -->
<j2se version="1.5+"
href="http://java.sun.com/products/autodl/j2se"/>
<jar href="Application.jar" main="true" />
</resources>
<application-desc main-class="com.simontuffs.onejar.Boot">
</application-desc>
<update check="background"/>
</jnlp>
I am trying to launch a Application.jar directly and com.simontuffs.onejar.Boot is the main class specify for JAR. I am also found this link that says we can not launch One-Jar with web-start. please help.
access denied (java.util.PropertyPermission one-jar.main-class read)
A web start app. can access any property if it declares all-permissions. If it is sand-boxed, it can only access properties prefixed with jnlp & some other JRE properties that are considered 'safe'.

NullPointerException when launching web start app

After finally solving the jar signing problem (thank you everyone for your help!), a new one has now come up.
When trying to launch the web start app from the launch.jnlp file I get the following error :
java.lang.NullPointerException
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If I use the jnlp file that points to the jar file on my computer, the app runs fine, but if I try to use the jar file in the website - I get the above error.
What exactly is the problem?
The jnlp file has the right format, otherwise why would it work on my local jar file?
Here is the jnlp:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp spec="1.0+">
<information>
<title>ExcelReader</title>
<vendor>Adam</vendor>
<homepage href="http://www.appquad.com"/>
<description>ExcelReader</description>
<description kind="short">ExcelReader</description>
<offline-allowed/>
</information>
<update check="background"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+"/>
<jar href="http://www.appquad.com/ExcelCopyApp/sExcelReader.jar" main="true"/>
<jar href="http://www.appquad.com/ExcelCopyApp/lib/jxl.jar"/>
</resources>
<application-desc main-class="excelreader.ExcelCopyApp">
</application-desc>
</jnlp>
Be sure that your JNLP file has the right format: http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html
I had faced similar issue. I was getting below exception while trying to launch
app through jnlp:
java.lang.NullPointerException
at com.sun.javaws.JnlpxArgs.execProgram(Unknown Source)
at com.sun.javaws.Launcher.relaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source).
I have jdk 1.7 on my machine and any how some jar in JRE lib was missing or corrupted. I have resinstalled the JRE and it worked for me. I would suggest to figure out jar that is not getting picked up from jnlp file and relplace them and see if it works.

Java web start - Unable to load resource

I've got a jar that loads great with java web start when I browse through the IP address of the server.
Once I try the server name instead I get the following exception:
com.sun.deploy.net.FailedDownloadException: Unable to load resource:
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The wrapped exception:
java.io.FileNotFoundException:
at sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown Source)
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException:
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
... 15 more
JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp
spec="1.0+"
codebase="http://servername/Site/Views/.."
href="">
<information>
<title>title</title>
<vendor>vendor</vendor>
<description>description</description>
<description kind="short">short</description>
<icon href="../../icon.gif" />
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+" java-vm-args="-Xmx1000M -Xms150M" initial-heap-size="150M" max-heap-size="1000M" />
<j2se version="1.4.2+" href="http://java.sun.com/products/autodl/j2se" java-vm-args="-Xmx1000M -Xms150M" initial-heap-size="150M" max-heap-size="1000M" />
<jar href="/file.jar"/>
</resources>
<application-desc main-class="com....">
<argument>CD6B172DEC34924D83EA64A61A6550BE1271325929392</argument>
<argument>http://servername/file.asp</argument>
<argument>/Site</argument>
</application-desc>
</jnlp>
Any idea what should I look for?
I've changed the java proxy settings to direct connection - and it works.
Try using Janela or github to diagnose the problem.
Include your IP address in your host file (C:\Windows\System32\drivers\etc\host) for the respective server:
Sample Entry:
10.100.101.102 server1.us.vijay.com Vijay's Server
I'm not sure exactly what the problem is, but I have looked at one of my jnlp files and I have put in the full path to each of my jar files. (I have a velocity template that generates the app.jnlp file which places it in all the correct places when my maven build runs)
One thing I have seen happen is that the jnlp file is re-downloaded by the by the webstart runtime, and it uses the href attribute (which is left blank in your jnlp file) to re-download the file. I would start there, and try adding the full path into the jnlp files too...I've found webstart to be a fickle mistress!
If anyone else gets here because they're trying to set up a Jenkins slave, then you need to set the url of the host to the one it's actually using.
On the host, go to Manage Jenkins > Configure System and edit "Jenkins URL"
i got the same issue, i updated the hosts file with the server address and it worked
changing java proxy settings to direct connection did not fix my issue.
What worked for me:
Run "Configure Java" as administrator.
Go to Advanced
Scroll to bottom
Under: "Advanced Security Settings" uncheck "Use SSL 2.0 compatible ClientHello format"
Save
this also worked for me , thanks a lot
changing java proxy settings to direct connection did not fix my issue.
What worked for me:
Run "Configure Java" as administrator.
Go to Advanced
Scroll to bottom
Under: "Advanced Security Settings" uncheck "Use SSL 2.0 compatible ClientHello format"
Save
In Advance Tab -> scroll down and un-checked all options in advance security setting and try by checking one-by-one and finally app start running with one option TLS 1.1
that was the solution I got it.

Categories

Resources