JDK-8017770 : webstart swing applications that use rmi with invokeLater are broken in u25
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 7u25
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_7
  • Submitted: 2013-06-25
  • Updated: 2016-02-16
  • Resolved: 2013-07-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7u40Resolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_25 " 
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux cawcdhplnx016.nss.vzwnet.com 2.6.32-220.4.2.el6.x86_64 #1 SMP Mon Feb 6 16:39:28 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

Windows: Version 6.1.7601

A DESCRIPTION OF THE PROBLEM :
On both Linux and Windows running 7u25, webstart applications that use RMI with SwingUtlities.invokeLater throw a NPE.

If started from the command line, the program works fine -- only fails if started via web start.
Earlier JRE versions work fine.
Fails on both Linux and Windows.

See the full stack trace below.


 java.lang.NullPointerException
        at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:1011)
        at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:1007)
        at sun.awt.SunToolkit.getSystemEventQueueImpl(SunToolkit.java:1002)
        at java.awt.Toolkit.getEventQueue(Toolkit.java:1730)
        at java.awt.EventQueue.invokeLater(EventQueue.java:1217)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See sample code below.

-Compile MainServer and Message into a jar (in this case RmiTest.jar) and place on web server.
-Launch via the attached JNLP file.
-From the command line or IDE, run MainClient

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JLabel text will update successfully.
ACTUAL -
The 'MainClint' will throw a NPE every time.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:1011)
at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:1007)
at sun.awt.SunToolkit.getSystemEventQueueImpl(SunToolkit.java:1002)
at java.awt.Toolkit.getEventQueue(Toolkit.java:1730)
at java.awt.EventQueue.invokeLater(EventQueue.java:1217)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1290)
at MainServer.sayHello(MainServer.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy0.sayHello(Unknown Source)
at MainClient.doTest(MainClient.java:18)
at MainClient.main(MainClient.java:28)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
MainServer.java:
public class MainServer extends UnicastRemoteObject implements Message {
    
    private void startServer(){
        try {
            // create on port 1099
            Registry registry = LocateRegistry.createRegistry(1099);
            
            // create a new service named myMessage
            registry.rebind( " myMessage " , this);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println( " system is ready " );
    }
    
    public static void main(String[] args) throws Exception {
    final MainServer mMain = new MainServer();
    mMain.startServer();

        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
            mMain.createAndShowGUI();
                System.out.println( " Main:  "  + this);
          }
        });}
    
    public MainServer() throws RemoteException {
    }
    
    @Override
    public void sayHello(final String name) throws RemoteException {
    final String mText =  " hello  " +name;
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                iLabel.setText(mText);
                iFrame.pack();
             
            }
        });
       System.out.println( " Text: "  + mText +  " ,  "  + this);
       
    }

    JLabel iLabel;
    JFrame iFrame;
    JPanel iPanel;
    void createAndShowGUI() {
        //Create and set up the window.
    iFrame = new JFrame( " rmi test " );
    iFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    iPanel = new JPanel();
    iFrame.add(iPanel);
        //Add the ubiquitous  " Hello World "  label.
        iLabel = new JLabel( " Hello World " );
        iPanel.add(iLabel);

        //Display the window.
        iFrame.pack();
        iFrame.setVisible(true);
    }

    
}

Message.java
public interface Message extends Remote {
    void sayHello(String name) throws RemoteException;
}


MainClient.java
public class MainClient {
    
    private void doTest(){
        try {
// fire to localhost port 1099
            Registry myRegistry = LocateRegistry.getRegistry( " cawcdhplnx016 " , 1099);

// search for myMessage service
            Message impl = (Message) myRegistry.lookup( " myMessage " );

// call server's method
            impl.sayHello( " at  "  + new Date());

            System.out.println( " Message Sent " );
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public static void main(String[] args) {
    MainClient main = new MainClient();
        main.doTest();
    }
}

JNLP file:
<?xml version= " 1.0 "  encoding= " utf-8 " ?>
<!-- JNLP File for RTT's ALU LTE -->
<jnlp
  spec= " 1.0+ " 
  codebase= " http://realtime.eng.vzwcorp.com/webstart/test/RmiTest " >
  <information>
    <title>RMI Test</title>
    <vendor>Blah</vendor>
    <homepage href= " docs/help.html " />
    <description> " RMI Test " </description>
    <description kind= " short " > " RMI Test " </description>
    <icon href= " images/Chart11.gif "  />
    <icon kind= " splash "  href= " images/Chart11.gif "  />
  </information>
  <security>
      <all-permissions/>
  </security>
  <resources>
    <j2se version= " 1.7+ "  java-vm-args= " -Xmx768m -Xss1m "  />
    <jar href= " RmiTest.jar "  main= " true "  />
  </resources>
  <application-desc main-class= " MainServer "  />
</jnlp>




---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
unknown

SUPPORT :
YES
Comments
duplicate of JDK-8019274
10-07-2013