This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 33835

Summary: NB3.5RC2 fails to load ANTLR jar (classpath)
Product: projects Reporter: oneway <oneway>
Component: AntAssignee: Jesse Glick <jglick>
Status: RESOLVED WORKSFORME    
Severity: blocker CC: gaganc, pkeegan
Priority: P3 Keywords: SPACE_IN_PATH
Version: 3.x   
Hardware: PC   
OS: Windows ME/2000   
Issue Type: DEFECT Exception Reporter:

Description oneway 2003-05-22 14:44:17 UTC
Project build (Ant build file) fails when
attempting to execute it from NB3.5 RC2. Works
fine in NB 3.4.1

Respective output as follows:
------------------------------------------------
NB 3.5 RC2

-->!!! The antlr_272.jar file is in C:\Program
Files\NetBeans IDE
3.5rc2\modules\patches\org-apache-tools-ant-module !!!

dropping
C:\Program%20Files\NetBeans%20IDE%203.5rc2\modules\patches\org-apache-tools-ant-module\antlr_272.jar
from path as it doesn't exist
dropping
C:\Program%20Files\NetBeans%20IDE%203.5rc2\modules\patches\org-apache-tools-ant-module\antlr_272.jar
from path as it doesn't exist
Execute:Java13CommandLauncher: Executing 'java'
with arguments:
'-Djava.compiler=NONE'
'antlr.Tool'
'-o'
'C:\Some\Dir\Here'
'C:\Some\Dir\Here\Grammar.g'
[...]
Exception in thread "main" 
src\ant\build.xml [83] ANTLR returned: 1
        at
org.apache.tools.ant.taskdefs.optional.ANTLR.execute(ANTLR.java:282)
        at
org.apache.tools.ant.Task.perform(Task.java:319)
        at
org.apache.tools.ant.Target.execute(Target.java:309)
        at
org.apache.tools.ant.Target.performTasks(Target.java:336)
        at
org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at
org.apache.tools.ant.Project.executeTargets(Project.java:1250)
        at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:331)
        at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:118)
BUILD FAILED

------------------------------------------------
NB3.4.1
Execute:Java13CommandLauncher: Executing 'java'
with arguments:
'-Djava.compiler=NONE'
'-classpath'
'C:\Program Files\NetBeans
3.4.1\modules\patches\org-apache-tools-ant-module\antlr_272.jar'
'antlr.Tool'
'-o'
'C:\Some\Dir\Here'
'C:\Some\Dir\Here\Grammar.tree.g'
The ' characters around the executable and
arguments are
not part of the command.
ANTLR Parser Generator   Version 2.7.2   1989-2003
jGuru.com
Comment 1 Jesse Glick 2003-05-22 15:05:41 UTC
It is a bug in Ant, which is already fixed in dev versions ("1.6 beta"):

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15131

NetBeans (correctly) constructs class loader resource URLs which
escape ' ' as "%20". The <antlr> task from Ant 1.5.x assumes it can
just use String.substring to translate a jar:file: URL to a File,
which is incorrect. Ant dev sources are more careful with URL <-> File
conversions.

Workaround should be to install NetBeans in a directory that does not
contain any spaces.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15131
Comment 2 Patrick Keegan 2003-05-22 16:03:15 UTC
proposed relnote:
Some Ant tasks fail when trying to load files. This occurs if the IDE
is installed in a directory that has spaces in its name.
Workaround: Move the IDE to a directory that does not contain spaces
in the name. 
Comment 3 Jesse Glick 2003-05-22 17:34:45 UTC
Sounds OK. BTW I do not know if the behavior is JDK-specific (i.e. 1.3
vs. 1.4). Dusan - would be helpful to investigate the exact tasks that
are affected, effect of JDK, etc. and provide more detailed release
notes. Also check if NB 3.4.1 with the Ant 1.5.1 module exhibits the
same behavior, or if only NB 3.5 has this problem - i.e. if there is
some interaction from the way the NB core constructs resource
(jar:file:...!/...) URLs, which on JDK 1.4 should use
File.toURI().toURL() but on JDK 1.3 uses a hackier system since
nothing better is available.
Comment 4 oneway 2003-05-22 18:47:11 UTC
The issue was reported for both NB341 and NB35 against:
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

It does work if NB is installed in dir without spaces.

