Bug 366711 - Perform some sanity checks when looking up Ant Home
Summary: Perform some sanity checks when looking up Ant Home
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Pradeep Balachandran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 101224
  Show dependency tree
 
Reported: 2011-12-14 10:30 EST by Michael Rennie CLA
Modified: 2020-03-01 05:40 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Rennie CLA 2011-12-14 10:30:16 EST
Many duplicate bugs have been reported about Ant not working, classfiles that cannot be found, etc, etc. The root cause of most of this is that the user has - at some point - modified Ant Home to point to somewhere other than the default Eclipse install and there is no longer a complete Ant install there. 

The workaround for this is described in bug 101224 (press restore defaults on the pref page), but I think we could do better to avoid these problems completely. I was thinking that when we try to restore Ant Home would could check that

1. the location exists
2. the location contains jars

failing either of those checks (there could be more checks also) and we should reset Ant Home.

The up-side of a change like this is that we can avoid a tonne of user confusion and hassle.

The down-side of this (and it is a bad one) is that we would end up removing all customizations to Ant Home, and would have to alert the user somehow to what we have done.
Comment 1 Michael Rennie CLA 2011-12-14 10:40:23 EST
(In reply to comment #0)
> and would have to alert the user somehow to what we have done.

Thinking back, we already have a way to notify the user of a problem with Ant Home - the option 'Warn when tools.jar is not on the classpath' on the Ant pref page (I forgot about it because like most people I tell it to not nag me any more).

Perhaps it would be best to detect the problem with Ant Home, pop up a dialog that will help direct the user the solve the problem, and *not* monkey with their Ant Home settings at all.
Comment 2 Daniel Sokolowski CLA 2014-08-29 10:30:20 EDT
The 'Restore Defaults' in the 'Preferences > Ant > Runtime' trick worked, however I am commenting because I did NOT receive any error indication or warning as implied by Michael Rennie - is there supposed to be a popup alert when I try to run Ant tasks but the classpath is incorrect?

I found this page after examining the Eclipse IDE error log ('Help > About Eclipse Platfrom > Installation Details > View Error Log')

```
!MESSAGE Could not find one or more classes: "org.apache.tools.ant.BuildException". Please check the Ant classpath. !STACK 0 java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.eclipse.ant.core.AntRunner.run(AntRunner.java:317) at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate$1.run(AntLaunchDelegate.java:244) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildException at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at org.eclipse.ant.internal.core.AntClassLoader.findClass(AntClassLoader.java:53) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 7 more 

```
Comment 3 Eclipse Genie CLA 2020-03-01 05:40:26 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.