Adam Bien's Weblog
How To Fix The libs.CopyLibs.classpath Problem in Netbeans 6.5
Recently I encountered the following error running a Java EE project from different Netbeans installation:
Z:\work\workspaces\winery\winery\nbproject\build-impl.xml:137: The following error occurred while executing this line:
Z:\work\workspaces\winery\winery\winery-war\nbproject\build-impl.xml:347: The libs.CopyLibs.classpath property is not set up.
This property must point to
org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part
of NetBeans IDE installation and is usually located at
<netbeans_installation>/java<version>/ant/extra folder.
Either open the project in the IDE and make sure CopyLibs library
exists or setup the property manually. For example like this:
ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar
I found only few pointers to the problem in the web. You will find a hint in the last line of the error report - you have to add the property libs.CopyLibs.classpath to the ant build.
It can be accomplished in menu: Tools --> Options --> Miscallenous --> Ant. Put the property libs.CopyLibs.classpath=[Netbeans Install]\NetBeans6.5\java2\ant\extra\org-netbeans-modules-java-j2seproject-copylibstask.jar (without -D). It should work after that.
I encounter the phenomenon few times. It seems like the error happens after upgrading the libraries (in my case icefaces 1.7.2 to 1.8.0), or running the ant build outside Netbeans in command shell, or continuus integration like hudson.
Posted at 09:00AM Apr 27, 2009 by Adam Bien in Java EE 5 Architectures And Idioms | Comments[19] | Views/Hits: 3949
*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier Tweet Follow @AdamBien



thats strange, netbeans adds the copylibs ant task usually to the libraries which enables building with ant outside NB. Never had any issues with this.
Posted by mbien on April 27, 2009 at 10:17 AM CEST #
Had issues few times:
1. Trying to run a checked-out Java EE Ant projects in Hudson.
2. Trying to build a project from a NB with different icefaces libraries
3. A team member tried to open a checked-in project (no idea why this happened)
There are only few pointers in the foras (or forums plural), without real answers. This hack seems to work. I posted it - now its persisted :-)
regards,
adam
Posted by Adam Bien on April 27, 2009 at 11:24 AM CEST #
Is your project using sharable libraries folder or not?
If it does not then check if libs.CopyLibs.classpath is defined in file {NetBeans-userdir}/build.properties. This file is autogenerated/updated after any change in IDE's Library Manager. I can imagine that a build from command line (after fresh checkout of the project from a VCS) will fail because project is not connected to IDE's userdir yet - that happens when you open it in the IDE and reference to above mentioned file is stored in private.properties as value of user.properties.file property.
If your project is using sharable libraries then situation is different and you should have a look at {project's-sharable-libraries-folder}/nblibraries.properties file which should contain the property. That property was added during project creation and because it is sort of internal jar required for building projects the property is rechecked during each project opening and recreated if necessary.
Posted by David Konecny on April 27, 2009 at 11:04 PM CEST #
@David,
in one case it was "just" a default Java EE project with IceFaces. Your response is the first good explanation of the problem :-)
Thanks!,
regards,
adam
Posted by Adam Bien on April 28, 2009 at 10:13 AM CEST #
If you want a truly interoperable project, i. e. one that can be checked out and built from the command-line or used by Eclipse guys, then you need to distribute the copylibs.jar with your project.
I put something like this in my build.xml:
<property name="libs.CopyLibs.classpath" value="bin/copylibstask.jar"/>
You won't then automatically get the newest version when you upgrade Netbeans, but you are not dependent on a local path anymore that might only exist on your machine.
Posted by 81.91.160.182 on April 29, 2009 at 05:40 PM CEST #
Superb answer thanks. I was worried since the day i started using 6.5 of netbeans.
Posted by Lava Kafle on June 16, 2009 at 10:02 AM CEST #
Hey,
thanks for this info, it happend to me while running check of updates in netbeans 6.7.
Posted by zeldi on August 13, 2009 at 11:52 AM CEST #
Thanks for the information.I was hitting my head over this problem and your resolution made my code run like a Rocket.
Cheers
Rajat Bhatnagar
Posted by Rajat Bhatnagar on September 19, 2009 at 07:41 AM CEST #
Fantastic.
I updated the build.xml file
<target name="-init-taskdefs">
<property name="libs.CopyLibs.classpath" value="bin/copylibstask.jar"/>
<fail unless="libs.CopyLibs.classpath">
..........
And it worked.
Posted by Saurabh Gupta on October 16, 2009 at 09:31 PM CEST #
hi, great post! i had the same problem after installing portal-pack netbeans plugins, but something is missing: i added the line libs.CopyLibs.classpath=Applications/NetBeans/NetBeans\ 6.7.1.app/Contents/Resources/NetBeans/java2/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
but i still have some reference problems, as asked at http://forums.netbeans.org/viewtopic.php?p=58354#58354 . Someone has a clue of what is going on? Thanks
Posted by mox601 on December 22, 2009 at 12:52 PM CET #
Thank you very much, this fixed my problem.
Today I accidentally started Netbeans 6.7 twice - which may or may not be related to the cause of the problem.
This was the solution.
Posted by Martin Jenkins on February 02, 2010 at 11:39 AM CET #
Thanks, your tip worked
Posted by 184.71.0.174 on January 12, 2011 at 04:55 AM CET #
Thanks a lot for this hint.
I was scratching my head looking for an answer.
cheers,
Posted by Joao Araujo on June 04, 2011 at 04:35 AM CEST #
I fixed the libs.CopyLibs.classpath but i get the following erro:
Refeitorio-ejb.compile:
Refeitorio-ejb.library-inclusion-in-manifest:
C:\refeitorio\Refeitorio\nbproject\build-impl.xml:160: The following error occurred while executing this line:
C:\refeitorio\Refeitorio\Refeitorio-ejb\nbproject\build-impl.xml:456: Problem: failed to create task or type copyfiles
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
How do I fix that?
Posted by Reudismam on June 21, 2011 at 02:48 PM CEST #
yes after restarting Netbeans IDE the problem is resolved :)
Posted by Chanchal on August 07, 2011 at 07:46 AM CEST #
This is the full string I had to use with NetBeans 7.0.1 in Mac OS X 10.6 Snow Leopard
libs.CopyLibs.classpath=/Applications/NetBeans/NetBeans 7.0.1.app/Contents/Resources/NetBeans/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
Posted by Steve on August 31, 2011 at 07:44 PM CEST #
Thanks.it worked.
Posted by Amrita deb on September 22, 2011 at 09:44 AM CEST #
For me worked copy the properties of nbproject/private/private.properties into the project.properties.
Or you can also follow this tutorial:
http://weblogs.java.net/blog/fabriziogiudici/archive/2006/11/setting_up_netb.html
The thing is that the build-impl generated have references to those properties.
Posted by jlich on January 19, 2012 at 07:08 PM CET #
it worked adding
<property name="libs.CopyLibs.classpath" value="bin/copylibstask.jar"/>
in build-impl.xml
Posted by bs on January 27, 2012 at 04:59 PM CET #