发生的原因
我的版本是mac eclipse neon,运行期间非正常退出,再次打开相同的workspace时,卡在启动界面的loading org.eclipse.egit.core,反复启动都无法跳过这里。
解决
查看eclipse启动日志
首先尝试打开其他workspace,能够正常启动。这说明启动不了跟workspace有关系。
eclipse在每个workspace目录下都有.metadata的目录,该目录记录该workspace的一些信息,在mac上或是linux上,以点开头的文件是隐藏文件,在finder文件浏览窗口中默认是看不到的,我们可以用终端来查看
ls -al
total 5008
drwxr-xr-x 9 user staff 306 10 26 16:27 .
drwxr-xr-x 33 user staff 1122 11 2 18:10 ..
-rw-r--r-- 1 user staff 1048061 10 26 16:27 .bak_0.log
-rw-r--r-- 1 user staff 1026991 10 15 17:37 .bak_1.log
-rw-r--r-- 1 user staff 0 7 20 16:23 .lock
-rw-r--r-- 1 user staff 479823 11 2 18:12 .log
drwxr-xr-x 4 user staff 136 7 20 16:24 .mylyn
drwxr-xr-x 66 user staff 2244 9 4 20:05 .plugins
-rw-r--r-- 1 user staff 99 11 2 18:11 version.ini
这个目录下存放着启动日志,在.metadata/.log,cat一下发现,错误如下:
!ENTRY org.eclipse.osgi 2 0 2016-11-02 18:12:30.996
!MESSAGE While loading class "org.eclipse.egit.core.internal.CoreText", thread "Thread[Worker-5,5,main]" timed out waiting (5002ms) for thread "Thread[main,6,main]" to finish starting bundle "org.eclipse.egit.core_4.4.0.201606070830-r [271]". To avoid deadlock, thread "Thread[Worker-5,5,main]" is proceeding but "org.eclipse.egit.core.internal.CoreText" may not be fully initialized.
!STACK 0
org.osgi.framework.BundleException: Unable to acquire the state change lock for the module: osgi.identity; type="osgi.bundle"; version:Version="4.4.0.201606070830-r"; osgi.identity="org.eclipse.egit.core"; singleton:="true" [id=271] STARTED [STARTED]
at org.eclipse.osgi.container.Module.lockStateChange(Module.java:337)
at org.eclipse.osgi.container.Module.start(Module.java:401)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:470)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:529)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:325)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:334)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:411)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.egit.core.internal.util.ResourceUtil$MappingJob.<init>(ResourceUtil.java:211)
at org.eclipse.egit.core.internal.util.ResourceUtil$MappingJob.<clinit>(ResourceUtil.java:190)
at org.eclipse.egit.core.internal.util.ResourceUtil.isSharedWithGit(ResourceUtil.java:163)
at org.eclipse.egit.core.project.GitProjectData$2.visit(GitProjectData.java:306)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:64)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:75)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:48)
at org.eclipse.egit.core.project.GitProjectData.update(GitProjectData.java:295)
at org.eclipse.egit.core.project.GitProjectData$RCL.resourceChanged(GitProjectData.java:97)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:289)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:152)
at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:374)
at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1469)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2253)
at org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.util.concurrent.TimeoutException: Timeout after waiting 5 seconds to acquire the lock.
at org.eclipse.osgi.container.Module.lockStateChange(Module.java:334)
... 29 more
Root exception:
java.util.concurrent.TimeoutException: Timeout after waiting 5 seconds to acquire the lock.
at org.eclipse.osgi.container.Module.lockStateChange(Module.java:334)
at org.eclipse.osgi.container.Module.start(Module.java:401)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:470)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:529)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:325)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:334)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:411)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.egit.core.internal.util.ResourceUtil$MappingJob.<init>(ResourceUtil.java:211)
at org.eclipse.egit.core.internal.util.ResourceUtil$MappingJob.<clinit>(ResourceUtil.java:190)
at org.eclipse.egit.core.internal.util.ResourceUtil.isSharedWithGit(ResourceUtil.java:163)
at org.eclipse.egit.core.project.GitProjectData$2.visit(GitProjectData.java:306)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:64)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:75)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:48)
at org.eclipse.egit.core.project.GitProjectData.update(GitProjectData.java:295)
at org.eclipse.egit.core.project.GitProjectData$RCL.resourceChanged(GitProjectData.java:97)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:289)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:152)
at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:374)
at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1469)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2253)
at org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
看错误描述,貌似是获取某个lock的时候出错了。刚好,该目录下有个.lock文件,抱着试一试的心态删了它,结果问题解决了~