Bug 216841 - Build NBMs hangs
Build NBMs hangs
Product: apisupport
Classification: Unclassified
Component: Harness
All All
: P1 (vote)
Assigned To: Jaroslav Tulach
Depends on:
  Show dependency treegraph
Reported: 2012-08-14 07:41 UTC by johan_walter
Modified: 2015-01-27 14:05 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT

Project Suite (4.48 MB, application/zip)
2012-08-14 07:41 UTC, johan_walter

Note You need to log in before you can comment on or make changes to this bug.
Description johan_walter 2012-08-14 07:41:06 UTC
Created attachment 123079 [details]
Project Suite

In Netbeans 7.1 and 7.2 I no longer can create NBMs files for all my modules.
It worked fine in Netbeans 7.0.

Please unzip the attached file and select "Package as NBMs".
After the following printout, the build hangs.

ant -f /home/jw/NetBeansProjects/TestSuite nbms
Created dir: /home/jw/NetBeansProjects/TestSuite/build/cluster/config/Modules
Created dir: /home/jw/NetBeansProjects/TestSuite/build/updates
Created dir: /home/jw/NetBeansProjects/TestSuite/Oracle Help/build
Created dir: /home/jw/NetBeansProjects/TestSuite/build/public-package-jars
Scanning for modules in /usr/share/netbeans/netbeans-7.2/nb
Scanning for modules in /usr/share/netbeans/netbeans-7.2/harness
Scanning for modules in /usr/share/netbeans/netbeans-7.2/ide
Scanning for modules in /usr/share/netbeans/netbeans-7.2/apisupport
Scanning for modules in /usr/share/netbeans/netbeans-7.2/profiler
Scanning for modules in /usr/share/netbeans/netbeans-7.2/javafx
Scanning for modules in /usr/share/netbeans/netbeans-7.2/websvccommon
Scanning for modules in /usr/share/netbeans/netbeans-7.2/platform
Scanning for modules in /usr/share/netbeans/netbeans-7.2/java
Scanning for modules in suite /home/jw/NetBeansProjects/TestSuite
Created dir: /home/jw/NetBeansProjects/TestSuite/Oracle Help/build/classes
Compiling 2 source files to /home/jw/NetBeansProjects/TestSuite/Oracle Help/build/classes
warning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning
Copying 1 file to /home/jw/NetBeansProjects/TestSuite/Oracle Help/build/classes
Created dir: /home/jw/NetBeansProjects/TestSuite/build/cluster/modules
Building jar: /home/jw/NetBeansProjects/TestSuite/build/cluster/modules/com-mercur-help.jar
Copying 5 files to /home/jw/NetBeansProjects/TestSuite/build/cluster
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.CachingControl
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.CachingControlEvent
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.ControllerClosedEvent
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.ControllerErrorEvent
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.ControllerListener
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.EndOfMediaEvent
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.Manager
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.MediaLocator
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.NoPlayerException
Warning: ice.pilots.jmf.ThePilot cannot access javax.media.Player
(additional warnings not reported)
0 file(s) have been successfully validated.
Generating Auto Update information for com.mercur.help
Comment 1 Jaroslav Tulach 2012-08-15 09:17:06 UTC
The build succeeded on my computer:

Building jar: /home/jarda/tmp/TestSuite/build/updates/com-mercur-help.nbm
Not signing NBM file /home/jarda/tmp/TestSuite/build/updates/com-mercur-help.nbm; no stored-key password provided or keystore (/home/jarda/tmp/TestSuite/Oracle Help/${keystore}) doesn't exist
Creating update description /home/jarda/tmp/TestSuite/build/updates/updates.xml
Creating group "null"
Creating group "Help"
 Adding module Oracle Help (/home/jarda/tmp/TestSuite/build/updates/com-mercur-help.nbm)
BUILD SUCCESSFUL (total time: 34 seconds)

