Bug #5669
closedreplace ProjectLocator.findKeplerModulesDir() with something more robust.
0%
Description
This method is problematic. Bug#5458 also mentions it.
/**
*
* FIXME replace this with something(s) more robust. Be careful when doing so, some things probably always want
* KeplerData/kepler.modules, others always the other "application modules dir", others one or the other depending on
* what exists.
*
* On linux(at least) during ant run, MemoryProperties invokes this, and the search begins based on the location of ant.jar
* i.e. /usr/share/ant/lib/ant.jar/build-area/modules.txt can be the first attempt.
*
* find the project dir
* WARNING this can return either the application modules dir,
* or KeplerData/kepler.modules, or a false positive (e.g. some arbitrary parent dir that happens to contain build-area/modules.txt),
* or the system-dependent default directory (in the catch).
* @return
*/
private static KeplerModulesDir findKeplerModulesDir()
Updated by jianwu jianwu about 12 years ago
I tried today (r31073) on linux to use 'ant run' at another directory, such as: ant -f ~/kepler/repository/kepler-trunk/build-area/build.xml run. Kepler won't start. The reason is that ProjectLocator.buildDir is not set correctly.
Error details:
ant -f ~/kepler/repository/kepler-trunk/build-area/build.xml run
Buildfile: /home/jianwu/kepler/repository/kepler-trunk/build-area/build.xml
compile:
[echo] Note that you may need to run "ant force-ptolemy compile" to compile ptolemy.
[compile] Compiling configuration-manager...
[compile] Compiling module-manager...
[compile] Compiling core...
[compile] Compiling event-state...
[compile] Compiling util...
[compile] Compiling component-library...
[compile] Compiling sms...
[compile] Compiling data-handling...
[compile] Compiling ssh...
[compile] Compiling io...
[compile] Compiling job...
[compile] Compiling repository...
[compile] Compiling authentication...
[compile] Compiling module-manager-gui...
[compile] Compiling gui...
[compile] Compiling authentication-gui...
[compile] Compiling ecogrid...
[compile] Compiling dataturbine...
[compile] Compiling opendap...
[compile] Compiling actors...
[compile] Compiling display-redirect...
[compile] Compiling loader...
[compile] Compiling r...
run:
[run] WARNING: Using virtual project location.
BUILD FAILED
/home/jianwu/kepler/repository/kepler-trunk/build-area/build.xml:52: Could not create type run due to java.lang.NullPointerException
Total time: 0 seconds
Updated by jianwu jianwu about 12 years ago
With changes in r31074, the kepler dir is set based on build.xml location. It won't start searching from ant.jar anymore. It works on linux, mac and windows.
Derik, please test it and close it if it works for you. Thanks.
Updated by Daniel Crawl about 12 years ago
On Linux, if build-area/use.keplerdata exists, an NPE occurs:
cd /
ant -f ~/.../build-area/build.xml run
compile:
[echo] Note that you may need to run "ant force-ptolemy compile" to compile ptolemy.
[compile] java.lang.Exception: No project dir found.
[compile] at org.kepler.build.project.ProjectLocator.findProjectLocation(ProjectLocator.java:194)
[compile] at org.kepler.build.project.ProjectLocator.findProjectLocation(ProjectLocator.java:196)
[compile] at org.kepler.build.project.ProjectLocator.findProjectLocation(ProjectLocator.java:196)
[compile] at org.kepler.build.project.ProjectLocator.findProjectLocation(ProjectLocator.java:196)
[compile] at org.kepler.build.project.ProjectLocator.findProjectLocation(ProjectLocator.java:196)
[compile] at org.kepler.build.project.ProjectLocator.findProjectLocation(ProjectLocator.java:196)
[compile] at org.kepler.build.project.ProjectLocator.findKeplerModulesDir(ProjectLocator.java:160)
[compile] at org.kepler.build.project.ProjectLocator.getUserBuildDir(ProjectLocator.java:232)
[compile] at org.kepler.build.modules.ModulesTxt.instance(ModulesTxt.java:70)
[compile] at org.kepler.build.modules.ModulesTask.init(ModulesTask.java:78)
[compile] at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:223)
[compile] at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:414)
[compile] at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
[compile] at org.apache.tools.ant.Task.perform(Task.java:347)
[compile] at org.apache.tools.ant.Target.execute(Target.java:357)
[compile] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[compile] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[compile] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[compile] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[compile] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[compile] at org.apache.tools.ant.Main.runBuild(Main.java:758)
[compile] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[compile] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[compile] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
[compile] WARNING: Using virtual project location.
BUILD FAILED
java.lang.NullPointerException
at java.io.File.<init>(File.java:239)
at org.kepler.build.project.KeplerModulesDir.<init>(KeplerModulesDir.java:50)
at org.kepler.build.project.ProjectDir.<init>(ProjectDir.java:22)
at org.kepler.build.project.ProjectLocator.findKeplerModulesDir(ProjectLocator.java:172)
at org.kepler.build.project.ProjectLocator.getUserBuildDir(ProjectLocator.java:232)
at org.kepler.build.modules.ModulesTxt.instance(ModulesTxt.java:70)
at org.kepler.build.modules.ModulesTask.init(ModulesTask.java:78)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:223)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:414)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
Updated by jianwu jianwu about 12 years ago
Dan found the problem because he ran ant installer tasks before run ant compile. The ant installer tasks for linux and Mac creates build-area/use.keplerdata file. At 31269, every ant installer tasks create this file at beginning and remove it in the end.
If build-area/use.keplerdata is created by users, the exception at comment 3 will still occur. But it rarely happens.
Updated by Daniel Crawl over 11 years ago
- Priority changed from Normal to High
- Target version changed from Unspecified to 2.5.0
The kepler-tasks module cannot be patched: once a patch is installed for kepler-tasks, Kepler will not start. The problem is that findKeplerModulesDir() uses the location of the kepler-tasks jar as the location where Kepler is installed. Since the patch is in KeplerData/kepler.modules, findKeplerModulesDir() assumes that all modules are in this directory and will not find the modules in the Kepler installation directory.
Updated by Daniel Crawl over 9 years ago
- Status changed from New to Resolved
- Assignee changed from jianwu jianwu to Daniel Crawl
I've updated ProjectLocator so that kepler-tasks can be patched. See r33827.