This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 229353 - "At most one resource per module" when layer.xml included in Maven NB Platform app with CoS enabled
Summary: "At most one resource per module" when layer.xml included in Maven NB Platfor...
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.4
Hardware: Macintosh Mac OS X
: P2 normal with 1 vote (vote)
Assignee: Milos Kleint
URL:
Keywords: REGRESSION
Depends on:
Blocks: 257992
  Show dependency tree
 
Reported: 2013-05-04 20:40 UTC by ebakke
Modified: 2016-04-17 04:05 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ebakke 2013-05-04 20:40:12 UTC
This bug is related to the Compile on Save (CoS) functionality introduced for Maven-based NetBeans Platform Application/Module projects in current development versions of the IDE (I'm running version 201304242301).

To reproduce:
1) Create a new Maven-based NetBeans Application project. This creates a branding module, an application module, and a parent module. Verify that Compile on Save is supported and enabled in all of these projects (Properties->Build->Compile->Compile On Save).
2) Clean and build the parent project and run the application project once to ensure that everything works fine at this point.
3) Add a layer.xml file to the branding module (New->XML Layer).
4) Clean and build the parent module again (or each module individually; doesn't matter).
5) Run the application project. The error cited further below will occur.

Quoting Milos Kleint on 2013-04-26 in an email on platform-dev: "might be worth filing as issue. Or try a clean rebuild of the module causing trouble, maybe CoS kicked in and sources/resources got out of sync. Or the given feature has problems dealing with the patching approach we take to make the CoS work (we put the target/classes files on the classpath of the module)"

===================
INFO [org.netbeans.core.startup.NbEvents]: Module patch or custom extension: /Users/ebakke/Deletables/mavenproject2/branding/target/classes
java.lang.AssertionError: At most one resource per module: StandardModule:no.ebakke.sieuferd.mavenproject2.branding jarFile: /Users/ebakke/Deletables/mavenproject2/application/target/mavenproject2/mavenproject2/modules/no-ebakke-sieuferd-mavenproject2-branding.jar
	at org.netbeans.core.startup.NbInstaller.loadLayers(NbInstaller.java:614)
	at org.netbeans.core.startup.NbInstaller.loadImpl(NbInstaller.java:356)
	at org.netbeans.core.startup.NbInstaller.access$000(NbInstaller.java:105)
	at org.netbeans.core.startup.NbInstaller$1.run(NbInstaller.java:346)
	at org.openide.filesystems.FileUtil$2.run(FileUtil.java:431)
	at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127)
	at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:609)
	at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:415)
	at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:435)
	at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:343)
	at org.netbeans.ModuleManager.enable(ModuleManager.java:1186)
	at org.netbeans.ModuleManager.enable(ModuleManager.java:1009)
	at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:340)
	at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:276)
	at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:301)
	at org.netbeans.core.startup.Main.getModuleSystem(Main.java:181)
	at org.netbeans.core.startup.Main.getModuleSystem(Main.java:150)
	at org.netbeans.core.startup.Main.start(Main.java:307)
	at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)
	at java.lang.Thread.run(Thread.java:722)
===================
Comment 1 ebakke 2013-05-04 20:43:58 UTC
Note that if Compile on Save is disabled for the particular module with the layer.xml file in it, the problem goes away. Also note that the problem is not specific to branding modules.
Comment 2 ebakke 2013-05-04 20:45:45 UTC
Yet another addition to the instructions I gave to reproduce the bug: if the layer file is empty, a unit test will fail saying it's inefficient to have an empty layer file. Here's the layer file I used:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
    <folder name="Menu">
        <folder name="Tools">
            <file name="LibrariesCustomizerAction.shadow_hidden"/>
        </folder>
    </folder>
