aspose file tools*
The moose likes Cattle Drive and the fly likes Ant building error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Ant building error" Watch "Ant building error" New topic
Author

Ant building error

Richard Broersma
Ranch Hand

Joined: Apr 28, 2009
Posts: 63

I'm trying for first attempt at building a WAR file using ANT. While following the instructions, I'm getting an error that indications to me that the classpath isn't being set to see the javaee.jar.



However, when I check the location where I was instructed to place the javaee.jar file, I see that it is there.



Does anyone have any thoughts about we my problem is?

The following is the build.xml contents:

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I checked your build.xml against mine, and I see a naming difference for the j2ee.jar file. Where your file is named javaee.jar, I have a file named j2ee.jar. Maybe the name of the file has something to do with it?
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Uhh, forgive me for asking, but did you put javaee.jar in your Classpath?
Richard Broersma
Ranch Hand

Joined: Apr 28, 2009
Posts: 63

Carol Murphy wrote:Where your file is named javaee.jar, I have a file named j2ee.jar. Maybe the name of the file has something to do with it?

It could be, but the name in the ant script matches the name of the jar file on the file system. So I hope it would see it correctly.

Carol Murphy wrote:Uhh, forgive me for asking, but did you put javaee.jar in your Classpath?

I don't have the classpath variable set as an environment variable. When calling java or javac I specify the classpath using the -cp flag. However, I didn't see a way to supply the classpath at the command line when call the ant script.

I'm not an expert at ant scripts, but I thought ant would find the appropriate file classpath from my understanding of this ant script code snippet:
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
The following is copied from the Cattle Drive instructions for Servlets:

Download the J2EE SDK(Java 2 Enterprise Edition Software Development Kit) from Sun, and install it. It is a supplement to the JDK you already have installed. You need to include the javaee.jar in your classpath.

You may need to add javvee.jar to your classpath variable.
Richard Broersma
Ranch Hand

Joined: Apr 28, 2009
Posts: 63

Carol Murphy wrote:Download the J2EE SDK(Java 2 Enterprise Edition Software Development Kit) from Sun, and install it. It is a supplement to the JDK you already have installed.
When I go to the link for Enterprise Edition Software Development Kit I see that they only have J6EE rather than J2EE. I hope that's okay. I do know that when manually complying these files use JAVAC with the appropriately supplied -cp parameter, the compile is successful. It's only ANT that is having a hard time complying and not seeing javaee.jar.

Carol Murphy wrote:You need to include the javaee.jar in your classpath. ... You may need to add javvee.jar to your classpath variable.
Do you mean setting it as an environment variable? When reading the ANT documentation, it mentions that the CLASSPATH should be left unset as mentioned in the Windows Note:.

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Grasping at straws here, but did you look inside the copy of javaee.jar inside of your app to verify that it contains the files that ANT can't locate? Maybe the jar file was corrupted somehow?
Richard Broersma
Ranch Hand

Joined: Apr 28, 2009
Posts: 63

Grasping at straws here, but did you look inside the copy of javaee.jar inside of your app to verify that it contains the files that ANT can't locate? Maybe the jar file was corrupted somehow?
I was able to verify that the javaee.jar file is good. I spent some time to familiarize myself with ANT and I discovered some interesting things about this problem. I used the command, which produced all of the options that ANT was passing to javac. When I manually constructed these options for this compilation I get the same error that ANT does:


However, if I change the -classpath to point to my glassfish installation of javaee.jar it compiles correctly.



Since the javaee.jar in my lib dir is a direct (and repeated refreshed) copy of the javaee.jar in the glassfish lib directory, I suspect there is another reason why the compilation is failing. Could it be the modern versions of javaee.jar rely on peer jar file in the glashfish lib directory?

Any thoughts?
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
Way over my pay grade. What else do you have in the glassfish\lib directory that isn't in the java\bee\lib\development directory?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Richard Broersma wrote:command, which produced all of the options that ANT was passing to javac. When I manually constructed these options for this compilation I get the same error that ANT does:




Having Java programs or jars in a folder containing spaces in its path isn't recommended. So try moving out your program and the jars from C:\Documents and Settings\rbroersma to maybe C:\rbroersma.


[My Blog] [JavaRanch Journal]
Richard Broersma
Ranch Hand

Joined: Apr 28, 2009
Posts: 63

I copied the bee folder upto the root directory. Now there are no spaces in the classpath. It looks like I'm still getting the same error.

The following is the result when I try to compile with javaee.jar in my lib directory versus having javaee.jar in the glashfish\lib directory:

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Richard Broersma wrote:
Since the javaee.jar in my lib dir is a direct (and repeated refreshed) copy of the javaee.jar in the glassfish lib directory, I suspect there is another reason why the compilation is failing. Could it be the modern versions of javaee.jar rely on peer jar file in the glashfish lib directory?

Any thoughts?


I should have checked this before. I just looked at my glassfish installation and that specific jar and it turns out to be a MANIFEST only jar file. What this means is the javaee.jar doesn't have any classes within itself, but has a META-INF/MANIFEST.MF file which has a ClassPath attribute which points to (relative) locations of other jars containing the relevant classes. So if you copy that javaee.jar from the glassfish/lib to some of the place, you'll also have to copy the other jars referenced in the ClassPath attribute to appropriate locations so that the relative paths specified there can work. For example, the MANIFEST.MF of that jar contains:

So wherever you copy that jar, you'll also need to create the "modules" folder at the right location and then copy over the other jars too.

The reason why this works if you just point to the glassfish/lib/javaee.jar (without moving it to some other folder) is because the relative paths of the referenced jars holds good.
Richard Broersma
Ranch Hand

Joined: Apr 28, 2009
Posts: 63

Thanks! That fix it:



Now regarding the instruction in the Cattle Drive (i.e. Tree struction and files to be copied), should these instructions be amended considering the makeup of modern versions of glassfish?
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1197
I love a happy ending. Sigh.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant building error