Solved

ANT java.io.IOException: CreateProcess

Posted on 2004-10-19
28
9,042 Views
Last Modified: 2012-08-14
My ANT script is building a long classpath, and I suspect this is causing a problem.  Here is a portion of my ANT output:

BUILD FAILED
C:\RetailDirect\build.xml:103: java.io.IOException: CreateProcess: C:\j2sdk1.4.1_02\jre\bin\java.exe -classpath C:\j2sdk1.4.1_02\jre\lib\ext\dnsns.jar;...[LONG PATH]...;C:\j2sdk1.4.1_02\jre?

The ? character marks the 1010th character of the command.  Is there a 1K limit on the length of a classpath specified from the javac.exe command-line?  Or is there a limit on command-lines in general?
0
Comment
Question by:knightEknight
  • 13
  • 10
  • +3
28 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 70 total points
Comment Utility
In some cases, there can be a limit. Any jars in that ext directory don't need to be in the classpath
0
 
LVL 8

Assisted Solution

by:kiranhk
kiranhk earned 55 total points
Comment Utility
usually on windows this problem occurs when the length is more but not on unix. probably u can try taking out the things not required by ur build script
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
Thanks for your feedback.  I have already removed all the jars I can ... next I will begin putting them in C:\X to shorten the path.  But I would not really consider this a good solution -- there may not be one.  I'll leave the question open for a while in case there are other ideas.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Please post the bit of build.xml that contains the classpath
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
The build.xml file was generated by JBuilderX.  The portion that was failing was making a call to a JSP compiler via the command-line version of java.exe, specifying the long classpath.  When I realized this I just removed the jsp target and the build succeeded.  I'll leave the jsp compiling to the app server.


Here is a portion of the path specifier:

  <path id="project.class.path">
    <pathelement location="${dest}"/>
    <pathelement location="${Tomcat.home}/lib/common/servlet.jar"/>
    <!-- removed proprietary jars -->
    <pathelement location="${jdk.home}/jre/lib/ext/dnsns.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/ldapsec.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/localedata.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/sunjce_provider.jar"/>
    <pathelement location="${jdk.home}/jre/lib/charsets.jar"/>
    <pathelement location="${jdk.home}/jre/lib/im/indicim.jar"/>
    <pathelement location="${jdk.home}/jre/lib/jaws.jar"/>
    <pathelement location="${jdk.home}/jre/lib/jce.jar"/>
    <pathelement location="${jdk.home}/jre/lib/jsse.jar"/>
    <pathelement location="${jdk.home}/jre/lib/rt.jar"/>
    <pathelement location="${jdk.home}/jre/lib/sunrsasign.jar"/>
    <pathelement location="${jdk.home}/lib/dt.jar"/>
    <pathelement location="${jdk.home}/lib/htmlconverter.jar"/>
    <pathelement location="${jdk.home}/lib/tools.jar"/>
    <pathelement location="${jdk.home}/rt"/>
  </path>

  <path id="jspc.class.path">
    <pathelement location="${Tomcat.home}/lib/container/jasper.jar"/>
    <pathelement location="${Tomcat.home}/lib/container/crimson.jar"/>
    <pathelement location="${Tomcat.home}/lib/common/servlet.jar"/>
  </path>

   ...

   <!-- below is line 103 -->
    <jspc destdir="${compiled.jsp}/rd" srcdir="C:/Jakarta/webapps/scrubbed">
      <classpath refid="project.class.path"/>
      <classpath refid="jspc.class.path"/>
      <include name="**/*.jsp"/>
    </jspc>

0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
So problem solved now then?
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
no, I did that before I posted the question ... I'd still like to know how to get around the command-line length limit -- if there is a way.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
You could probably remove those pathelements from where that comment starts to the end. Try commenting them out
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
yes, I did that too but added them back in later because even when I remove them, all the JSP filenames were being passed one at a time on the command line -- so I had no hope of getting the length under 1K.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
What OS are you using btw?
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
W2K
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
also tried this:

command.com /e:30000
ant
exit

still same result
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
It would be cmd.exe in Win2k
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

Author Comment

by:knightEknight
Comment Utility
yes, but command.com is the only shell that allows you to set the environment space.

In other words, you can't do this:  cmd.exe /e:30000

besides, I doubt the environment space has much to do with the 1K limit of a command-line argument.
0
 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 55 total points
Comment Utility
Hi knightEknight,

When you have multiple jar files in the same directory, you can use the '*' character like :
C:\common\directory\path\*.jar
0
 
LVL 7

Accepted Solution

by:
JugglerW earned 70 total points
Comment Utility
See here for some discussion of command line length limit:

http://weblogs.asp.net/oldnewthing/archive/2003/12/10/56028.aspx

A kind of unusual solution for your problem could be:

- Extract all the jars in your classpath to a single directory
- jar the complete directory to one big jar file: mybigfat.jar
- use this in your classpath

You may also define an ant task to do this automatically for you if any of your source jars change. But from your example above I assume the jars will change very seldom so this could easily done manually.
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
Webstorm,
I wish it were so ... but ANT does not expand the wildcard characters that way.
Here is what I tried to test this in my build.xml file:

    <!--  
    <pathelement location="${jdk.home}/jre/lib/ext/dnsns.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/ldapsec.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/localedata.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/sunjce_provider.jar"/>
     -->
    <pathelement location="${jdk.home}/jre/lib/ext/*.jar"/>

But none of the jars were included by the *.jar.


Juggler,
Thanks for the link -- I'll read thru it.  However, I'm trying to avoid all solutions that involve extracting, renaming, or moving the libraries.  I'm really just after two things:  1) Why is the command (apparently) limited to about 1K, and 2) is there a way to increase this length explicitely.

Thanks all
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
1) I think there is some doubt as to the real length, but some seem to think it's 32K
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
according to the link posted by Juggler above, the CreateProcess limit is 32K, the CMD.EXE limit is 8K, and the spawnv() limit is 1K.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
btw are you running ant from the command line or through JBuilder now?
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
command line
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Might be good to post your build.xml, or even better, a link to it. How many jsps btw?
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
almost 700 JSPs.  The build.xml was generated by JBuilder and is very lengthy.  But there is nothing atypical about it that I can see.

But this issue has also appeared in other contexts:

http://forums.bea.com/bea/thread.jspa?threadID=200060432&start=-1&f#202428357

http://www.myeclipseide.com/index.php?name=PNphpBB2&file=viewtopic&p=22486#22486
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
I have confirmed that my command processor (CMD.EXE) allows commands to a maximum of 2K.  I have also confirmed that java.exe allows a classpath approaching that limit.  So I must conclude that something in the ANT tool is truncating the classpath at 1K.  In any event, the 2K limit imposed by CMD.EXE is far short of what I would need it to be to compile the JSPs in this fashion.  Since that limitation is not going to be solved in ANT or java.exe, I will close this question.  Thanks to all of you who contributed.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
8-)

There's probably a kludge that could be done for incremental compilation in a batch file
0
 
LVL 4

Expert Comment

by:schubach
Comment Utility
I found that adding %JAVA_HOME%/bin to my %PATH% environment variable allowed my ant script to succeed, whereas I had been getting the same error in the same situation described in this question.  I'm not 100% sure why this fixed things, but it was a suggestion from a co-worker and I wanted to share it with others who might have the same problem, because it seems to be a very elegant solution.
0
 
LVL 33

Author Comment

by:knightEknight
Comment Utility
Thanks!  This problem is ancient history to me now but I'll give it a try should it happen again.  :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now