Try to generate stacktrace of the Ant process (Ctrl+\ on Unix or using jvisualvm), so we know what the build is waiting for in your case.
Comment 2 Geertjan Wielenga 2012-08-15 10:26:15 UTC
I am able to reproduce the problem too.
Comment 3 anders_ahlgren 2012-08-21 13:21:32 UTC
It is "pack200" that is hanging with stack:

"main" prio=5 tid=0x00007f8f79803800 nid=0x10bea1000 runnable [0x000000010bea0000]
   java.lang.Thread.State: RUNNABLE
	at java.io.FileOutputStream.writeBytes(Native Method)
	at java.io.FileOutputStream.write(FileOutputStream.java:318)
	at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
	- locked <0x00000007df6039e0> (a java.io.BufferedOutputStream)
	at java.io.PrintStream.write(PrintStream.java:480)
	- locked <0x00000007df6039c0> (a java.io.PrintStream)
	at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
	at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
	at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
	- locked <0x00000007df603b10> (a java.io.OutputStreamWriter)
	at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
	at java.io.PrintStream.write(PrintStream.java:527)
	- locked <0x00000007df6039c0> (a java.io.PrintStream)
	at java.io.PrintStream.print(PrintStream.java:669)
	at sun.util.logging.PlatformLogger$LoggerProxy.doLog(PlatformLogger.java:365)
	at sun.util.logging.PlatformLogger.warning(PlatformLogger.java:235)
	at com.sun.java.util.jar.pack.Utils$Pack200Logger.warning(Utils.java:194)
	at com.sun.java.util.jar.pack.Utils$Pack200Logger.warning(Utils.java:198)
	at com.sun.java.util.jar.pack.PackerImpl$DoPack.readClass(PackerImpl.java:519)
	at com.sun.java.util.jar.pack.PackerImpl$DoPack.run(PackerImpl.java:485)
	at com.sun.java.util.jar.pack.PackerImpl.pack(PackerImpl.java:99)
	at com.sun.java.util.jar.pack.Driver.main(Driver.java:311)

I also took a heap dump, and dug around some in that. It is attempting to write to System.err and what it is trying to write is:

aug 21, 2012 12:47:26 EM com.sun.java.util.jar.pack.Utils$Pack200Logger warning\u000aWARNING: Passing class file uncompressed due to unrecognized attribute: ice/mozilla/javascript/ClassNameHelper.class\u000a
Comment 4 anders_ahlgren 2012-08-23 09:04:43 UTC
It turns out that Java version matters. It works fine with Java 6 but hangs with Java 7 (at least in Netbeans 7.1.2).
Comment 5 Jaroslav Tulach 2012-08-24 12:32:26 UTC
As pack200 is also java process, it may make sense to generate its stacktrace with jstack and report bug to JDK.
Comment 6 westrick85 2015-01-27 14:05:05 UTC
The MakeNBM ant task doesn't read the stdout or stderr of the child pack200 processes. If pack200 generates too much output, it will hang because the output buffers are full. 

The MakeNBM ant task launches pack200 using ProcessBuilder/Process. It starts the pack200 and then immediately waits for it to complete like so (NB 7.3.1 code snippet of org.netbeans.nbbuild.MakeNBM):
                Process process = pb.start();
                result = process.waitFor();

If pack200 generates too much output to either of these streams, it will block until the parent process reads stdout or stderr to create more room in the output buffers. But as you can see from that code, the parent process is blocked waiting for the child to complete. 

This is why the NBM ant target can hang. Normally, pack200 doesn't generate a lot of output, but some jar files can cause it to generate a lot of warnings. I experienced this in NetBeans 7.3.1 using JDK 7u72 with a module that wrapped a spring framework jar. Pack200  generates multiple warnings with the text "WARNING: Passing class file uncompressed due to unrecognized attribute".

Killing the pack200 process will let the NBM task continue, but I don't know if the resulting NBM is valid.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo