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 106153 - mobility/ant-ext includes Ant classes in the module JAR
Summary: mobility/ant-ext includes Ant classes in the module JAR
Status: RESOLVED WONTFIX
Alias: None
Product: javame
Classification: Unclassified
Component: Build System (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Adam Sotona
URL:
Keywords: ARCH
Depends on:
Blocks:
 
Reported: 2007-06-08 19:09 UTC by Jesse Glick
Modified: 2007-08-20 09:10 UTC (History)
0 users

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 Jesse Glick 2007-06-08 19:09:45 UTC
mobility8/modules/org-netbeans-modules-mobility-antext.jar includes various Ant
tasks. But this is supposed to be a NB module, which cannot directly access Ant
at runtime. The tasks should either

1. Be moved into mobility8/ant/nblib/org-netbeans-modules-mobility-antext.jar,
if they are intended to be run only from inside the IDE.

2. Be moved into a separate JAR file which is not directly referenced (via
Class-Path) from the module. This would conventionally be in
mobility8/ant/extra/*.jar.

The current position causes a problem when running with

  -J-Dnetbeans.preresolve.classes=true

(see nbbuild/build.xml#sanity-start), e.g.

INFO [org.netbeans.core.modules]: Pre-resolving classes for all loaded
modules...be sure you have not specified -J-Xverify:none in ide.cfg
WARNING [org.netbeans.core.modules]: From
org.netbeans.mobility.antext.ExtractTask in org.netbeans.modules.mobility.antext
with effective classpath
/space/jdk1.5.0_11/jre/lib/rt.jar:/space/jdk1.5.0_11/jre/lib/i18n.jar:/space/jdk1.5.0_11/jre/lib/sunrsasign.jar:/space/jdk1.5.0_11/jre/lib/jsse.jar:/space/jdk1.5.0_11/jre/lib/jce.jar:/space/jdk1.5.0_11/jre/lib/charsets.jar:/space/jdk1.5.0_11/jre/classes:/space/jdk1.5.0_11/jre/lib/ext/localedata.jar:/space/jdk1.5.0_11/jre/lib/ext/dnsns.jar:/space/jdk1.5.0_11/jre/lib/ext/sunjce_provider.jar:/space/jdk1.5.0_11/jre/lib/ext/sunpkcs11.jar:/space/src/nb_all/nbbuild/netbeans/platform7/lib/org-openide-modules.jar:/space/src/nb_all/nbbuild/netbeans/platform7/lib/org-openide-util.jar:/space/jdk5/lib/dt.jar:/space/jdk5/lib/tools.jar:/space/src/nb_all/nbbuild/netbeans/platform7/core/org-openide-filesystems.jar:/space/src/nb_all/nbbuild/netbeans/nb6.0/core/org-netbeans-upgrader.jar:/space/src/nb_all/nbbuild/netbeans/ide8/modules/org-netbeans-modules-classfile.jar[org.netbeans.modules.classfile.*]:/space/src/nb_all/nbbuild/netbeans/mobility8/modules/org-netbeans-api-mobility.jar[org.netbeans.spi.mobility.cfgfactory.*,org.netbeans.spi.mobility.cldcplatform.*,org.netbeans.spi.mobility.deployment.*]:/space/src/nb_all/nbbuild/netbeans/mobility8/modules/org-netbeans-modules-mobility-antext.jar
java.lang.NoClassDefFoundError: org/apache/tools/ant/Task
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at org.netbeans.JarClassLoader.simpleFindClass(JarClassLoader.java:180)
	at org.netbeans.ProxyClassLoader.smartLoadClass(ProxyClassLoader.java:550)
	at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:174)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:242)
[catch] at
org.netbeans.core.startup.NbInstaller.preresolveClasses(NbInstaller.java:1365)
	at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:290)
	at org.netbeans.ModuleManager.enable(ModuleManager.java:903)
	at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:380)
	at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:316)
	at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:260)
	at org.netbeans.core.startup.Main.getModuleSystem(Main.java:149)
	at org.netbeans.core.startup.Main.start(Main.java:300)
	at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:88)
	at java.lang.Thread.run(Thread.java:595)
[several more...]
Comment 1 Adam Sotona 2007-06-11 14:02:20 UTC
I can fix it this way but does it help when the module will still reference the
Ant library in its classpath?

Mobility-AntExt is a library used in other modules as well as headless Ant
extension.
Comment 2 Jesse Glick 2007-06-11 18:02:08 UTC
What module references Ant in its classpath? (None should, since the user can
pick an alternate Ant installation.) How do other modules use it as a library
when its classes cannot even be resolved?
Comment 3 Adam Sotona 2007-06-14 09:47:25 UTC
The requred classes can be resolved and it works. 
Split into a library, an Ant task library and module would complicate headless usage. The library is designed to be used
headless outside IDE. Simply by copying the module jar everything works. The same approach is for example used in
ProGuard obfuscator library. It is a bundle of obfuscator libarary and its Ant tasks. After the split user would need to
copy multiple library files and arrange on a new possitions.

BTW what is netbeans.preresolve.classes=true good for?
Comment 4 Jesse Glick 2007-06-18 19:40:50 UTC
netbeans.preresolve.classes=true attempts to load every class in every module to see if it can really be resolved. It is
correctly reporting that the Ant tasks in org-netbeans-modules-mobility-antext.jar cannot be resolved when loaded from
the module class loader, because ant.jar is not visible to any module. That is, any attempt to refer to or load these
task classes normally (from the module) would fail with a linkage error. The flag cannot, and does not attempt to,
verify that classes are resolvable when referred to in other ways, such as from Ant or from manually constructed class
loaders.

I would still advise you to split apart the task classes into a separate JAR, as is done for every other collection of
Ant tasks distributed with the IDE, but if you feel strongly that they must be present inside the module JAR then it
would be possible to add an explicit exclude for classes matching a certain pattern.
Comment 5 Adam Sotona 2007-08-20 09:10:17 UTC
The split requires to create three jars instead of one. Headless build configuration requires two of them + one optional
jar to arrange on the classpath manually.
I recommend to ignore this small architectural exception as it cause no harm.