How to use java.sql.Timestamp in RMI with Java 11 + Openwebstart

611 Views Asked by At

Setup: Windows 10 openjdk-11.0.5+10 Openwebstart 1.0.0

We have an Java Swing Client connected via RMI to an Backendserver. The Client is distributed via JNLP.

When we starting the Client all works fine until the Client gets an java.sql.Timestamp over RMI and wants it to deserialize. Then we get the following Exception:

Caused by: exceptions.unchecked.communication.ClientLoginException: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
    java.lang.ClassNotFoundException: java.sql.Timestamp    
 at client.LoginHandler.login(LoginHandler.java:134)     
 at code.MainClient.lambda$0(MainClient.java:317)    
 at com.github.rholder.retry.AttemptTimeLimiters$NoAttemptTimeLimit.call(AttemptTimeLimiters.java:78)    
 at com.github.rholder.retry.Retryer.call(Retryer.java:160)     ... 41 more 

Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:  
   java.lang.ClassNotFoundException: java.sql.Timestamp     
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:194)    
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:209)     
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:161)     
at com.sun.proxy.$Proxy14.login(Unknown Source)    
 at client.LoginHandler.login(LoginHandler.java:128)     ... 44 more 

Caused by: java.lang.ClassNotFoundException: java.sql.Timestamp     
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)     
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)     
at java.rmi/sun.rmi.server.LoaderHandler$Loader.loadClass(LoaderHandler.java:1207)    
 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)    
 at java.base/java.lang.Class.forName0(Native Method)    
 at java.base/java.lang.Class.forName(Class.java:398)     
at java.rmi/sun.rmi.server.LoaderHandler.loadClassForName(LoaderHandler.java:1221) 

Our JNLP looks like that:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp
spec="1.0+"
codebase="http://192.168..."
href="Intranet.jnlp">
<security>
<all-permissions/>
</security>
<information>
<offline-allowed/>
</information>
<resources>
<j2se version="1.8.0_25+" href="http://java.sun.com/products/autodl/j2se" java-vm-args="-XX:+UseParallelGC -XX:+CMSClassUnloadingEnabled -Xincgc -Xnoclassgc -Xms64m -Xmx1024m"/>
<property name="sun.java2d.transaccel" value="true" />
<property name="sun.java2d.noddraw" value="true" />
<property name="java.util.Arrays.useLegacyMergeSort" value="true" />
<jar href="lib/intranet-client-ei-0.0.1-SNAPSHOT.jar"/>
<!--....-->
</resources>
<application-desc main-class="xdev.Application">
<argument>-application.type=webstart</argument>
<argument>-main=start.Main</argument>
<argument>-mode</argument>
<argument>ei</argument>
</application-desc>
</jnlp>

then we added the following

<j2se  version="1.8.0_25+" href="http://java.sun.com/products/autodl/j2se" java-vm-args="-XX:+UseParallelGC -XX:+CMSClassUnloadingEnabled -Xincgc -Xnoclassgc -Xms64m -Xmx1024m 
--add-modules=ALL-SYSTEM,java.base,java.rmi,java.sql
--add-exports=java.base/sun.security.action=ALL-UNNAMED
--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED,java.base,java.sql
--add-exports=java.sql/java.sql=ALL-UNNAMED,java.base,java.rmi
"/>

but that doesn't work.

When we start the client from terminal (with -classpath ./lib/*) than all works fine. So the Code works with Java 11 but OpenWebstart doesn't run it in Classpathmode.

Has anyone an Idea?

1

There are 1 best solutions below

0
On

Can you please use the following definition:

<j2se version="1.8.*" .../>

By using * instead of + you do not allow a newer version than 1.8. Maybe you have problems by running your app with Java11.