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

Bug 198952

Summary: Run Ant Build As... loses targets for ant files with import statements
Product: [Eclipse Project] Platform Reporter: Arthur Branham <arthur.branham>
Component: AntAssignee: Platform-Ant-Inbox <platform-ant-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Darin_Swanson
Version: 3.2.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Arthur Branham CLA 2007-08-06 11:30:09 EDT
Build ID: M20060921-0945

Steps To Reproduce:
1.Create a simple ant build file which imports another parent ant build file whose location is specified by a native environment variable.  A task in the build.xml should depend on a task from the imported parent ant file.  
2.Set the environment variable in your native environment and relaunch eclipse so it takes effect.
3.Right click the build.xml->Run As->Ant Build...
4.The targets will initially show up which is the expected behavior.  Eclipse has successfully used the environment variable to create a path which allowed the import statement to include the targets into the current graph of the ant build. It displays the list of targets and the file they are inherited from. This is the desired behavior.
5. Click the Classpath tab in the Run As.. dialog and modify ANT_HOME to be a different Ant Home installation.  As soon as this is done the Targets dissappear and an error message is displayed at the top of the dialog "No targets could be determined for the buildfile".  This goes for touching anything in the Classpath, JRE, or Environment tab.  A second scenario in which case the targets disappear is to run one of the targets immediately upon opening the Run As.. dialog followed by opening it a second time in order to choose a different target to run.  Upon opening it the second time you will see there are no targets.
6. The only way to get the targets to reappear is to close Eclipse and repeat step #3.

More information:
Comment 1 Darin Swanson CLA 2007-08-06 11:46:52 EDT
Thank you for the bug report Arthur.
I believe this is a duplicate of bug 174759.

Can you please try the latest Eclipse release, 3.3 and report back?
Comment 2 Arthur Branham CLA 2007-08-06 12:13:16 EDT
Build Id: I20070625-1500

I tried Eclipse 3.3 and I still receive that error message.  I think I have isolated the scenario to when I set a different Classpath User Entry for Ant Home under the Classpath tab.  For some reason I am able to run a target once after doing this and then everything gets hosed and all targets disappear from the list.  At this point I must either restart Eclipse or click the Restore Default Entries button under the Classpath Tab for the targets to reappear.  

As an additional note the Ant Home I tried to set was version 1.7.0
Comment 3 Darin Swanson CLA 2007-08-06 12:16:44 EDT
Is there any indication of problem in your error log?

Note that Eclipse 3.3 bundles Ant 1.7.0
Comment 4 Arthur Branham CLA 2007-08-06 12:25:53 EDT
There is in fact a stack trace for the target retrieval.  Understood about Eclipse bundling 1.7.0.  We are trying to leverage an existing external installation in which antlib bundles are loaded by default with the ant engine.  The particular build file I am using has some namespace declarations for antlibs to load.  The corresponding antlib files are located in jars under the external 1.7.0 lib directory.

!ENTRY org.eclipse.ant.ui 4 0 2007-08-06 12:04:55.756
!MESSAGE Internal error occurred retrieving targets
!STACK 0
java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
	at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
	at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
	at org.apache.tools.ant.util.JAXPUtils.newSAXParser(JAXPUtils.java:215)
	at org.apache.tools.ant.util.JAXPUtils.getNamespaceXMLReader(JAXPUtils.java:172)
	at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:185)
	at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:86)
	at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:75)
	at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:429)
	at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:281)
	at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:802)
	at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:259)
	at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:236)
	at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:215)
	at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:411)
	at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
	at org.eclipse.ant.internal.ui.model.AntPropertyNode.configure(AntPropertyNode.java:102)
	at org.eclipse.ant.internal.ui.model.AntModel.resolveBuildfile(AntModel.java:504)
	at org.eclipse.ant.internal.ui.model.AntModel.parseDocument(AntModel.java:329)
	at org.eclipse.ant.internal.ui.model.AntModel.reconcile(AntModel.java:265)
	at org.eclipse.ant.internal.ui.model.AntModel.getProjectNode(AntModel.java:1386)
	at org.eclipse.ant.internal.ui.model.AntModel.getProjectNode(AntModel.java:1396)
	at org.eclipse.ant.internal.ui.AntUtil.getTargets(AntUtil.java:237)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntTargetsTab$8.run(AntTargetsTab.java:518)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:758)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:755)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2451)
	at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1149)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1142)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntTargetsTab.getTargets(AntTargetsTab.java:535)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntTargetsTab.initializeFrom(AntTargetsTab.java:644)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntTargetsTab.isValid(AntTargetsTab.java:759)
	at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer.refresh(LaunchConfigurationTabGroupViewer.java:516)
	at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer$6.widgetSelected(LaunchConfigurationTabGroupViewer.java:418)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:706)
	at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3227)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:2005)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:316)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
	at org.eclipse.jface.window.Window.open(Window.java:796)
	at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog.open(LaunchConfigurationsDialog.java:1133)
	at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog.open(LaunchConfigurationPropertiesDialog.java:230)
	at org.eclipse.debug.ui.DebugUITools.openLaunchConfigurationDialog(DebugUITools.java:460)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchShortcut.launch(AntLaunchShortcut.java:339)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchShortcut.launch(AntLaunchShortcut.java:234)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchShortcut.launch(AntLaunchShortcut.java:179)
	at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchShortcut.launch(AntLaunchShortcut.java:86)
	at org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension.launch(LaunchShortcutExtension.java:429)
	at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.run(LaunchShortcutAction.java:66)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
Comment 5 Darin Swanson CLA 2007-08-06 12:35:42 EDT
Thank you for reporting back.

antlib was the missing piece.
Unfortunately this is a duplicate of bug 152793.

Have you tried the workaround listed in bug 143008: 
"As well, if you remove the xerces JARs (xercesImpl.jar and xml-apis.jar) from
the Ant runtime classpath for the ANT HOME the problem goes away as well."

I cannot remember if this fixes this problem but worth a try.

*** This bug has been marked as a duplicate of bug 152793 ***