Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 67753

Summary: ClassNotFoundException while shutting down a self-hosted session
Product: [Eclipse Project] JDT Reporter: Douglas Pollock <douglas.pollock>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andre_weinand, deboer, pascal, philippe_mulet
Version: 3.0   
Target Milestone: 3.1 M7   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Douglas Pollock CLA 2004-06-17 20:12:23 EDT
I200406172000, GTK+ 2.4.1, KDE 3.2.2, Linux 2.6.4. 
 
Sometimes, when I have been running a self-hosted session and I shutdown, I get 
the following output on the console.  It seems like the AllTypesCache is trying 
to load classes after the class loader has decided that it will no longer be 
doing that.  The problem has happened a couple of times in the past two to 
three hours, but does not happen all the time.  It is likely a race/timing 
problem. 
 
 
An exception occurred while writing to the platform log: 
java.lang.NullPointerException 
	at 
org.eclipse.core.runtime.adaptor.EclipseLog.write(EclipseLog.java:378) 
	at 
org.eclipse.core.runtime.adaptor.EclipseLog.writeStack(EclipseLog.java:368) 
	at 
org.eclipse.core.runtime.adaptor.EclipseLog.writeLog(EclipseLog.java:332) 
	at org.eclipse.core.runtime.adaptor.EclipseLog.log(EclipseLog.java:203) 
	at 
org.eclipse.core.runtime.adaptor.EclipseClassLoader.shouldActivateFor(EclipseClassLoader.java:148) 
	at 
org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:62) 
	at 
org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:371) 
	at 
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:402) 
	at 
org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93) 
	at java.lang.ClassLoader.loadClass(ClassLoader.java:236) 
	at 
org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(BundleLoader.java:307) 
	at 
org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:336) 
	at 
org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1313) 
	at 
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:131) 
	at 
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:124) 
	at 
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:113) 
	at 
org.eclipse.jdt.core.JavaCore.getClasspathContainerInitializer(JavaCore.java:1223) 
	at 
org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(JavaModelManager.java:1245) 
	at 
org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:1226) 
	at 
org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:833) 
	at 
org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:1184) 
	at 
org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1888) 
	at 
org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1798) 
	at 
org.eclipse.jdt.internal.core.search.JavaSearchScope.add(JavaSearchScope.java:78) 
	at 
org.eclipse.jdt.internal.core.search.JavaWorkspaceScope.initialize(JavaWorkspaceScope.java:80) 
	at 
org.eclipse.jdt.internal.core.search.JavaSearchScope.<init>(JavaSearchScope.java:52) 
	at 
org.eclipse.jdt.internal.core.search.JavaWorkspaceScope.<init>(JavaWorkspaceScope.java:31) 
	at 
org.eclipse.jdt.core.search.SearchEngine.createWorkspaceScope(SearchEngine.java:423) 
	at 
org.eclipse.jdt.internal.corext.util.AllTypesCache.search(AllTypesCache.java:531) 
	at 
org.eclipse.jdt.internal.corext.util.AllTypesCache$TypeCacher.doSearchTypes(AllTypesCache.java:197) 
	at 
org.eclipse.jdt.internal.corext.util.AllTypesCache$TypeCacher.run(AllTypesCache.java:166) 
Logging to the console instead. 
 
!ENTRY org.eclipse.osgi Jun 17, 2004 19:44:51.181 
!MESSAGE The class "org.eclipse.jdt.internal.launching.JREContainerInitializer" 
cannot be loaded because the system is shutting down and the plug-in 
"org.eclipse.jdt.launching" has already been stopped. 
!STACK 0 
java.lang.ClassNotFoundException: The class 
"org.eclipse.jdt.internal.launching.JREContainerInitializer" cannot be loaded 
because the system is shutting down and the plug-in "org.eclipse.jdt.launching" 
has already been stopped. 
	at 
org.eclipse.core.runtime.adaptor.EclipseClassLoader.shouldActivateFor(EclipseClassLoader.java:147) 
	at 
org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:62) 
	at 
org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:371) 
	at 
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:402) 
	at 
org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93) 
	at java.lang.ClassLoader.loadClass(ClassLoader.java:236) 
	at 
org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(BundleLoader.java:307) 
	at 
org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:336) 
	at 
org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1313) 
	at 
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:131) 
	at 
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:124) 
	at 
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:113) 
	at 
org.eclipse.jdt.core.JavaCore.getClasspathContainerInitializer(JavaCore.java:1223) 
	at 
