ImageIO hangs when referred inside an OSGI Application Mac OS X - Java 1.7

﹥>﹥吖頭↗ 提交于 2019-12-22 10:36:11

问题


I am using Java 1.7 on Mac OS X 10.7.5 . It hangs the moment execution touches any ImageIO API.

import javax.imageio.ImageIO;

import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;

public class ImageMain implements IApplication {

    @Override
    public Object start(IApplicationContext context) throws Exception {

        ImageIO.getCacheDirectory();

         return IApplication.EXIT_OK; 
    }

    @Override
    public void stop() {
        // TODO Auto-generated method stub

    }

}

jstack output :

013-12-03 11:37:57 Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode):

"Attach Listener" daemon prio=5 tid=0x00007fbada8c5000 nid=0x8a23 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Worker-JM" prio=5 tid=0x00007fbadb941000 nid=0x6007 in Object.wait() [0x0000000116ee6000]
   java.lang.Thread.State: WAITING (on object monitor)
  at java.lang.Object.wait(Native Method)
  - waiting on <0x00000007f85bf428> (a java.util.ArrayList)
  at org.eclipse.core.internal.jobs.InternalWorker.run(InternalWorker.java:58)
  - locked <0x00000007f85bf428> (a java.util.ArrayList)

"Start Level Event Dispatcher" daemon prio=5 tid=0x00007fbadb92c800 nid=0x5d03 in Object.wait()

[0x0000000115bbf000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000007f96b2838> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread) at java.lang.Object.wait(Object.java:503) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:400) - locked <0x00000007f96b2838> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:336)

"State Saver" prio=5 tid=0x00007fbadb895800 nid=0x5b03 in Object.wait() [0x0000000115ab7000]
   java.lang.Thread.State: RUNNABLE
  at sun.awt.AppContext$2.run(AppContext.java:271)
  at sun.awt.AppContext$2.run(AppContext.java:260)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.awt.AppContext.initMainAppContext(AppContext.java:260)
  at sun.awt.AppContext.access$200(AppContext.java:133)
  at sun.awt.AppContext$3.run(AppContext.java:314)
  at sun.awt.AppContext$3.run(AppContext.java:298)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.awt.AppContext.getAppContext(AppContext.java:297)
  at sun.awt.AppContext$6.getContext(AppContext.java:841)
  at sun.misc.SharedSecrets.getJavaAWTAccess(SharedSecrets.java:200)
  at java.util.TimeZone.getDefaultInAppContext(TimeZone.java:730)
  at java.util.TimeZone.getDefaultRef(TimeZone.java:620)
  at java.util.Date.normalize(Date.java:1193)
  at java.util.Date.toString(Date.java:1027)
  at java.util.Properties.store0(Properties.java:823)
  at java.util.Properties.store(Properties.java:812)
  at org.eclipse.osgi.storagemanager.StorageManager.save(StorageManager.java:551)
  at org.eclipse.osgi.storagemanager.StorageManager.update(StorageManager.java:310)
  at org.eclipse.osgi.storagemanager.StorageManager.closeOutputStream(StorageManager.java:903)
  at org.eclipse.osgi.storagemanager.ManagedOutputStream.close(ManagedOutputStream.java:52)
  at java.io.FilterOutputStream.close(FilterOutputStream.java:160)
  at java.io.FilterOutputStream.close(FilterOutputStream.java:160)
  at org.eclipse.osgi.internal.baseadaptor.BaseStorage.saveBundleDatas(BaseStorage.java:598)
  at org.eclipse.osgi.internal.baseadaptor.BaseStorage.saveAllData(BaseStorage.java:461)
  at org.eclipse.osgi.internal.baseadaptor.BaseStorage$StateSaver.run(BaseStorage.java:1306)
  - locked <0x00000007f96b8c48> (a org.eclipse.osgi.internal.resolver.SystemState)
  at java.lang.Thread.run(Thread.java:724)

"Framework Event Dispatcher" daemon prio=5 tid=0x00007fbadb948000 nid=0x5903 in Object.wait() [0x00000001159b6000]
   java.lang.Thread.State: WAITING (on object monitor)
  at java.lang.Object.wait(Native Method)
  - waiting on <0x00000007f96b2520> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
  at java.lang.Object.wait(Object.java:503)
  at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:400)
  - locked <0x00000007f96b2520> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
  at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:336)

"State Data Manager" daemon prio=5 tid=0x00007fbadb828000 nid=0x5703 waiting for monitor entry [0x00000001158b3000]
   java.lang.Thread.State: BLOCKED (on object monitor)
  at org.eclipse.osgi.internal.baseadaptor.StateManager.run(StateManager.java:303)
  - waiting to lock <0x00000007f96b8c48> (a org.eclipse.osgi.internal.resolver.SystemState)
  at java.lang.Thread.run(Thread.java:724)