</filesystem>
Comment 3 Milos Kleint 2013-05-06 06:40:48 UTC
jtulach: could this be related to -J-Dnetbeans.patches.CNB=<path> property that we use in Compile on Save mode?
We set <path> to ${basedir}/target/classes which will not only contain class files but also all the resources, including layers etc.
Comment 4 Milos Kleint 2013-05-14 09:56:49 UTC
reassigning to module system
Comment 5 _ tboudreau 2013-06-23 23:56:02 UTC
Making this P2.  Check out the sources to https://imagine.java.net/ - it built before, now you have to open almost all of the child projects and disable compile-on-save on each one to make it runnable.  Quite the regression.

Oddly, this is a problem even after a clean-and-build cycle on the parent project.  Does compile-on-save interfere even with that?
Comment 6 Jaroslav Tulach 2013-07-09 17:04:22 UTC
The assertion error is eliminated by ergonomics#d73e6477f7c4 

However I had a problem with relative paths. Had to comment out:

--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -158,7 +158,7 @@
     private String projectToOutputDir(Project p, File basedir) {
         //attempt to resolve a relative path to save space on the cmd line..
         File f = new File(new File(FileUtil.toFile(p.getProjectDirectory()), "target"), "classes");
-        String toRet = FileUtilities.relativizeFile(basedir, f);
+        String toRet = null;//FileUtilities.relativizeFile(basedir, f);
         if (toRet == null) {
             toRet = f.getAbsolutePath();
         }

in CoSApplicationLateBoundChecker. Passing back to Maven.
Comment 7 Milos Kleint 2013-07-10 06:53:49 UTC
the problem with relative path is caused by fix for issue 231276. Apparently current directory of the running app is different on different OS. To see if -J-Dnetbeans.patches.CNB=<path> property is working (meaning if CoS is working) check in the output  of the app if the following line is present for your modules:

INFO [org.netbeans.core.startup.NbEvents]: Module patch or custom extension: /private/var/folders/46/zjq4yb7j4ml8gr6bkkfl94gm0000gn/T/mavenproject6/application/../mavenproject6-sample/target/classes


musilt2: can we have this tested on all the supported platforms? (currently on windows uses relative path but still)

http://hg.netbeans.org/core-main/rev/2a8ea251269d

jtulach: I suppose we can mark the issue as fixed?
Comment 8 Jaroslav Tulach 2013-07-10 08:07:07 UTC
> jtulach: I suppose we can mark the issue as fixed?

Yes, I believe the assert error problem is fixed now.
Comment 9 Quality Engineering 2013-07-11 04:12:24 UTC
Integrated into 'main-silver', will be available in build *201307102300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/2a8ea251269d
User: Milos Kleint <mkleint@netbeans.org>
Log: #229353, #231276 use relative path to output dir on windows only, different OS have different current directory when running
Comment 10 ebakke 2013-07-14 03:06:03 UTC
I just tried the latest development build--the bug is fixed indeed on my MacOS installation. A build that threw the error on the previous NetBeans Dev version worked fine once I installed the new one.

Thanks, guys! Compile-on-Save for maven-based module projects has been a huge timesaver for me.
Comment 11 ebakke 2013-07-14 08:06:41 UTC
Hmm, the fix removed the build error, but now I'm getting an exception every time I try to edit or browse a layer file node: http://statistics.netbeans.org/analytics/exception.do?id=680979

The exception is confirmed on MacOS with NB build 201307122300, when creating a fresh new Maven-based platform application and adding/viewing a layer file to a module (e.g. the branding module).
Comment 12 Milos Kleint 2013-07-14 09:54:33 UTC
that appears unrelated to the problem in this issue

(In reply to comment #11)
> Hmm, the fix removed the build error, but now I'm getting an exception every
> time I try to edit or browse a layer file node:
> http://statistics.netbeans.org/analytics/exception.do?id=680979
> 
> The exception is confirmed on MacOS with NB build 201307122300, when creating a
> fresh new Maven-based platform application and adding/viewing a layer file to a
> module (e.g. the branding module).
Comment 13 Quality Engineering 2013-07-17 02:40:36 UTC
Integrated into 'main-silver', will be available in build *201307162300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/d73e6477f7c4
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #229353: In case of using patches, take just the first layer, and go on without raising any errors