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 235492 - failed to create task or type nbundeploy on command line ANT clean: work from the IDE Clean
Summary: failed to create task or type nbundeploy on command line ANT clean: work from...
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 7.3.1
Hardware: PC Windows 8
: P4 normal (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-04 10:34 UTC by khinewhine
Modified: 2016-07-07 08:53 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (343.73 KB, text/plain)
2013-09-04 10:34 UTC, khinewhine
Details
output from the ant script as run from the command line (131.59 KB, text/plain)
2013-09-04 10:37 UTC, khinewhine
Details
Output from the ant clean -debug when run within the IDE (141.03 KB, application/octet-stream)
2013-09-04 10:39 UTC, khinewhine
Details
Piped output of ant clean -debug with comments at the bottom (135.31 KB, application/octet-stream)
2013-09-05 08:27 UTC, khinewhine
Details
Options Export (6.70 MB, application/octet-stream)
2013-09-06 09:30 UTC, khinewhine
Details
ant build script (3.65 KB, application/xml)
2013-09-06 09:49 UTC, khinewhine
Details
Project's wide definintions (4.81 KB, application/xml)
2013-09-06 09:49 UTC, khinewhine
Details
log file with a "ant clean" and without netbeans.home defined (239.17 KB, application/octet-stream)
2013-09-10 22:04 UTC, khinewhine
Details

Note You need to log in before you can comment on or make changes to this bug.
Description khinewhine 2013-09-04 10:34:26 UTC
Product Version = NetBeans IDE 7.3.1 (Build 201306052037)
Operating System = Windows 8 version 6.2 running on amd64
Java; VM; Vendor = 1.7.0_25
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.25-b01

The Ccommand line ant clean appears to bedependent upon :\Program Files\NetBeans 7.3.1\enterprise\ant\nblib\org-netbeans-modules-j2ee-ant.jar when it is not being parsed out, but this is referenced from the GUI Build
Comment 1 khinewhine 2013-09-04 10:34:36 UTC
Created attachment 139646 [details]
IDE log
Comment 2 khinewhine 2013-09-04 10:37:43 UTC
Created attachment 139647 [details]
output from the ant script as run from the command line
Comment 3 khinewhine 2013-09-04 10:39:52 UTC
Created attachment 139648 [details]
Output from the ant clean -debug when run within the IDE
Comment 4 David Konecny 2013-09-04 22:08:35 UTC
I'm not sure I understand your report. Are you saying that running Ant build from command line should not perform "undeploy-clean"? Otherwise it fails because org-netbeans-modules-j2ee-ant.jar is missing? Thanks for clarifying what's wrong behavious and what is expected correct behaviour.
Comment 5 khinewhine 2013-09-04 22:36:46 UTC
Hi David, thanks for getting back to me quickly.

My problem report is that the command line invocation of the clean targets aborts with an error and fails to clean the project; whilst Invoking the clean on that same project from the IDE's GUI menu completes the clean successfully.  I have attached ant traces that show this for both.

The undeploy activity should be consistent between the command line and that GUI invocations.  It is my view that the command line "ant clean" should do an undeploy to be consistent with the GUI.
Comment 6 khinewhine 2013-09-04 22:38:29 UTC
(Just going to send this again as a reply just to be confident you get notified correctly)
Hi David, thanks for getting back to me quickly.

My problem report is that the command line invocation of the clean targets aborts with an error and fails to clean the project; whilst Invoking the clean on that same project from the IDE's GUI menu completes the clean successfully.  I have attached ant traces that show this for both.

The undeploy activity should be consistent between the command line and that GUI invocations.  It is my view that the command line "ant clean" should do an undeploy to be consistent with the GUI.

(In reply to David Konecny from comment #4)
> I'm not sure I understand your report. Are you saying that running Ant build
> from command line should not perform "undeploy-clean"? Otherwise it fails
> because org-netbeans-modules-j2ee-ant.jar is missing? Thanks for clarifying
> what's wrong behavious and what is expected correct behaviour.
Comment 7 David Konecny 2013-09-04 22:54:32 UTC
Thanks. Unfortunately the second log ends when "undeploy-clean" is called and does not show any error message. What is the exact error message? What are the steps to reproduce the failure from command line?

I understand what you mean by consistency but it is more complicated. Running Ant build from command line is assumed to happen primarily when IDE is not avilable, eg. on continual builders like Hudson. Hence the need to support two different scenarios. I'm looking at how "undeploy-clean" is defined and it is conditional to "netbeans.home" property being set. And that property is automatically sent when Ant is executed from the IDE. You could try to do the same by running something like

ant -Dnetbeans.home="C:\Program Files\NetBeans 7.3.1\platform" ....
Comment 8 khinewhine 2013-09-05 08:25:41 UTC
(In reply to David Konecny from comment #7)
> Thanks. Unfortunately the second log ends when "undeploy-clean" is called
> and does not show any error message. What is the exact error message? What
> are the steps to reproduce the failure from command line?
> 
> I understand what you mean by consistency but it is more complicated.
> Running Ant build from command line is assumed to happen primarily when IDE
> is not avilable, eg. on continual builders like Hudson. Hence the need to
> support two different scenarios. I'm looking at how "undeploy-clean" is
> defined and it is conditional to "netbeans.home" property being set. And
> that property is automatically sent when Ant is executed from the IDE. You
> could try to do the same by running something like
> 
> ant -Dnetbeans.home="C:\Program Files\NetBeans 7.3.1\platform" ....

David,

There is a stack trace after the undeploy-clean that is sent to StdErr so ends up on the screen of the console.  Luckily this is reproduceable for me.  Please find another attachment to the issue.  You will see me setting the netbeans.home property if it is not set at startup within the ant.out file I attached.  Look for

"
Setting ro project property: netbeans.home -> C:\Program Files\NetBeans 7.3.1/platform
     [echo] Using NETBEANS_HOME envvar : netbeans.home[C:\Program Files\NetBeans 7.3.1/platform]
"
Comment 9 khinewhine 2013-09-05 08:27:58 UTC
Created attachment 139693 [details]
Piped output of ant clean -debug with comments at the bottom

Includes a stack trace copied from the Console
Comment 10 David Konecny 2013-09-05 22:38:29 UTC
I think the problem is that nobody before tried to do this hence this problem was not reported before. The problem based on your error message is that the Ant cannot find "nbundeploy" task definition. This task is defined in jar {nb.install}/enterprise/ant/nblib/org-netbeans-modules-j2ee-ant.jar which contains file antlib.xml defining the task as:

    <taskdef name="nbundeploy"
             classname="org.netbeans.modules.j2ee.ant.Undeploy"/>

I thought a simple wokraround would be to run ant with -lib param and specify folder with org-netbeans-modules-j2ee-ant.jar but that does not seem to be enough. I assume that when Ant script is executed from the IDE it is "pre-configure" with right classpath or tasks or something like that.

Other workaround would be to define above task in your build.xml.
Comment 11 khinewhine 2013-09-06 09:30:59 UTC
Created attachment 139746 [details]
Options Export

Here are my IDE options just in case they answer some needed questions
Comment 12 khinewhine 2013-09-06 09:49:16 UTC
Created attachment 139748 [details]
ant build script

Here is the build script I am using.  it reference a projects wide definintions script global.defines.xml which I will upload separately
Comment 13 khinewhine 2013-09-06 09:49:52 UTC
Created attachment 139749 [details]
Project's wide definintions
Comment 14 khinewhine 2013-09-06 10:29:00 UTC
Hi David,

I have tried to work out how the

/enterprise/ant/nblib/org-netbeans-modules-j2ee-ant.jar

library is being referenced from where and by what configuration.  But it appears that the GUI Build action from the menu invokes the ant script in way that is not immediately apparent.

From the command line I am depending upon the default target with ins "dist".  Maybe I should change the command line invocation to match the the GUI version?

I have attached my Options export and build scripts because I do not believe I am performing any specific configuration to get the nbundeploy defined in the GUI build or the command line build.  Thus the most likely alternative is the invocation is different?

Background:
My parts of our product integrate int a production make routine that is automated and command line only

Kevin

(In reply to David Konecny from comment #10)
> I think the problem is that nobody before tried to do this hence this
> problem was not reported before. The problem based on your error message is
> that the Ant cannot find "nbundeploy" task definition. This task is defined
> in jar {nb.install}/enterprise/ant/nblib/org-netbeans-modules-j2ee-ant.jar
> which contains file antlib.xml defining the task as:
> 
>     <taskdef name="nbundeploy"
>              classname="org.netbeans.modules.j2ee.ant.Undeploy"/>
> 
> I thought a simple wokraround would be to run ant with -lib param and
> specify folder with org-netbeans-modules-j2ee-ant.jar but that does not seem
> to be enough. I assume that when Ant script is executed from the IDE it is
> "pre-configure" with right classpath or tasks or something like that.
> 
> Other workaround would be to define above task in your build.xml.
Comment 15 David Konecny 2013-09-08 22:47:28 UTC
I would love to help you but after debugging this a bit more it is getting more and more complicated. The thing is that when Ant build is executed from IDE there is fairly lot of "magic" involved - classloader is set, classpath is set, list of Ant tasks which IDE knows about are loaded etc. That's what I saw when I was debugging it. Also when you run Ant script from the IDE you can see all these tasks getting loaded, eg:

parsing buildfile jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-ant-browsetask.jar!/org/netbeans/modules/ant/browsetask/antlib.xml
parsing buildfile jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-debugger-jpda-ant.jar!/org/netbeans/modules/debugger/jpda/ant/antlib.xml
parsing buildfile jar:file:/home/dev/main/nbbuild/netbeans/enterprise/ant/nblib/org-netbeans-modules-j2ee-ant.jar!/org/netbeans/modules/j2ee/ant/antlib.xml
parsing buildfile jar:file:/home/dev/main/nbbuild/netbeans/profiler/ant/nblib/org-netbeans-modules-profiler-nbimpl.jar!/org/netbeans/modules/profiler/nbimpl/antlib.xml
parsing buildfile jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-javawebstart.jar!/org/netbeans/modules/javawebstart/antlib.xml
parsing buildfile jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-java-source-ant.jar!/org/netbeans/modules/java/source/ant/antlib.xml

The reason for that is that these are internal NB tasks which do not have to be explicitely defined in the build script itself because in typical case they are needed only while IDE is running. I understand now why you are trying to use them from command line but it is not going to be easy. I tried to simply add to build.xml, eg.:

    <taskdef resource="org/netbeans/modules/j2ee/ant/antlib.xml"
             classpath="/home/dev/main/nbbuild/netbeans/enterprise/ant/nblib/org-netbeans-modules-j2ee-ant.jar" />

which should load nbundeploy task and few others. The problem is that it fails because the nbundeploy task itself depends on NetBeans support for server deployment which is additional closure of 10 to 20 jars which need to be added to classpath. If you find all those jars and add them to classpath then it will work but sorry I do not know which jars these are. You could try to define an Ant fileset including all jars from NB installation and it may just work. Or may not. Good luck.
Comment 16 khinewhine 2013-09-09 08:53:27 UTC
David,

That sounds like a rabbit hole I'd rather not go down from my position.

In terms of a workaround I believe I can handle the clean task manually.  Remove the build and dist directories and then remove the JAXB and Web Client build products.

The web server undeploy during a full product build activity is not critical, as it forms a bigger build script that compiles more modules and copies things to the needed places.

What does cause me a problem is the failure result from the build.xml that results in the controlling script aborting.  This stops the web server build and stop the entire product build.

For me the failure to undeploy is severe warning or non fatal error.

I am sure that my circumstances would not fit other folks is some or many ways.

I would prefer the GUI and command line variation of the ant invocation to be the same but as you have described there is a lot of "magic" logic that the IDE is performing.

Is there a way to detect a IDE build and avoid the dependency?

Kevin


(In reply to David Konecny from comment #15)
> I would love to help you but after debugging this a bit more it is getting
> more and more complicated. The thing is that when Ant build is executed from
> IDE there is fairly lot of "magic" involved - classloader is set, classpath
> is set, list of Ant tasks which IDE knows about are loaded etc. That's what
> I saw when I was debugging it. Also when you run Ant script from the IDE you
> can see all these tasks getting loaded, eg:
> 
> parsing buildfile
> jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-
> ant-browsetask.jar!/org/netbeans/modules/ant/browsetask/antlib.xml
> parsing buildfile
> jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-
> debugger-jpda-ant.jar!/org/netbeans/modules/debugger/jpda/ant/antlib.xml
> parsing buildfile
> jar:file:/home/dev/main/nbbuild/netbeans/enterprise/ant/nblib/org-netbeans-
> modules-j2ee-ant.jar!/org/netbeans/modules/j2ee/ant/antlib.xml
> parsing buildfile
> jar:file:/home/dev/main/nbbuild/netbeans/profiler/ant/nblib/org-netbeans-
> modules-profiler-nbimpl.jar!/org/netbeans/modules/profiler/nbimpl/antlib.xml
> parsing buildfile
> jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-
> javawebstart.jar!/org/netbeans/modules/javawebstart/antlib.xml
> parsing buildfile
> jar:file:/home/dev/main/nbbuild/netbeans/java/ant/nblib/org-netbeans-modules-
> java-source-ant.jar!/org/netbeans/modules/java/source/ant/antlib.xml
> 
> The reason for that is that these are internal NB tasks which do not have to
> be explicitely defined in the build script itself because in typical case
> they are needed only while IDE is running. I understand now why you are
> trying to use them from command line but it is not going to be easy. I tried
> to simply add to build.xml, eg.:
> 
>     <taskdef resource="org/netbeans/modules/j2ee/ant/antlib.xml"
>             
> classpath="/home/dev/main/nbbuild/netbeans/enterprise/ant/nblib/org-netbeans-
> modules-j2ee-ant.jar" />
> 
> which should load nbundeploy task and few others. The problem is that it
> fails because the nbundeploy task itself depends on NetBeans support for
> server deployment which is additional closure of 10 to 20 jars which need to
> be added to classpath. If you find all those jars and add them to classpath
> then it will work but sorry I do not know which jars these are. You could
> try to define an Ant fileset including all jars from NB installation and it
> may just work. Or may not. Good luck.
Comment 17 David Konecny 2013-09-10 00:21:01 UTC
Why cannot you use just "ant clean dist" without -Dnetbeans.home?

The undeploy during clean was added especially for Windows platform because on some servers deployed jars get locked during directory deployment and consequently removing these jars during rebuild can fail.
Comment 18 khinewhine 2013-09-10 19:29:30 UTC
David,

I will give this a try tomorrow morning GMT+1 time when I get back into the office.

Is there much chance of a work around for this being worked into the base code?

(In reply to David Konecny from comment #17)
> Why cannot you use just "ant clean dist" without -Dnetbeans.home?
> 
> The undeploy during clean was added especially for Windows platform because
> on some servers deployed jars get locked during directory deployment and
> consequently removing these jars during rebuild can fail.
Comment 19 David Konecny 2013-09-10 19:37:06 UTC
> Is there much chance of a work around for this being worked into the base
> code?

This sounds so far like a very specific one-off case so I'd tend to say No. Let's see if you can workaround it and once we know what the workaround is we could look into this again. The reality is that we have hundreds if not thousands of issues to address and resolve so at the end of the day you have to prioritize.

I would like to hear what exactly gets broken if you use simply "ant clean dist" without -Dnetbeans.home. That is what works for most of the users.
Comment 20 khinewhine 2013-09-10 22:04:06 UTC
Created attachment 139900 [details]
log file with a "ant clean" and without netbeans.home defined
Comment 21 khinewhine 2013-09-10 22:06:33 UTC
Hi David,

With no netbeans.home defined then a "ant clean" results is a clear build and dist directory as I desire them to be. With no errors reported.

If feel like you have found a satisfactory workaround.  You can see the -debug tracing in the attachment.

Kevin

(In reply to David Konecny from comment #19)
> > Is there much chance of a work around for this being worked into the base
> > code?
> 
> This sounds so far like a very specific one-off case so I'd tend to say No.
> Let's see if you can workaround it and once we know what the workaround is
> we could look into this again. The reality is that we have hundreds if not
> thousands of issues to address and resolve so at the end of the day you have
> to prioritize.
> 
> I would like to hear what exactly gets broken if you use simply "ant clean
> dist" without -Dnetbeans.home. That is what works for most of the users.
Comment 22 Martin Balin 2016-07-07 08:53:21 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss