How to use Openjfx in a webstart application using OpenWebStart - java

We are migrating a Java 1.8 JavaFX/Webstart application to Java 11 using Openjfx (https://openjfx.io) and OpenWebStart (https://openwebstart.com).
We successfully migrate and run the app to JavaFx-14 (OpenJfx). To run it at the IDE now it is necessary to include the following jvm args:
--module-path 'path/javafx-sdk-11.0.2/lib' --add-modules javafx.controls,javafx.fxml
We build the App using Maven. It beautifully works on Java 1.8. It signs all jars, create the package and the jnlp file. Maven also creates an "uber jar" with all dependencies included. We migrated the POM including the new deps. We tested it by manually running the App using the uber jar file via command line (using the --module-path parameters).
We included the --module-path argument in .jnlp file:
<?xml version="1.0" encoding="utf-8"?>
<jnlp
spec="1.0+"
codebase="http://localhost:8080/download/"
href="myapp.jnlp">
<information>
<title>MyApp</title>
<vendor>Myself</vendor>
<homepage href="http://localhost:8080"/>
<description>My App</description>
<description>Migration test</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="11"
initial-heap-size="256m"
max-heap-size="2048m"
java-vm-args="-Xms256m -Xmx4096m -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=25 --module-path '/Users/chocksmith/Desktop/javafx-sdk-11.0.2/lib' --add-modules javafx.controls,javafx.fxml"/>
<jar href="myapp-5.0.0.jar"/>
</resources>
<application-desc main-class="com.mycompany.myproduct.application.App"/>
</jnlp>
Unfortunately it fails:
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:670)
We run out of ideas here. Please advise!

OpenWebStart now provides several points about running JavaFX based application in an FAQ: https://github.com/karakun/OpenWebStart/blob/master/documentation/faq/FAQ.adoc
If this does not help please open an issue at https://github.com/karakun/OpenWebStart/issues

FX must be bundled in the JDK on the client side.
We manage to make it work with Zulo Community version 13.29.11
https://www.azul.com/downloads/zulu-community/?architecture=x86-64-bit&package=jdk-fx
Use "OpenWebStart Settings.app" application to configure the right JVM on your system.

Related

How do I get my application to run with Java WebStart

I have been trying to figure this out on and off for a couple of weeks now and today I spent a considerable amount of time with an old professor at UTD and we still were not able to figure it out.
I have an application I've been working on that I would like to deploy as a WebStart application. I have tried doing this Self Signed and Unsigned and get different errors for both.
Right now I'm just trying to get the application to launch locally on my machine (Running latest MacOS).
I have updated my JDK to 11.0.2. Tried different configurations with signed and unsigned certificates. Tried adding the application .jar and .jnlp files to the Site Exception List in Java Console (as well as other random things to see if any error changed, which it didn't.)
Occasionally I would see that activation.jar (for JavaBeans Activation Framework from Oracle) that I have added as a dependency would come up saying that the application was being blocked because the certificate had expired. But I haven't been able to recreate this in most of the configurations I've been trying recently. I have gone through as many of the even relatively close questions posted on here and none of them have gotten me any closer to a resolution.
JNLP file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/Users/Thomas/OneDrive/MSVO/dist/" href="launch.jnlp" spec="1.0+">
<information>
<title>MSVO</title>
<vendor>Thomas</vendor>
<homepage href=""/>
<description>MSVO</description>
<description kind="short">MSVO</description>
<icon href="splash_screen.jpg" kind="splash"/>
</information>
<update check="always"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="11+"/>
<jar href="MSVO.jar" main="true"/>
<jar href="lib/commons-io-2.6.jar"/>
<jar href="lib/joda-time-2.10.1.jar"/>
<jar href="lib/mail.jar"/>
<jar href="lib/mysql-connector-java-8.0.15.jar"/>
<jar href="lib/smtp-1.4.4.jar"/>
<jar href="lib/swingx-all-1.6.4.jar"/>
<jar href="lib/AbsoluteLayout.jar"/>
<extension href="jnlpcomponent1.jnlp"/>
</resources>
<application-desc main-class="Controller.MSVO_controller">
</application-desc>
For Unsigned I get the following exception:
java.lang.UnsupportedClassVersionError: Controller/MSVO_controller has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
When I run it as Self Signed I get:
Let me know if you need any other information and I will gladly update this.
Not sure where to go from here.

Windows 7, JDK 1.8, Spring Boot application JAR takes up lot of time for method Security.getProviders() to return

I am executing a Spring Boot application which takes up lot of time to create a SSL context.
Initial debugging points to method Security.getProviders() not returning the list of providers for around 8 minutes.
Provider[] providers = Security.getProviders();
This happens when I execute the JAR using below command on command prompt. But it does not take time when executed as Java Application via Eclipse of STS.
"Command to run Application"
java -DkeystoreFile=<Certificate File Name> -DkeystorePassword=<Password> -jar aws-sqs-consumer-0.0.1-SNAPSHOT.jar <QueueName> localhost false <proxy IP> <proxy Port>
Maven Pom.xml, uses spring boot maven plugin to build the application:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

My java web start application only starts when verbose is set

I have a java web start application, that I try to start via
javaws.exe https://localhost:8888/myApplication/myApplication.jnlp
nothing happens (no error message; I see no process starting in the task list).
If I start it via
javaws.exe -verbose https://localhost:8888/myApplication/myApplication.jnlp
the application starts.
I can also start the application when using
javaws.exe -viewer https://localhost:8888/myApplication/myApplication.jnlp
and then starting the application from the java cache viewer.
What is the difference, that might trigger the application to run, when in verbose mode or via the viewer? Here is my jnlp file:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="https://localhost:8888/myApplication" href="myApplication.jnlp">
<information>
....
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.8.0_60+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="500m" initial-heap-size="250m"/>
<!-- some jars are referenced -->
<property name="sun.java2d.d3d" value="false" />
</resources>
<resources os="Windows">
<nativelib href="mylib.jar" download="eager" />
</resources>
<application-desc main-class="myClass">
<argument>-initLogging</argument>
<argument>SETPROPERTYjavax.net.ssl.trustStore</argument>
<argument>_UNDEFINED_</argument>
<argument>SETPROPERTYjavax.net.ssl.trustStoreType</argument>
<argument>_UNDEFINED_</argument>
<argument>SETPROPERTYjavax.net.ssl.trustStorePassword</argument>
<argument>_UNDEFINED_</argument>
<argument>-locale</argument>
<argument>_UNDEFINED_</argument>
<argument>-serviceHost</argument>
<argument>_UNDEFINED_</argument>
<argument>-serviceProtocol</argument>
<argument>_UNDEFINED_</argument>
<argument>-servicePort</argument>
<argument>_UNDEFINED_</argument>
<argument>-trustStrategy</argument>
<argument>_UNDEFINED_</argument>
</application-desc>
</jnlp>
I activated the trace and log output and found an Exception occured:
java.io.FileNotFoundException: C:\ProgramData\Oracle\Java\java.settings.cfg (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileReader.<init>(FileReader.java:72)
at com.sun.deploy.config.WinPlatform.readSystemConfig(Unknown Source)
at com.sun.deploy.config.WinPlatform.getSponsorOffersDisabledSettings(Unknown Source)
at com.sun.deploy.config.ClientConfig.getSponsorOffersDisabledSettings(Unknown Source)
at com.sun.deploy.panel.AdvancedProperties.saveSponsorOfferingSettings(Unknown Source)
at com.sun.deploy.panel.ControlPanel.apply(Unknown Source)
at com.sun.deploy.panel.ControlPanel.<init>(Unknown Source)
at com.sun.deploy.panel.ControlPanel.main(Unknown Source)
at com.sun.javaws.Main.launchJavaControlPanel(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)
Then I found this page:
https://bugs.openjdk.java.net/browse/JDK-8134475
When I activate the java browser content (Java Control Panel > Security Tab > select checkbox "Enable content for browser and Web Start application").
Then the application started...
But the problem is: I do not know why!
I had the problem, too (see my comment My java web start application only starts when verbose is set)
I solved this problem by updating Java, i.e. reinstalling Java. The file C:\ProgramData\Oracle\Java\java.settings.cfg was created again and this new java installation could open web start applications again correctly. Although older versions still had the same bug.
After an update of Java with Java 9 I need to "Enable Applets and Web Start in the browser" in the security tab of the Java control panel.

What is needed to configure Jetty to run Spring MVC application?

I am working on Spring MVC web-abblication and I need it to work on Jetty server (Jetty should be Servlet Cobtainer).
I addded Jetty server to my app by "Edit run configuration".
Edit Run Config
Here are application server settings:
App server settings
But, when I launch my application IDEA gives me this:
"C:\Program Files\Java\jdk1.8.0_65\bin\java" -DSTOP.PORT=0 -Dcom.sun.management.jmxremote= -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -DOPTIONS=jmx -Didea.launcher.port=7535 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0.4\bin" -Dfile.encoding=windows-1251 -classpath "D:\jetty-distribution-9.3.7.v20160115\start.jar;C:\Program Files\Java\jdk1.8.0_65\lib\tools.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.eclipse.jetty.start.Main --module=jmx C:\Windows\Temp\context4config\jetty-contexts.xml
[2016-03-03 07:17:55,511] Artifact DVDExchange:war exploded: Server is not connected. Deploy is not available.
Detected server http port: 8080
java.nio.file.AccessDeniedException: C:\Windows\Temp\context4config\jetty-contexts.xml
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:90)
at sun.nio.fs.WindowsLinkSupport.getRealPath(WindowsLinkSupport.java:259)
at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:836)
at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:44)
at org.eclipse.jetty.start.FS.toRealPath(FS.java:165)
at org.eclipse.jetty.start.StartArgs.addUniqueXmlFile(StartArgs.java:217)
at org.eclipse.jetty.start.StartArgs.resolveExtraXmls(StartArgs.java:1123)
at org.eclipse.jetty.start.Main.processCommandLine(Main.java:342)
at org.eclipse.jetty.start.Main.main(Main.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Usage: java -jar start.jar [options] [properties] [configs]
java -jar start.jar --help # for more information
Disconnected from server
Process finished with exit code -9
Maybe one of the reasons is epmpty jetty-web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
</Configure>
But actually how Should I make jetty work with Spring web-app in proper way.
Could someone give complete list if things I have to do. Well structured and detailed tutorial would the best answer. I really need to handle that jetty.
Thanks in advance!
This question would suffice your needs,
Debug web app in IntelliJ, webapp built by maven, run by jetty
You need to add the embedded maven-jetty plugin to your pom.xml and run the maven goals to start the jetty server, mvn jetty:run
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<contextPath>/</contextPath>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<!--<port>8085</port>-->
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<stopKey>stop</stopKey>
<stopPort>8089</stopPort>
</configuration>
</plugin>
</plugins>
</build>

Run Renjin Java-API on Wildfly 9

i'm trying to run R Renjin Script Engine on Wildfly 9.
When i run my Java/Renjin Application, which works fine on local execution, by using it on Wildfly as EJB-Project i get the error:
Caused by: java.lang.RuntimeException: Renjin Script Engine not found on the classpath.
I had already add an module (JBOSS_HOME\modules\system\layers\base\org\renjin\renjin-script-engine\main) with the jar file (renjin-script-engine-0.7.0-RC7-jar-with-dependencies.jar) and the
module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.renjin.renjin-script-engine">
<resources>
<resource-root path="renjin-script-engine-0.7.0-RC7-jar-with-dependencies.jar"/>
</resources>
</module>
Do i need to add the R home-directory to JBoss java.class.path get run Renjin and how can i add that path(R_HOME) to JBoss' java classpath?
I had the same issue. I solve it by moving the API from lib of the java EJB project to superordinate EAR project. So you do not need to create a module on your wildfly server.

Categories