[ http://jira.activemq.org/jira//browse/SM-329?page=all ] Guillaume Nodet resolved SM-329: --------------------------------
Resolution: Fixed Fix Version: 3.0-M1 Author: gnodet Date: Fri Feb 24 09:13:21 2006 New Revision: 380716 URL: http://svn.apache.org/viewcvs?rev=380716&view=rev Log: SM-329: NullPointerException when reinstalling a component after a previous uninstall Patch submitted by David Grigglestone Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java > NullPointerException when reinstalling a component after a previous uninstall > ----------------------------------------------------------------------------- > > Key: SM-329 > URL: http://jira.activemq.org/jira//browse/SM-329 > Project: ServiceMix > Type: Bug > Components: servicemix-core > Versions: incubation, 3.0, 3.0-M2, 3.0-M1 > Environment: win32, Sun jdk (1.4.2_09-b05) > Reporter: David Grigglestone > Assignee: Guillaume Nodet > Fix For: 3.0-M1 > > > 06/02/24 08:36:17 ERROR Failed to deploy component: TEST-BC > java.lang.NullPointerException > at > org.apache.servicemix.jbi.util.FileUtil.buildDirectory(FileUtil.java:80) > at > org.apache.servicemix.jbi.container.EnvironmentContext.getComponentStateFile(EnvironmentContext.java:358) > at > org.apache.servicemix.jbi.framework.InstallationService.buildComponent(InstallationService.java:619) > at > org.apache.servicemix.jbi.framework.InstallationService$1.run(InstallationService.java:596) > at > org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291) > at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown > Source) > at java.lang.Thread.run(Thread.java:595) > 06/02/24 08:36:17 ERROR Could not build Component: TEST-BC > javax.jbi.management.DeploymentException: java.lang.NullPointerException > at > org.apache.servicemix.jbi.framework.InstallationService.buildComponent(InstallationService.java:632) > at > org.apache.servicemix.jbi.framework.InstallationService$1.run(InstallationService.java:596) > at > org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291) > at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown > Source) > at java.lang.Thread.run(Thread.java:595) > Caused by: java.lang.NullPointerException > at > org.apache.servicemix.jbi.util.FileUtil.buildDirectory(FileUtil.java:80) > at > org.apache.servicemix.jbi.container.EnvironmentContext.getComponentStateFile(EnvironmentContext.java:358) > at > org.apache.servicemix.jbi.framework.InstallationService.buildComponent(InstallationService.java:619) > ... 4 more > 1) Installed the component archive > [JBIContainer.updateExternalArchive(componentArchive, true);] > 2) Uninstalled the component > [InstallationService.unloadInstaller(componentName, true);] > 3) Restart the container > 4) Try to repeat 1) and it fails with the above exception. > The problem is due to the new component version support (the code could be a > liitle more readable with more meaningful method names). When a component is > removed the version directory is deleted, but not the parent directory (in > previous versions there was no concept of versions and thus the parent > [component] directory was the one being deleted. In 3.0 the extra layer of > directory has been added. > When the component is reinstalled component root directory [in this case > "TEST-BC"] already exists, but nothing else .. a condition which is not > catered for in the code that generates the exception. > Now I'm unsure where the developers are heading with the versioning support > (is it really required?). Based on lack of knowledge on this part I did code > a temporary fix pending someone looking at the underlying issues [e.g. should > there be a state file per version, etc.]. The temporary fix is to remove the > versions parent [component root] directory if it is empty [note my comment > earlier about method naming .. the "root" becomes somewhat misleading with > both the component and version roots. The code for this fix is shown below .. > maybe you might consider putting this temporary fix in until the underlying > issues are resolved? > (Note: I have also changed the log messages to be a bit more reflective of > whats going on) > org.apache.servicemix.jbi.container.EnvironmentContext .... > /** > * Remove the Component root directory from the local file system > * > * @param componentName > */ > public void removeComponentRootDirectory(String componentName) { > try { > File file = getComponentRootDirectory(componentName); > if (file != null) { > if (!FileUtil.deleteFile(file)) { > log.warn("Failed to remove directory structure for > component [version]: " + componentName + " [" + file.getName() + ']'); > } > else { > log.info("Removed directory structure for component > [version]: " + componentName + " [" + file.getName() + ']'); > File parent = file.getParentFile(); > if (parent.list().length == 0) { > if (!FileUtil.deleteFile(parent)) { > log.warn("Failed to remove root directory for > component: " + componentName); > } > else { > log.info("Removed root directory structure for > component: " + componentName); > } > } > } > } > } > catch (IOException e) { > log.warn("Failed to remove directory structure for component: " + > componentName, e); > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.activemq.org/jira//secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira