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 117909 - [60cat] Error while creating JAR: Cannot read referenced JAR
Summary: [60cat] Error while creating JAR: Cannot read referenced JAR
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P4 blocker (vote)
Assignee: Jan Jancura
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-05 13:39 UTC by tboerkel
Modified: 2009-11-02 11:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
project files (17.18 KB, application/x-compressed)
2007-10-05 14:16 UTC, tboerkel
Details
Ant debug output. (68.72 KB, application/x-compressed)
2007-10-24 13:05 UTC, tboerkel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tboerkel 2007-10-05 13:39:19 UTC
[ BUILD # : 200710050000 ]
[ JDK VERSION : 1.6.0_03 ]

We have JAR files that we are using in our J2SE project in the src
folder. This may not be recommended, but is still legal AFAIK (was
common usage in the NB 3.x days). 

Now, when NB tries to create a JAR of the app at the end of the build
process, it tries to read the JAR files from the root of the
filesystem (D:\ in my case), not from the real location, resulting in
an error and not including any JAR files at all in the resulting app
JAR.

NB 5.x works correct here, so it's a regression.

Error message in the build console:
D:\activation.jar is a directory or can't be read. Not copying the
libraries.
Comment 1 Milos Kleint 2007-10-05 14:01:59 UTC
please include the complete build output. A sample project demonstrating the problem would help as well.

I didn't understand how your project is setup, especially the part about putting jar files in the src directory. The
reference to 3.x setup is irrelevant.
Comment 2 tboerkel 2007-10-05 14:14:59 UTC
I cannot reproduce it in a small sample project, so I am attaching the project files from our real app.

This is the complete build output:
init:
deps-jar:
Compiling 1 source file to D:\P2plus\Trunk\AppServer\P2Java
compile:
D:\activation.jar is a directory or can't be read. Not copying the libraries.
Building jar: D:\P2plus\Trunk\AppServer\dist\AppServerTrunk.jar
Not copying the libraries.
To run this application from the command line without Ant, try:
D:\jdk6.0/bin/java -jar "D:\P2plus\Trunk\AppServer\dist\AppServerTrunk.jar"
jar:
BUILD SUCCESSFUL (total time: 28 seconds)
Comment 3 tboerkel 2007-10-05 14:16:26 UTC
Created attachment 50266 [details]
project files
Comment 4 Milos Kleint 2007-10-24 12:27:37 UTC
the properties files content looks ok.
I noticed you have edited the build-impl.xml and are keeping a backup around. Why?

The problem seems to be somewhere in property resolution. The value from private.properties
(file.reference.activation.jar=D:\\P2plus\\Trunk\\AppServer\\P2Java\\activation.jar) should be taken first. Do you have
such file on your computer?

Can you try running your app's build with Ant verbosity level set to "debug" and attach the output to the issue? The
verbosity level is set in the Tools/Options dialog under Miscelaneous/Ant

Thanks a lot.
Comment 5 tboerkel 2007-10-24 13:04:44 UTC
I have made a backup when I switched from NB 5.5.1 to NB 6.0 but I have not manually edited build-impl.xml.

The file "D:\P2plus\Trunk\AppServer\P2Java\activation.jar" exists.

Now I see that the JAR files actually are being added to the resulting AppServer.jar, so it works as expected. AFAIR
this was not the case with Beta 1.

However I still get that strange warning "D:\activation.jar is a directory or can't be read. Not copying the
libraries.". Actually, it does not have to copy the JAR files to some sub folder of \dist, because they are in the
classpath and so are being added to the JAR as all other files in the classpath. But ant or NB does not seem to
recognize this correctly.

Attaching ant debug output.
Comment 6 tboerkel 2007-10-24 13:05:35 UTC
Created attachment 51567 [details]
Ant debug output.
Comment 7 Milos Kleint 2007-10-24 14:35:34 UTC
the relevant portion of the build output:

-do-jar-with-libraries:

Setting project property: build.classes.dir.resolved -> D:\P2plus\Trunk\AppServer\P2Java

Set property run.classpath.without.build.classes.dir =
\activation.jar;\axis.jar;\commons-discovery.jar;\commons-httpclient.jar;\commons-logging.jar;\comwrapper.jar;\icemh.jar;\izmcomjni.jar;\jaxrpc.jar;\js.jar;\log4j.jar;\mail.jar;\saaj.jar;\simultan.jar;\simultan70.jar;\simultan80.jar;\svnjavahl.jar;\swing-layout.jar;\tools.jar;\Una2000.jar;\varial.jar;\varial245.jar;\varial250.jar;\varial270.jar;\webdavlib.jar;\wsdl4j.jar;\xalan.jar;\xercesImpl.jar;\xmlParserAPIs.jar;\jdom.jar;\rome-0.9.jar;\css.jar;\jtds.jar;\commons-io-1.3.2.jar;\mysql-connector-java-5.0.7-bin.jar;\junit.jar;\apcommon.jar;

Setting project property: run.classpath.without.build.classes.dir ->
\activation.jar;\axis.jar;\commons-discovery.jar;\commons-httpclient.jar;\commons-logging.jar;\comwrapper.jar;\icemh.jar;\izmcomjni.jar;\jaxrpc.jar;\js.jar;\log4j.jar;\mail.jar;\saaj.jar;\simultan.jar;\simultan70.jar;\simultan80.jar;\svnjavahl.jar;\swing-layout.jar;\tools.jar;\Una2000.jar;\varial.jar;\varial245.jar;\varial250.jar;\varial270.jar;\webdavlib.jar;\wsdl4j.jar;\xalan.jar;\xercesImpl.jar;\xmlParserAPIs.jar;\jdom.jar;\rome-0.9.jar;\css.jar;\jtds.jar;\commons-io-1.3.2.jar;\mysql-connector-java-5.0.7-bin.jar;\junit.jar;\apcommon.jar;

Set property jar.classpath = lib/activation.jar lib/axis.jar lib/commons-discovery.jar lib/commons-httpclient.jar
lib/commons-logging.jar lib/comwrapper.jar lib/icemh.jar lib/izmcomjni.jar lib/jaxrpc.jar lib/js.jar lib/log4j.jar
lib/mail.jar lib/saaj.jar lib/simultan.jar lib/simultan70.jar lib/simultan80.jar lib/svnjavahl.jar lib/swing-layout.jar
lib/tools.jar lib/Una2000.jar lib/varial.jar lib/varial245.jar lib/varial250.jar lib/varial270.jar lib/webdavlib.jar
lib/wsdl4j.jar lib/xalan.jar lib/xercesImpl.jar lib/xmlParserAPIs.jar lib/jdom.jar lib/rome-0.9.jar lib/css.jar
lib/jtds.jar lib/commons-io-1.3.2.jar lib/mysql-connector-java-5.0.7-bin.jar lib/junit.jar lib/apcommon.jar

Setting project property: jar.classpath -> lib/activation.jar lib/axis.jar lib/commons-discovery.jar
lib/commons-httpclient.jar lib/commons-logging.jar lib/comwrapper.jar lib/icemh.jar lib/izmcomjni.jar lib/jaxrpc.jar
lib/js.jar lib/log4j.jar lib/mail.jar lib/saaj.jar lib/simultan.jar lib/simultan70.jar lib/simultan80.jar
lib/svnjavahl.jar lib/swing-layout.jar lib/tools.jar lib/Una2000.jar lib/varial.jar lib/varial245.jar lib/varial250.jar
lib/varial270.jar lib/webdavlib.jar lib/wsdl4j.jar lib/xalan.jar lib/xercesImpl.jar lib/xmlParserAPIs.jar lib/jdom.jar
lib/rome-0.9.jar lib/css.jar lib/jtds.jar lib/commons-io-1.3.2.jar lib/mysql-connector-java-5.0.7-bin.jar lib/junit.jar
lib/apcommon.jar

Finding class org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs

Loaded from D:\Program Files\NetBeans 6.0 Beta 2\java1\ant\extra\org-netbeans-modules-java-j2seproject-copylibstask.jar
org/netbeans/modules/java/j2seproject/copylibstask/CopyLibs.class

Class org.apache.tools.ant.taskdefs.Jar loaded from parent loader (parentFirst)

Class org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs loaded from ant loader (parentFirst)

Class java.lang.Object loaded from parent loader (parentFirst)

Class java.lang.Throwable loaded from parent loader (parentFirst)

Class java.lang.AssertionError loaded from parent loader (parentFirst)

Class java.lang.ClassNotFoundException loaded from parent loader (parentFirst)

Class java.io.IOException loaded from parent loader (parentFirst)

Class org.apache.tools.ant.BuildException loaded from parent loader (parentFirst)

Class java.io.Writer loaded from parent loader (parentFirst)

Class java.io.FileWriter loaded from parent loader (parentFirst)

Class java.util.ResourceBundle loaded from parent loader (parentFirst)

Class java.io.File loaded from parent loader (parentFirst)

Class java.lang.Class loaded from parent loader (parentFirst)

 +Datatype copylibs org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs

Class org.apache.tools.ant.types.Path loaded from parent loader (parentFirst)

Class java.lang.StringBuffer loaded from parent loader (parentFirst)

D:\activation.jar is a directory or can't be read. Not copying the libraries.

fileset: Setup scanner in dir D:\P2plus\Trunk\AppServer\P2Java with patternSet{ includes: [] excludes: [] }



reassigning to tzezula.
Comment 8 Tomas Zezula 2007-11-02 13:59:03 UTC
I've found what is the problem. The project builds into the same folder where the jar files are located, the Ant
<pathcovert> uses prefix to match the path element, it removes the build path even from libraries. I doubt there is a
general nice solution using Ant on JDK 5.0 without script engine. Anyway the build finishes correctly, only the
Class-Path attribute in the jar files has wrong paths, in the NB 3.x there was no such a feature.
Anyway there is quite easy fix you can do if you are using JDK 6.
You have to override the "-do-jar-with-libraries" target (copy it into build.xml form build-impl.xml) and change the
first <pathconvert> to:

<pathconvert property="run.classpath.without.build.classes.dir">
    <path path="${run.classpath}"/>
    <scriptmapper language="javascript">
        if (!source.equals(project.getProperty("build.classes.dir.resolved"))) {
            self.addMappedName(source);
        }
    </scriptmapper>
</pathconvert>

When the NetBeans will come with some script engine I will put it into the build-impl.
Comment 9 Jesse Glick 2007-11-02 15:19:42 UTC
Try:

        <pathconvert property="run.classpath.without.build.classes.dir">
            <path path="${run.classpath}"/>
            <regexpmapper from="^\Q${build.classes.dir.resolved}\E$|(.*)" to="\1"/>
        </pathconvert>
Comment 10 Jesse Glick 2007-11-02 15:24:18 UTC
Note that this style will not work for Windows users who have folder names beginning with a capital 'E'. Such is the
pleasure of Ant.
Comment 11 Tomas Zezula 2007-11-02 17:50:27 UTC
Work fine on Linux, but as it doesn't work on Windows when the folder name satarts with 'E' I am not going to add it
into the NB 6.0.
Comment 12 David Strupl 2009-03-31 16:02:50 UTC
Resolving all issues with milestone "future" as LATER. If you feel strongly that
it should be implemented please reopen and set the target milestone to "next".
Comment 13 Quality Engineering 2009-11-02 11:02:50 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX