Reputation: 802
For months now I've been having an intermittent problem where, during my ant build, one of the jar files it produces is 0 bytes in size. This 0-byte jar file ends up getting packaged in my ear file, and the subsequent deployment fails. My project structure looks like this:
myProj
myProj-common
myProj-ejb
myProj-web
The resulting build directory contains these files
lib
myProj-common.jar <-- sometimes 0 bytes
META-INF
application.xml
MANIFEST.MF
myProj-common.jar <-- never 0 bytes
myProj-ejb.jar
myProj-web.war
It is the myProj-common.jar file in lib that is 0 bytes. The one in the main build directory is always the correct size. It's unclear to me why I have two copies of the jar file in the end result. All of the ant build scripts were automatically generated by NetBeans.
I'm still learning the ins and outs of ant build files, so it's not entirely clear to me why they're so complex. I've written a somewhat minimal alternate build.xml file that I use for building the software in our Hudson environment on a Solaris server. That build never has this problem.
After upgrading from NetBeans 7.0.1 to 7.1.1, the problem has gotten a lot more frequent, and occurs whether I build the project inside of NetBeans or on the command line. The system where I'm having this problem runs Windows XP. With NB 7.0.1 I had a bad build perhaps one time in six. Now I have a -good- build maybe one time in ten.
Any pointers on where I should be looking to debug this would be most appreciated.
Upvotes: 1
Views: 1745
Reputation: 1
I found a solution to this problem here: https://netbeans.org/bugzilla/show_bug.cgi?id=216033
In my case (Nebeans 8.0.2), it was enough to uncheck "Compile on Save" checkbox for my enterprise application. (Project properties -> Compile -> Compile on Save)
Upvotes: 0
Reputation: 1138
I know it's an old question, but sharing mi experience maybe help someone.
I've had the same issue with netbeans 8.0.2 on linux, my enterprise project lib folder look like this:
~/NetBeansProjects/myeeproject/build/lib $ ls -l
-rw-rw-r-- 1 user1 user1 16013 jan 5 11:52 my_lib.jar
-rw-rw-r-- 1 user1 user1 1489258 jan 5 11:52 my_ws_lib.jar
-rw-rw-r-- 1 user1 user1 0 jan 5 11:52 commons-lang3-3.1.jar
-rw-rw-r-- 1 user1 user1 0 jan 5 11:52 itextpdf-5.4.5.jar
-rw-rw-r-- 1 user1 user1 0 jan 5 11:52 primefaces-4.0.jar
-rw-rw-r-- 1 user1 user1 0 jan 5 11:52 primefaces-extensions-1.1.0.jar
and I cannot deploy the project to glassfish server. Doing repeately clean & build sometimes solve the problem, sometimes not, but I've found that deleting the 0-bytes jar and then doing a build (or a deploy) works every time. The problem is that if there's a file already in place netbeans simply does not copy the library, it doesn't check filesize, so deleting it force netbeans to do a fresh copy.
bye
Upvotes: 1
Reputation: 108
I had been having a similar issue happen to me lately as well. Just to summarize, I have an EAR file which contains a few EJB files and a WAR file. I am in a Windows 7 64-bit environment with Netbeans 7.2 and I run on a local JBoss 7 server.
I have seen this happen when I do one of two things.
I have encountered this issue so many times, it's not even funny now. I don't know if I have the exact same problem as you, but here is what solved my issue.
After removing any jars or libraries, you must clean and build. When I remove any JAR file or library, I see empty jars end up in my EAR's lib folder. Cleaning this will help reduce your issue.
Here's the main thing that happens to me.
Clean and Build ONLY the project(s) that has the size of zero. Then select "Build" and not "Clean and Build" on your EAR file. I hope this helps.
I can only theorize that the EJB is being built twice since it's a dependency in my WAR file, and it gets copied into the /lib folder during the second build. I have not done any ant debugging, only have found that this is a solution to my problem.
Summary: Clean and Build properly and make sure you are "Clean and Build"-ing the projects that end up as size 0 in your lib folder, then hit "Build" only on your EAR file.
Good luck!
Upvotes: 0
Reputation: 802
This appears to be a conflict with our whole-disk encryption software, PGP Desktop. Recently it was running in a degraded mode on my laptop, which slowed my builds down considerably, but then I never saw the problem arise. My speculation is that this left time for the lower level drivers to complete whatever actions they were taking and flush their write buffers. It looks like right now the jar file is getting copied before the write buffer flushes and therefore a 0-byte file is getting copied. Ant never sees an error, which is why there's no failure in the build process.
Unfortunately there's not much I can do, except perhaps modify the build script to throw in a delay before the jar file gets copied. Right now my workaround is to manually copy the jar after a full Clean and Build, then run Build (as opposed to Clean and Build), which only takes a few seconds to repackage the ear file.
I think the reason the problem got more prevalent when I upgraded NetBeans is that some change in the IDE made the builds run faster, and thus I ran into the buffering problem more often.
Upvotes: 0
Reputation: 21130
You should be able to figure out what's happening by executing Ant with the -d (debug) and -v (verbose) flags. You could either add these flags in NetBeans, or execute the build file generated by NetBeans from the command line.
Upvotes: 0