This discussion is archived
1 2 3 Previous Next 31 Replies Latest reply: Jul 10, 2013 2:26 AM by StefanSt RSS

Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out

8874cfa5-7e3c-4291-84b4-538137096d40 Newbie
Currently Being Moderated

Since Java 7 update 25, I have an issue where my client Java application, downloaded with Java Web Start, can no longer connect to a remote server. (The client uses remote EJB to connect various servers). The issue I believe is that the client application is being blocked by security features of this Java update.

 

A very quick (random?) fix around the problem is to show the Java console. If the Java console is enabled to be shown, the client application can connect fine.


Although showing the Java console is a quick fix, it's not one we particularly want to keep asking customers to do. I understand we may need to define the Codebase and Permissions in the manifest file as described here: http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/no_redeploy.html..

 

I have defined the Codebase and Permissions in the manifest of the client jar's we build ourselves. I believe this has worked as we no longer see "Missing Codebase manifest attribute for...." in the console for our own jar's. However, the application still cannot connect out. I'm stumbling around somewhat on this issue and trying various things in an attempt to get this to work. Assuming i'm on the right lines and the problem is some jars missing the Codebase and Permissions in their manifests, my question is, should I and how can I modify the manifest of 3rd party jars to include this information? For example, the client app requires many JBoss and EJB client jars - do I need to somehow modify the manifest of all of these jars to include the codebase and permissions?

 

It goes without saying that all the jars are signed - the application would not start at all if there was a problem here. So the application starts with it's login box - but it simply cannot connect out to the servers.

 