"Framework Active Thread" prio=5 tid=0x00007fbadb05b800 nid=0x5503 in Object.wait() [0x00000001157b0000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
  at java.lang.Object.wait(Native Method)
  - waiting on <0x00000007f96b7310> (a org.eclipse.osgi.framework.internal.core.Framework)
  at org.eclipse.osgi.framework.internal.core.Framework.run(Framework.java:1862)
  - locked <0x00000007f96b7310> (a org.eclipse.osgi.framework.internal.core.Framework)
  at java.lang.Thread.run(Thread.java:724)

"Service Thread" daemon prio=5 tid=0x00007fbad9806000 nid=0x4f03 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=5 tid=0x00007fbadc001800 nid=0x4d03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=5 tid=0x00007fbadb829800 nid=0x4b03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"JDWP Command Reader" daemon prio=5 tid=0x00007fbadd002000 nid=0x4903 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"JDWP Event Helper Thread" daemon prio=5 tid=0x00007fbadd000000 nid=0x4703 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"JDWP Transport Listener: dt_socket" daemon prio=5 tid=0x00007fbadb828800 nid=0x4503 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=5 tid=0x00007fbadb81a000 nid=0x4303 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=5 tid=0x00007fbadb803000 nid=0x3a03 in Object.wait() [0x0000000114b56000]
   java.lang.Thread.State: WAITING (on object monitor)
  at java.lang.Object.wait(Native Method)
  - waiting on <0x00000007f96e30b0> (a java.lang.ref.ReferenceQueue$Lock)
  at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
  - locked <0x00000007f96e30b0> (a java.lang.ref.ReferenceQueue$Lock)
  at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
  at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:189)

"Reference Handler" daemon prio=5 tid=0x00007fbadb800800 nid=0x3803 in Object.wait() [0x0000000114a53000]
   java.lang.Thread.State: WAITING (on object monitor)
  at java.lang.Object.wait(Native Method)
  - waiting on <0x00000007f96e2af8> (a java.lang.ref.Reference$Lock)
  at java.lang.Object.wait(Object.java:503)
  at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
  - locked <0x00000007f96e2af8> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x00007fbad9041000 nid=0x707 runnable [0x00007fff6ccd1000]
   java.lang.Thread.State: RUNNABLE
  at java.lang.ClassLoader$NativeLibrary.load(Native Method)
  at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
  - locked <0x00000007f96e20e0> (a java.util.Vector)
  - locked <0x00000007f96a0ad8> (a java.util.Vector)
  at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1843)
  at java.lang.Runtime.load0(Runtime.java:795)
  - locked <0x00000007f9727830> (a java.lang.Runtime)
  at java.lang.System.load(System.java:1061)
  at java.lang.ClassLoader$NativeLibrary.load(Native Method)
  at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
  - locked <0x00000007f96e20e0> (a java.util.Vector)
  - locked <0x00000007f96a0ad8> (a java.util.Vector)
  at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
  at java.lang.Runtime.loadLibrary0(Runtime.java:849)
  - locked <0x00000007f9727830> (a java.lang.Runtime)
  at java.lang.System.loadLibrary(System.java:1087)
  at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
  at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.awt.Toolkit.loadLibraries(Toolkit.java:1646)
  at java.awt.Toolkit.<clinit>(Toolkit.java:1668)
  at sun.awt.AppContext$2.run(AppContext.java:271)
  at sun.awt.AppContext$2.run(AppContext.java:260)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.awt.AppContext.initMainAppContext(AppContext.java:260)
  at sun.awt.AppContext.access$200(AppContext.java:133)
  at sun.awt.AppContext$3.run(AppContext.java:314)
  at sun.awt.AppContext$3.run(AppContext.java:298)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.awt.AppContext.getAppContext(AppContext.java:297)
  at javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:154)
  at javax.imageio.ImageIO.<clinit>(ImageIO.java:65)
  at com.sap.ImageTest.ImageMain.start(ImageMain.java:13)
  at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
  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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
  at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
  at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
  at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

"VM Thread" prio=5 tid=0x00007fbad908e000 nid=0x3603 runnable 

"GC task thread#0 (ParallelGC)" prio=5 tid=0x00007fbad904d000 nid=0x2603 runnable 

"GC task thread#1 (ParallelGC)" prio=5 tid=0x00007fbad904d800 nid=0x2803 runnable 

"GC task thread#2 (ParallelGC)" prio=5 tid=0x00007fbad904e000 nid=0x2a03 runnable 

"GC task thread#3 (ParallelGC)" prio=5 tid=0x00007fbad904e800 nid=0x2c03 runnable 

"GC task thread#4 (ParallelGC)" prio=5 tid=0x00007fbad904f800 nid=0x2e03 runnable 

"GC task thread#5 (ParallelGC)" prio=5 tid=0x00007fbad9050000 nid=0x3003 runnable 

"GC task thread#6 (ParallelGC)" prio=5 tid=0x00007fbad9050800 nid=0x3203 runnable 

"GC task thread#7 (ParallelGC)" prio=5 tid=0x00007fbad9051000 nid=0x3403 runnable 

"VM Periodic Task Thread" prio=5 tid=0x00007fbada801000 nid=0x5103 waiting on condition 

JNI global references: 2810

回答1:


indeed Oracle has an issue on this but not related to ISGI but to the Mac JRE: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8019496 You may try to add this to you launch configuration. -Djava.awt.headless=true




回答2:


It appears to be a bug only on Mac OS X.
I had the same problem on a Mac and switching to a PC (Java 1.7) solved the problem.

In my code I am using

File file = new File( "my/path" );
ImageIO.read( file ); // <-- Hangs here
System.out.println( "Never logged" );


来源:https://stackoverflow.com/questions/20330807/imageio-hangs-when-referred-inside-an-osgi-application-mac-os-x-java-1-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!