Comment 5 Patrick Keegan 2004-03-03 23:06:57 UTC
still worth release noting, I suppose?
Comment 6 Jesse Glick 2004-03-04 04:16:40 UTC
Don't think so. According to my previous evaluation (don't remember
details now), it no longer applies to Ant 1.6.x, and NB 3.6 is now
shipping 1.6.x.
Comment 7 oneway 2004-03-23 20:24:17 UTC
NB3.6.rc1

The classpath was defined in the build.xml but, as one can see, it
does not get passed to the antlr (besides, ANTLR task does not have a
classpath property anyway).

Tried copying the antlr.jar into "lib", "pathches", etc directories
but  it did not help. Can't build with NB3.6.rc1.

-----------------------------------------------------------

Execute:Java13CommandLauncher: Executing 'C:\Program
Files\Sun\j2sdk1.4.2\jre\bin\java.exe' with arguments:
'-Djava.compiler=NONE'
'antlr.Tool'
'-o'
'C:\...\test'
'C:\...\test\Grammar.g'

The ' characters around the executable and arguments are
not part of the command.
java.lang.NoClassDefFoundError: antlr/Tool
Exception in thread "main"

\build.xml [85] ANTLR returned: 1
        at
org.apache.tools.ant.taskdefs.optional.ANTLR.execute(ANTLR.java:285)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
        at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:178)
        at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:252)
        at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)
Comment 8 Jesse Glick 2004-03-24 12:19:04 UTC
lib, patches, etc. directories are not used by Ant in NB 3.6. You can
configure extra JARs to add to Ant's internal classpath in the Options
dialog, as is explained in the online help and FAQ for the Ant module.

Anyway the <antlr> task does accept a <classpath> as far as I can
tell, which should presumably contain antlr.jar.

I cannot work further on this without steps to reproduce from scratch,
including at least a build script. First you need to confirm that the
same script works correctly when run from command-line Ant (if not, it
is a bug in Ant that should be filed on ant.apache.org). Specifically
check whether putting antlr.jar in a directory containing spaces
works, i.e. whether the problem is the location of antlr.jar or of
NetBeans.
Comment 9 oneway 2004-03-24 13:21:04 UTC
It appears you're right about the classpath property of the ANTLR
task. Tried it with 3.6.rc1, it appears to work. Closing the issue. Thanks
Comment 10 Marian Mirilovic 2005-07-12 09:41:33 UTC
closed
Comment 11 gaganc 2006-09-10 08:49:02 UTC
This Issue is very much alive with NetBeans 5.0!

OS : Windows XP SP2
JDK : 1.5 Update 8
NetBeans : 5.0

Netbeans is installed in its default location ("Program Files\Netbeans 5.0"). I
am trying to build a project whose ant build uses ANTLR task. The project builds
without any problems from command line, but the same build fails in NetBeans
with following messages:

java.lang.NoClassDefFoundError: antlr/Tool
Exception in thread "main" 
C:\project\build.xml:180: ANTLR returned: 1
BUILD FAILED (total time: 3 seconds)

So i uninstalled Netbeans and reinstalled it in a folder without any whitespace
in its name. After that the project builds successfully even in Netbeans!

Comment 12 Jesse Glick 2006-09-11 23:57:22 UTC
Generally wisest to install NB in a folder w/o spaces. I will take a look at it
again when I get a chance.
Comment 13 Jesse Glick 2007-10-09 18:33:31 UTC
I run a 6.0 dev build, 071005, using JDK 6 on Ubuntu, in an installation with a space ("/tmp/net beans") and just for
fun in a userdir "/tmp/user dir". I open:

<project default="x">
    <target name="x">
        <property name="nb_all" location="/space/src/nb_all"/>
        <delete file="${java.io.tmpdir}/CalcScanner.java"/> <!-- no up-to-date check please -->
        <antlr target="${nb_all}/lexer/demo/src/org/netbeans/modules/lexer/demo/antlr/Calc.g"
outputdirectory="${java.io.tmpdir}">
            <classpath>
                <fileset dir="${nb_all}/lexer/external" includes="*.jar"/>
            </classpath>
        </antlr>
    </target>
</project>

where /space/src/nb_all is a NB source checkout. I run the 'x' target using context menu in the editor. Works, same as
from the command line, and same as from an IDE with no spaces in its installation dir.