If anybody can offer any help on this issue i'd be most grateful. As a quick fix, is there a way to get this to work via adjusting Control Panel settings (other than showing the console)? I have played with a lot but not stumbled on a way to get this to work other than showing the console, although ideally i'd like to be able to get this to work without having to do any tweaks to clients Java control panel.

  • 1. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    theskad81 Newbie
    Currently Being Moderated

    Have similar problem: client-server application (swing-spring+hibernate). application crashes unless "Show console" is selected in control panel in Windows XP -- seems to be working on OSX with jdk7u25.

     

    So far it seem like classloader or service provider problem:

    - application consist of three jar files with (problem related classes):

    -- common.jar

    --- interface Context

    --- class ContextProvider with getContext() static method (find below)

    -- client.jar

    --- class ClientContext implements Context

    -- server.jar

    --- class ServerContext implements Context

     

    ContextProvider#getContexts does following

            final ServiceLoader<ILightContext> serviceLoader = ServiceLoader.load(ILightContext.class);

        final Iterator<ILightContext> it = serviceLoader.iterator();

        if (!it.hasNext()) { /** this is a problematic part! */

            throw new IllegalStateException("No light context registered. Check /META-INF/services/" + ILightContext.class.getName());

        }

     

    Problem's that there's NO implementing class.

     

    Classloader of ContextProvider (common.jar) and Main (client.jar) seems to be same...

     

    My 5 cents... will post solution when I get lucky...

     

    Cheerio,
    Adam

     

    PS: already tried Class.forName("FullnameOfClientContextClass") to no avail :-(

  • 2. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    43ada953-7d96-4e66-baad-a2503c385770 Newbie
    Currently Being Moderated

    It's hard to tell if my solution fits your problem, but here goes. My JWS application started having ClassNotFoundException problems after 7u25 update. The problem was that the AWT thread had a different class loader than the main thread. I solved this by:

     

    Thread.currentThread().setContextClassLoader(SomeClassLoadedByJWS.class.getClassLoader());

     

    inside and at the beginning of the AWT-thread's life. You might use SwingUtilities.invokeAndWait. In my case, I knew when the first AWT-thread action was occurring in my application, so it was easy.

     

    The apparent issue is that JWS sets the thread context class loader differently if you start the AWT-thread than if it (JWS) starts the AWT-thread when the Java console is showing. Maybe something about the delay. IMO, this is a JWS bug.

     

    This old link helped me out: Unofficial Java Web Start/JNLP FAQ

     

    Hope this helps.

    -Philip

  • 3. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    theskad81 Newbie
    Currently Being Moderated

    So far:

    1. Java SeviceLoader#load(Class) just delegates call to ServiceLoader#load(Class, ClassLoader) using following { return this.load(clazz, Thread.currentThread().getContextClassLoader()); }
    2. there are two class loaders present in web started app:
      • com.sun.jnlp.JNLPLoader
      • sun.misc.Launcher.AppClassLoader
    3. When running WITHOUT console
      • AWT Thread has AppClassLoader set as #contextClassLoader while
      • Main thread has JNLPLoader
    4. When running WITH console both share same JNLPLoader

     

    From my point of view:

    1. actual bug is use of JNLPLoader when using console
    2. you should NOT use ServiceLoader in AWT dispatch thread OR use two parameter construct with e.g. (naive solution) Main.class.getClassLoader() as second parameter

     

    I've tried #2 in our app and it SEEMs to be working even without console -- with slight problems with  ResourceBundle (localized strings are not displayed).

  • 4. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    theskad81 Newbie
    Currently Being Moderated

    VERY UGLY and very temporary solution: try calling following (below) as soon as possible in your application e.g. at the first line of main method.

     

        private static void quickAndDirtyFixForProblemWithWebStartInJava7u25() {

            if (!"1.7.0_25".equals(System.getProperty("java.version"))) {

                return ;

            }

          

            final ClassLoader cl = Thread.currentThread().getContextClassLoader();

            try {

                SwingUtilities.invokeAndWait(new Runnable() {

                    @Override

                    public void run() {

                        try {

                            // Change context in all future threads

                            final Field field = EventQueue.class.getDeclaredField("classLoader");

                            field.setAccessible(true);

                            final EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();

                            field.set(eq, cl);

                            // Change context in this thread

                            Thread.currentThread().setContextClassLoader(cl);

                        } catch (Exception ex) {

                            // Call to java logging causes NPE :-( ...

                            ex.printStackTrace(System.err);

                            System.err.println("Unable to apply 'fix' for java 1.7u25");

                        }

                    }

                });

            } catch (Exception ex) {

                // Same as serr above

                ex.printStackTrace(System.err);

                System.err.println("Unable to apply 'fix' for java 1.7u25");

            }

        }

     

    Message was edited by: theskad81

    - replaced reference to "Main" class by Thread->currentThread->contextClassLoader as mentioned in comment below

    - added code that set contextClassLoader for current thread

  • 5. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    jeffb Newbie
    Currently Being Moderated

    I can confirm that this hack solves problems I was seeing, including null java.util.logging root logger, errors setting look and feel, and class loading problems in general.  It is better than than the 'Show console' hack we've used the last few days.

     

    To expand on your description in case it's helpful to anyone, the EventDispatch thread that runs for the Web Start app seems to use the ClassLoader reference from the Web Start launcher instead of a separate one for the application being launched.  This would actually seem to be a security problem.

     

    Before the hack, I get the following output at runtime regardless of 'Show console' setting.

      Current thread's ClassLoader is: com.sun.jnlp.JNLPClassLoader

      AppContext named javawsApplicationThreadGroup's ClassLoader is sun.misc.Launcher$AppClassLoader

      AppContext named javawsSecurityThreadGroup's ClassLoader is com.sun.jnlp.JNLPClassLoader

      AppContext named main's ClassLoader is com.sun.jnlp.JNLPClassLoader

      My app's EventDispatch thread ClassLoader is: sun.misc.Launcher$AppClassLoader


    In other words, EventDispatchThread that runs for your Web Start app has the ClassLoader from javawsApplicationThreadGroup and doesn't get the correct ClassLoader for the AppContext it is running in.  The hack above (thanks very much by the way) corrects it to have the one for your own application class loaded by Web Start.


    Also in case it's helpful to anyone else, where it says Main.class.getClassLoader() in the code posted above, that should just be the containing class name that holds this whole quickAndDirtyFix... method.

  • 6. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    443897bc-1b7e-44af-bcba-3a7349f320f5 Newbie
    Currently Being Moderated

    As far as I can see, problems resulting from this j7u25 classloader change are reproducible only on Windows, not on OS X. Anyone made any experiences on Linux? So would it make sense to add an operating system switch to the if statement (System.getProperty("os.name") …)? And, yes, thanks for this workaround!

  • 7. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    theskad81 Newbie
    Currently Being Moderated

    Apple fixed the problem according to this: FIXED! 1.6.0_51 in Java 1.6.0_51 OS X 2013-004 &amp;amp; 10.6 Update 16 -- e.g. our app works flawlessly under osx

  • 8. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    StephanosPiperoglou Newbie
    Currently Being Moderated

    Very helpful stuff here guys, some things:

     

    I have found that apps launched using the 7u25 Java Web Start but running under a Java 6 JRE (i.e. one is enabled in the Java control panel and the JNLP prefers it) will show the same symptoms regardless of whether the console is visible. In fact we developers have been completely unable to reproduce the bug otherwise; this is very helpful for debugging but it also means renders the fix above (thanks a ton by the way!) will not work; this can be remedied by changing the check on the first line to:

     

    if (!"javaws-10.25.2.16".equals(System.getProperty("javawebstart.version"))) {

     

    This will apply the fix whenever you're running under java web start 10.25.2.16 (the version that came with 7u25) regardless of the actual JRE being used.

     

    1) Has anybody written a simple, self-contained example test case that demonstrates the issue? (I have, sort of, trying to trim it down further)

    2) Has anybody filed a bug report with Oracle?

     

    I'm willing to do both if nobody else has - just trying to avoid duplication

     

    Also, see this thread for another symptom of what looks to be the same root cause: https://forums.oracle.com/thread/2552214

  • 9. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    StephanosPiperoglou Newbie
    Currently Being Moderated

    I have submitted a bug report to oracle under ID 9004450 though it isn't showing up yet. Source code for the test case:

     

    package com.piperoglou.webstartlaftest;

     

     

    import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;

    import java.awt.BorderLayout;

    import java.awt.Container;

    import javax.swing.JFrame;

    import javax.swing.JTextArea;

    import javax.swing.SwingUtilities;

    import javax.swing.UIManager;

    import javax.swing.WindowConstants;

     

     

    public class WebStartLookAndFeelTestHarness {

     

     

        public static void main(String[] args) {

            SwingUtilities.invokeLater(new Runnable() {

                @Override

                public void run() {

                    try {

                        System.out.println("Classloader: " + Thread.currentThread().getContextClassLoader());

                        UIManager.setLookAndFeel("com.piperoglou.webstartlaftest.WebStartLookAndFeelTestHarness$MyLookAndFeel");

                    } catch (Exception e) {

                        e.printStackTrace();

                    }

     

     

                    JTextArea textArea = new JTextArea("The quick brown fox jumped over the lazy dog. How rude.", 50, 10);

                    textArea.setLineWrap(true);

                    textArea.setWrapStyleWord(true);

     

     

                    JFrame frame = new JFrame("Java Web Start Look & Feel Test");

                    frame.setBounds(50, 50, 200, 200);

                    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

     

     

                    Container contentPane = frame.getContentPane();

                    contentPane.setLayout(new BorderLayout());

                    contentPane.add(textArea, BorderLayout.CENTER);

     

     

                    frame.setVisible(true);

                }

            });

        }

     

     

        public static class MyLookAndFeel extends WindowsLookAndFeel {

            private static final long serialVersionUID = -7686127811595151510L;

        }

     

     

    }

  • 10. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    6f07a7ac-dcbe-4613-af18-1fdba7cbcf52 Newbie
    Currently Being Moderated

    We're also seeing this. The 7u25 update completely derailed a trial program we were conducting, because no one could log in to our application via WebStart once they upgraded Java.

     

    Our login code crashes because SwingUtilities.isEventDispatchThread() throws an NPE.

     

    We tried theskad81's fix but it didn't work for us. We worked around the issue by hosting u21 on our site and pointing our WebStart page there instead of at Oracle's update site.

     

    *** ORACLE: PLEASE FIX THIS ISSUE USING APPLE'S FIX (mentioned in an earlier post - see above) ***

     

    Slightly edited stack trace:

         javax.security.auth.login.LoginException: java.lang.NullPointerException

        at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)

        at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)

        at sun.awt.SunToolkit.getSystemEventQueueImpl(Unknown Source)

        at java.awt.Toolkit.getEventQueue(Unknown Source)

        at java.awt.EventQueue.isDispatchThread(Unknown Source)

        at javax.swing.SwingUtilities.isEventDispatchThread(Unknown Source)

        at com.abc.ConsoleAuthUI.handle(ConsoleAuthUI.java:43)

        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 sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)

        at sun.rmi.transport.Transport$1.run(Unknown Source)

        at sun.rmi.transport.Transport$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at sun.rmi.transport.Transport.serviceCall(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.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)

        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)

        at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)

        at sun.rmi.server.UnicastRef.invoke(Unknown Source)

        at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)

        at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)

        at com.sun.proxy.$Proxy1.handle(Unknown Source)

        at com.abc.ms.rmi.MsLogin$1.handle(MsLogin.java:100)

        at javax.security.auth.login.LoginContext$SecureCallbackHandler$1.run(Unknown Source)

        at javax.security.auth.login.LoginContext$SecureCallbackHandler$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at javax.security.auth.login.LoginContext$SecureCallbackHandler.handle(Unknown Source)

        at com.abc.ms.auth.abcLoginModule.login(abcLoginModule.java:35)

        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 javax.security.auth.login.LoginContext.invoke(Unknown Source)

        at javax.security.auth.login.LoginContext.access$000(Unknown Source)

        at javax.security.auth.login.LoginContext$4.run(Unknown Source)

        at javax.security.auth.login.LoginContext$4.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at javax.security.auth.login.LoginContext.invokePriv(Unknown Source)

        at javax.security.auth.login.LoginContext.login(Unknown Source)

        at com.abc.ms.rmi.MsLogin.authenticate(MsLogin.java:111)

        at com.abc.ms.rmi.MsLogin.login(MsLogin.java:92)

        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 sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)

        at sun.rmi.transport.Transport$1.run(Unknown Source)

        at sun.rmi.transport.Transport$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at sun.rmi.transport.Transport.serviceCall(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.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)

        at javax.security.auth.login.LoginContext.invoke(Unknown Source)

        at javax.security.auth.login.LoginContext.access$000(Unknown Source)

        at javax.security.auth.login.LoginContext$4.run(Unknown Source)

        at javax.security.auth.login.LoginContext$4.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at javax.security.auth.login.LoginContext.invokePriv(Unknown Source)

        at javax.security.auth.login.LoginContext.login(Unknown Source)

        at com.abc.ms.rmi.MsLogin.authenticate(MsLogin.java:111)

        at com.abc.ms.rmi.MsLogin.login(MsLogin.java:92)

        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 sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)

        at sun.rmi.transport.Transport$1.run(Unknown Source)

        at sun.rmi.transport.Transport$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at sun.rmi.transport.Transport.serviceCall(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)

        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.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)

        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)

        at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)

        at sun.rmi.server.UnicastRef.invoke(Unknown Source)

        at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)

        at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)

        at com.sun.proxy.$Proxy0.login(Unknown Source)

        at com.abc.abc.ui.console.Main.attemptLogin(Main.java:488)

        at com.abc.abc.ui.console.LoginDialog$7.run(LoginDialog.java:182)

        at com.abc.util.GrayTimer$GrayTimerTaskWrapper.run(GrayTimer.java:84)

        at java.util.TimerThread.mainLoop(Unknown Source)

        at java.util.TimerThread.run(Unknown Source)

  • 11. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    thomasng Newbie
    Currently Being Moderated

    I tried your test and it seems to work fine with 7u25 webstart and there is no exception.   Can you provide more details on how to reproduce the bug please ?

  • 12. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    DejanH Newbie
    Currently Being Moderated

    Hello.

     

    Can you please explain how you created, added, defined Codebase and Permissions attribute in the manifest file (in jar file).


    We have many custom jar, such as keyfilter.jar, calendar.jar, ...

    But we don't know how to do it.

    Our java console returns:

    Missing Permissions manifest attribute for: http://hostname:port/forms/java/keyfilter.jar

    Missing Codebase manifest attribute for: http://hostname:port/forms/java/keyfilter.jar

     

    Thanks.

     

    Regards,

    Dejan

  • 13. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    StephanosPiperoglou Newbie
    Currently Being Moderated

    The only way to consistently reproduce the error is:

     

    - Install Java 6 (any version really)

    - Install Java 7u25

    - Run the example above under Java 6 (either by disabling the Java 6 runtime in the control panel or by forcing Java 6 from the JNLP descriptor)

     

    You'll get a UIDefaults.getUI() failed error.

     

    This also happens to some users with only 7u25, but I haven't been able to determine what the specific condition is that triggers it and why it doesn't happen for everyone; we have two machines here with 7u25, one exhibits the problem and the other doesn't and I haven't been able to determine any differences in the setup of the two. Any insight here would be very much appreciated. For these cases, enabling the Java Console in the control panel fixes the issue, so make sure the console is disabled before you try it.

  • 14. Re: Java 7 Update 25 Client App Downloaded From Web Start Can't Connect Out
    foch Newbie
    Currently Being Moderated

    Hello Stephanos,

    can you please provide us with the link to the bug report, so I can follow it up?

    Thanks!!!

1 2 3 Previous Next