Java Web Start NetBeans Bug? - java

I am trying to make a Java Web Start application using the Web Start tool in NetBeans 8.0. I followed the directions from NetBeans, but I get the following exception:
java.lang.NumberFormatException: For input string: "\Users\maxerdwien\Desktop\ConverterPrj\ConverterPrj\dist"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
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(Thread.java:745)
This problem is a closed bug of NetBeans and has been discussed on Stack Overflow, but I am using Java 7 update 65. I suspect that the reason it worked for Tomas Zezula (who closed the bug) is that he did not set the project configuration to 'Web Start'. This step is not stated in the NetBeans tutorial, but without it NetBeans will bypass the jnlp entirely and just run the jar.
The program works when run from the jar directly.
I have determined that the 'input string' is not coming from the codebase property in the jnlp; I suspect it is coming from the manifest.
Any advice on how to fix this within NetBeans or outside it would be very appreciated.
Edit: Here is the generated jnlp:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/Users/maxerdwien/Desktop/ConverterPrj/ConverterPrj/dist/" href="launch.jnlp" spec="1.0+">
<information>
<title>ConverterPrj</title>
<vendor>maxerdwien</vendor>
<homepage href=""/>
<description>ConverterPrj</description>
<description kind="short">ConverterPrj</description>
<offline-allowed/>
</information>
<update check="background"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+"/>
<jar href="ConverterPrj.jar" main="true"/>
</resources>
<application-desc main-class="Converter">
</application-desc>
Edit: And here is the report from JaNeLA:
JaNeLA Report - version 11.05.17
Report for file:/C:/Users/maxerdwien/Desktop/ConverterPrj/ConverterPrj/dist/launch.jnlp
Content type application/xml does not equal expected type of application/x-java-jnlp-file
cvc-complex-type.2.4.a: Invalid content was found starting with element 'security'. One of '{resources, application-desc, applet-desc, component-desc, installer-desc}' is expected.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'security'. One of '{resources, application-desc, applet-desc, component-desc, installer-desc}' is expected.
XML encoding not known, but declared as UTF-8
Downloads can be optimized by specifying a resource size for 'ConverterPrj.jar'.
The resource download at ConverterPrj.jar can be optimized by removing the (default) value of download='eager'.
Lazy downloads might not work as expected for ConverterPrj.jar unless the download 'part' is specified.

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

Unable to launch the applications

Hi, I have a java swing application, I want to start it via jnlp, I configured my project web start configuration but when I push the launch button doesn't work. Do you know why?
Here is the error
Java.lang.NumberFormatException: For input string: "\Users\Administrator\Documents\NetBeansProjects\LoginPage\dist"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
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)
With just this error we can only tell you that your problem is happening because of a parseInt on a String that is not an int.
To correct this you have two possibilities :
add try{}catch(NumberFormatException e){//show error}
Assert that you have the proper things into parseInt ;)
I have the same issue.
Netbeans 8.01, JDK 1.8u20, JRE project,
Run option:
'run as webstart' enabled.
Application/Webstart options:
Created Certificates Keystore (Tip: i used 'portecle' )
Codebase: Local execution (by which the preview shows: 'file:/C:/..../')
The JNLP which is created by the project says;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/<snip>/dist/" href="launch.jnlp" spec="1.0+">
<information>
<title>netbeans_prj</title>
<vendor>bla</vendor>
<homepage href=""/>
<description>netbeans_prj</description>
<description kind="short">netbeans_prj</description>
<offline-allowed/>
</information>
<update check="background"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se java-vm-args="-Xmx512m -Xverify:none" version="1.7+"/>
<jar href="netbeans_prj.jar" main="true"/>
<jar href="lib/all_ext.jar"/>
</resources>
<application-desc main-class="<snip>">
<argument>-h</argument>
<argument>127.0.0.1</argument>
</application-desc>
</jnlp>

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