Community
Participate
Working Groups
3.7M2a Running a custom Ant task that creates an API baseline and tries to add components to it no longer works in 3.7M2a with the following NPE reported: batchmigration] scan: [batchmigration] [batchmigration] java.lang.NullPointerException [batchmigration] /home/apiadmin/tasks/buildfiles/migrationscan.xml:19: java.lang.NullPointerException [batchmigration] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116) [batchmigration] at org.apache.tools.ant.Task.perform(Task.java:348) [batchmigration] at org.apache.tools.ant.Target.execute(Target.java:357) [batchmigration] at org.apache.tools.ant.Target.performTasks(Target.java:385) [batchmigration] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) [batchmigration] at org.apache.tools.ant.Project.executeTarget(Project.java:1306) [batchmigration] at com.ibm.api.scans.servertools.tasks.ServerTask.runSubProject(ServerTask.java:158) [batchmigration] at com.ibm.api.scans.servertools.tasks.BatchMigration.checkProduct(BatchMigration.java:184) [batchmigration] at com.ibm.api.scans.servertools.tasks.BatchMigration.execute(BatchMigration.java:149) [batchmigration] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) [batchmigration] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [batchmigration] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) [batchmigration] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [batchmigration] at java.lang.reflect.Method.invoke(Method.java:618) [batchmigration] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [batchmigration] at org.apache.tools.ant.Task.perform(Task.java:348) [batchmigration] at org.apache.tools.ant.Target.execute(Target.java:357) [batchmigration] at org.apache.tools.ant.Target.performTasks(Target.java:385) [batchmigration] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) [batchmigration] at org.apache.tools.ant.Project.executeTarget(Project.java:1306) [batchmigration] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) [batchmigration] at org.apache.tools.ant.Project.executeTargets(Project.java:1189) [batchmigration] at org.apache.tools.ant.Main.runBuild(Main.java:758) [batchmigration] at org.apache.tools.ant.Main.startAnt(Main.java:217) [batchmigration] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) [batchmigration] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) [batchmigration] Caused by: java.lang.NullPointerException [batchmigration] at org.eclipse.pde.api.tools.internal.model.ApiModelFactory.addComponents(ApiModelFactory.java:209) [batchmigration] at org.eclipse.pde.api.tools.internal.tasks.CommonUtilsTask.createBaseline(CommonUtilsTask.java:74) [batchmigration] at org.eclipse.pde.api.tools.internal.tasks.ApiMigrationTask.getBaseline(ApiMigrationTask.java:306) [batchmigration] at org.eclipse.pde.api.tools.internal.tasks.ApiMigrationTask.execute(ApiMigrationTask.java:222) [batchmigration] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) [batchmigration] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) [batchmigration] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [batchmigration] at java.lang.reflect.Method.invoke(Method.java:618) [batchmigration] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [batchmigration] ... 25 more [batchmigration] --- Nested Exception --- [batchmigration] java.lang.NullPointerException [batchmigration] at org.eclipse.pde.api.tools.internal.model.ApiModelFactory.addComponents(ApiModelFactory.java:209) [batchmigration] at org.eclipse.pde.api.tools.internal.tasks.CommonUtilsTask.createBaseline(CommonUtilsTask.java:74) [batchmigration] at org.eclipse.pde.api.tools.internal.tasks.ApiMigrationTask.getBaseline(ApiMigrationTask.java:306) [batchmigration] at org.eclipse.pde.api.tools.internal.tasks.ApiMigrationTask.execute(ApiMigrationTask.java:222) [batchmigration] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) [batchmigration] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) [batchmigration] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [batchmigration] at java.lang.reflect.Method.invoke(Method.java:618) [batchmigration] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [batchmigration] at org.apache.tools.ant.Task.perform(Task.java:348) [batchmigration] at org.apache.tools.ant.Target.execute(Target.java:357) [batchmigration] at org.apache.tools.ant.Target.performTasks(Target.java:385) [batchmigration] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) [batchmigration] at org.apache.tools.ant.Project.executeTarget(Project.java:1306) [batchmigration] at com.ibm.api.scans.servertools.tasks.ServerTask.runSubProject(ServerTask.java:158) [batchmigration] at com.ibm.api.scans.servertools.tasks.BatchMigration.checkProduct(BatchMigration.java:184) [batchmigration] at com.ibm.api.scans.servertools.tasks.BatchMigration.execute(BatchMigration.java:149) [batchmigration] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) [batchmigration] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [batchmigration] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) [batchmigration] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [batchmigration] at java.lang.reflect.Method.invoke(Method.java:618) [batchmigration] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [batchmigration] at org.apache.tools.ant.Task.perform(Task.java:348) [batchmigration] at org.apache.tools.ant.Target.execute(Target.java:357) [batchmigration] at org.apache.tools.ant.Target.performTasks(Target.java:385) [batchmigration] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) [batchmigration] at org.apache.tools.ant.Project.executeTarget(Project.java:1306) [batchmigration] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) [batchmigration] at org.apache.tools.ant.Project.executeTargets(Project.java:1189) [batchmigration] at org.apache.tools.ant.Main.runBuild(Main.java:758) [batchmigration] at org.apache.tools.ant.Main.startAnt(Main.java:217) [batchmigration] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) [batchmigration] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) Looks like the fix to bug 322572 is the culprit here, as the bundle might not have been started - no instance of ApiPlugin has been created. Steps: 1. create ant Ant task that creates an API baseline 2. add the api.tools bundle on the Ant classpath 3. run the task Happens: NPE Expected: works as it always has
It would make sense that if there is no bundle context (it hasn't been started) the method should fall back to its old behavior.
Created attachment 181307 [details] Possible Fix If we don't have a bundle context, can we still call code from PDE at all? If so, this patch will fix the problem by using PDE code directly rather than accessing it through the service (if there is no bundle context available). If we cannot call any code from PDE, then we'll have to put back in the original code that scanned a directory. However, this will cause behaviour to differ significantly between having/not having a context.
Applied/Fixed.
verified