org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(JavaModelManager.java:1245) 
	at 
org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:1226) 
	at 
org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:833) 
	at 
org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:1184) 
	at 
org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1888) 
	at 
org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1798) 
	at 
org.eclipse.jdt.internal.core.search.JavaSearchScope.add(JavaSearchScope.java:78) 
	at 
org.eclipse.jdt.internal.core.search.JavaWorkspaceScope.initialize(JavaWorkspaceScope.java:80) 
	at 
org.eclipse.jdt.internal.core.search.JavaSearchScope.<init>(JavaSearchScope.java:52) 
	at 
org.eclipse.jdt.internal.core.search.JavaWorkspaceScope.<init>(JavaWorkspaceScope.java:31) 
	at 
org.eclipse.jdt.core.search.SearchEngine.createWorkspaceScope(SearchEngine.java:423) 
	at 
org.eclipse.jdt.internal.corext.util.AllTypesCache.search(AllTypesCache.java:531) 
	at 
org.eclipse.jdt.internal.corext.util.AllTypesCache$TypeCacher.doSearchTypes(AllTypesCache.java:197) 
	at 
org.eclipse.jdt.internal.corext.util.AllTypesCache$TypeCacher.run(AllTypesCache.java:166)
Comment 1 Jerome Lanneluc CLA 2004-06-18 05:36:32 EDT
AllTypesCache should not run after shutdown(), or shutdown() should wait for 
AllTypesCache to finish.

Moving to JDT UI for comments.
Comment 2 Dirk Baeumer CLA 2004-06-18 06:46:08 EDT
Results from investigating into the problem:

- on shutdown, JDT/UI joins with the AllTypesChange using a join(1000)
- so it might happen that the AllTypeCache thread is still running 
  although JDT/UI finish the shutdown.

However, even if JDT/UI would wait until the AllTypeChange has finished, this 
situation can occur since JDT/UI can't avoid that upper level plug-ins are 
shutdown.  In the specific example it would help since JDT/UI requires 
org.eclipse.jdt.launching.

But consider a scenario where the classpath container initializer is 
contributed by a plug-in not required by JDT/UI. This is the case for the PDE 
container we are using. In this scenario PDE is already stpped but JDT/Core 
still wants to make upcalls into PDE. 

CCing Philippe since one solution would be to protect the class path container 
initialization against this.
Comment 3 Dirk Baeumer CLA 2004-06-18 06:51:26 EDT
Douglas,

does this happen when you shutdown Eclipse right after you started it ? 

Philippe,

can you comment on how the class path initalization works. I always thought 
that they are only initialized once and this tyically happens very "early" 
since the All types cache gets populated after the workbench is active after a 
certain delay.
Comment 4 Philipe Mulet CLA 2004-06-18 07:15:47 EDT
Container gets initialized on demand. If nobody asks, then it could occur that 
first opportunity is during shutdown. We could add protection when 
instantiating extensions, but I believe this is rather a platform bug.

Dup of bug 64134
Comment 5 Douglas Pollock CLA 2004-06-18 07:20:55 EDT
Dirk: I'm not sure, but this is possible.  The next time it happens, I will try 
to let you know how long it was after start-up. 
Comment 6 Dirk Baeumer CLA 2004-06-18 11:42:27 EDT
Philippe, 

when core runtime throws an CoreException in this scenario on shutdown will 
this cause any harm to the JavaModel on shutdown. E.g. loss of data. As far as 
I can interpret it it shouldn't.

Comment 7 Philipe Mulet CLA 2004-06-18 11:56:50 EDT
It will traverse us, but we should be left consistent. Note that we deal 
normally with situations where CoreException are occurring.
Comment 8 Dirk Baeumer CLA 2004-06-18 12:56:42 EDT
Given that this will not cause any harm to the workspace (except the exception 
in the log) and we haven't seen this (can from our stand point only happen if 
you startup and shutdown without having class path containers initialized) I 
opt to do nothing here for 3.0.
Comment 9 Dirk Baeumer CLA 2004-06-24 11:54:09 EDT
*** Bug 67681 has been marked as a duplicate of this bug. ***
Comment 10 Dirk Baeumer CLA 2004-11-03 16:44:39 EST
*** Bug 75657 has been marked as a duplicate of this bug. ***
Comment 11 Dirk Baeumer CLA 2005-04-25 19:15:49 EDT
Fixed by removing the all types cache.