You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2006/04/13 11:18:06 UTC

DO NOT REPLY [Bug 39295] New: - white spaces in path

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295

           Summary: white spaces in path
           Product: Ant
           Version: 1.6.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Keywords: PatchAvailable
          Severity: enhancement
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: wherka@o2.pl


A couple of weeks ago I found that sometimes there is problem with launching ant
when the path which is utilized to lookup the "jars" contains some blanks. I
investigated it and changed the code of ant-launcher a little bit. Now the path
is converted to URI and then back to URL, so we can forget about white spaces
and any other error-prone characters. It works perfectly for me - I think it can
be useful for others too.

*************************************************************
Changes in file org.apache.tools.ant.launch.Launcher.java:
1)
import java.net.URLEncoder;
2)
    private void run(String[] args) throws LaunchException, MalformedURLException {
//..
        // now update the class.path property
        StringBuffer baseClassPath
            = new StringBuffer(System.getProperty("java.class.path"));
        if (baseClassPath.charAt(baseClassPath.length() - 1)
                == File.pathSeparatorChar) {
            baseClassPath.setLength(baseClassPath.length() - 1);
        }
//--------------- my modifications -------------------
        URL[] tempJars = new URL[numJars] ;
        int count = 0;
        for(URL _url: jars)
        {        	         	
        	File _file = null;        	
        	_file = new File(_url.getFile());
            tempJars[count++] = _file.toURI().toURL();        	
        }                
        
        
        System.arraycopy(tempJars, 0, jars, 0, tempJars.length);        
//----------------- end of modifications ------------------------        
        for (int i = 0; i < jars.length; ++i) {
            baseClassPath.append(File.pathSeparatorChar);
            baseClassPath.append(Locator.fromURI(jars[i].toString()));
        }

//..
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From peterreilly@apache.org  2006-04-24 11:31 -------
Can you try the current SVN ant.
I implemently something similar to your request.
It uses Locator.encodeURI implemented in
ant 1.7, instead of File.toURI

I have tested on linux.
export CLASSPATH="/home/preilly/a space"
preilly@backpack:~/tmp/a > ant -f x.xml

Where there is a jar in "a space" that is
needed by x.xml.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295


antoine@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |1.7




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295


kevin.jackson@it.fts-vn.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Additional Comments From kevin.jackson@it.fts-vn.com  2006-04-13 11:18 -------
It looks like you've used Java5 (indeed Java 1.4+) code here.  This means that
Ant cannot be compiled on Java 1.2 compilers.

toURI() is the easiest way of encoding the space character as %20, but it's only
available in Java 1.4+.  For the 'enhanced' for loop, that limits the code even
further to Java 1.5+

I'll look into the underlying problem (spaces in path), but if you'd like to
submit code that will compile under JDK 1.2 that would be great

Thanks for the bug report and the code.
Kev

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From wherka@o2.pl  2006-04-24 14:25 -------
(In reply to comment #9)
> Opps, Sorry, I did not read our previous message correctly.
> I have made the change now (after extracting the fileToURL code
> to a method). Thanks for reporting the problem and showing
> the solution!
> 
> Peter

You're welcome :-)

BTW: I'm gonna play around ANT since I found it very useful and powerfull tool,
so I suppose I will be sending some code (fixes or extensions) from time to time..


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From wherka@o2.pl  2006-04-14 20:13 -------
(In reply to comment #2 and #3)
> Have you verfied against ant HEAD, I think we fixed this some time ago.

Kev: Indeed I'm working on Java 1.5 - if this problem still exist I will change 
it according to 1.2 spec, but first I will check the HEAD since Martijn 
reported that it has been already fixed.

Martijn: I suppose you're right, but I did not use dev code. I will check it 
soon - just after Easter.

BTW: I must say that ANT is my favourite batch-processing tool - it's SIMPLY 
THE BEST!



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From wherka@o2.pl  2006-04-24 12:44 -------
(In reply to comment #7)
> Can you try the current SVN ant.
> I implemently something similar to your request.
> It uses Locator.encodeURI implemented in
> ant 1.7, instead of File.toURI
> 
> I have tested on linux.
> export CLASSPATH="/home/preilly/a space"
> preilly@backpack:~/tmp/a > ant -f x.xml
> 
> Where there is a jar in "a space" that is
> needed by x.xml.
> 

Indeed it was implemented this way, but please try to put JAVA environment in
Windows' default location (C:\Program Files\Java\..) and you'll get this error
for sure.
I have just investigated it once again - in fact I gave the workaround not the
real solution... it works but I can give you a better one.
The real problem was encoding of "tools.jar" - it hasn't been encoded at all, so
if you've installed JDK somewhere in "spacing" location you get into trouble as
I did.


New refined fix:
Launcher.java - line#258 "jars[jars.length - 1] = toolsJar.toURL();" should be
changed to:
**************** FIX ***********************
 if (toolsJar != null) {
        	try {
        		jars[jars.length - 1] = new
URL(Locator.encodeURI(toolsJar.toURL().toString()));
            } catch (UnsupportedEncodingException ex) {
                throw new MalformedURLException(ex.toString());
            }
        }
**************** FIX ***********************

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From wherka@o2.pl  2006-04-24 09:20 -------
I saw the last changes related to this bug - unfortunately they didn't fix it at
all :-(
I've made the test and it looked the same as previously... but they give us one
advantage - now we need to change one line only to make this working properly.

Launcher.java[line#272("baseClassPath.append(Locator.fromURI(jars[i].toString()));)"]
to:
************ FIX ********************
"baseClassPath.append(jars[i].toString());"
************ FIX ********************
_______________________________________________________________________________
Since the paths of "jars" have been already encoded in addPath(..) we cannot do
this once again here...
_______________________________________________________________________________

Result of the test with the version from repository:
//-----------------------------------------------------
C:\Program Files\tools test 2\ant\bin>ant
java.lang.IllegalArgumentException
        at java.net.URI.create(URI.java:842)
        at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.tools.ant.launch.Locator.fromURI(Locator.java:160)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:272)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:100)
Caused by: java.net.URISyntaxException: Illegal character in path at index 16:
file:/C:/Program Files/Java/jdk1.5.0_05/lib/tools.jar
        at java.net.URI$Parser.fail(URI.java:2809)
        at java.net.URI$Parser.checkChars(URI.java:2982)
        at java.net.URI$Parser.parseHierarchical(URI.java:3066)
        at java.net.URI$Parser.parse(URI.java:3014)
        at java.net.URI.<init>(URI.java:578)
        at java.net.URI.create(URI.java:840)
//-----------------------------------------------------
.. and after my change:
//-----------------------------------------------------
C:\Program Files\tools test 2\ant\bin>ant
Buildfile: build.xml
     [echo] [windir]    : C:\WINDOWS
     [echo] [temp.dir]  : C:\WINDOWS\temp

test:
     [echo] splash:  file:///C:\Program Files/tools test 2/ant/images/winzip.jpg
     [echo] 10:57:27 AM
     [exec] Result: 1

BUILD SUCCESSFUL
Total time: 7 seconds
//-----------------------------------------------------

I hope it will not harm the processing on the other OSes.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295


peterreilly@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |major
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From peterreilly@apache.org  2006-04-24 14:17 -------
Opps, Sorry, I did not read our previous message correctly.
I have made the change now (after extracting the fileToURL code
to a method). Thanks for reporting the problem and showing
the solution!

Peter

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From wherka@o2.pl  2006-04-13 10:21 -------
Created an attachment (id=18091)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=18091&action=view)
Fix of the "white spaces in path" problem

Changes from line #235 to #246

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From gudnabrsam@yahoo.com  2006-04-14 20:38 -------
batch processing tool?  Ant is a build tool... ;) (I abuse it this way too!)

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295


wherka@o2.pl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #18091|Fix of the "white spaces in |Launcher.java - fixed the
        description|path" problem               |"white spaces in path"
                   |                            |problem




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295





------- Additional Comments From jkf@apache.org  2006-04-13 19:14 -------
Have you verfied against ant HEAD, I think we fixed this some time ago.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


DO NOT REPLY [Bug 39295] - white spaces in path

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39295


peterreilly@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |svetozar01@hotmail.com




------- Additional Comments From peterreilly@apache.org  2006-05-03 16:54 -------
*** Bug 39037 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org