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 154479 - [codehaus] System dependencies lost when using assemblies
Summary: [codehaus] System dependencies lost when using assemblies
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-03 15:31 UTC by Jaromir Uhrik
Modified: 2009-11-02 11:01 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 Jaromir Uhrik 2008-12-03 15:31:22 UTC
This issue was originally reported by Daniel Mutch in 06/Apr/08 at codehaus.org - see more details at
http://jira.codehaus.org/browse/MEVENIDE-619
Environment: Java 6, NB 6.1 Dev

===========
Description:
===========
Steps to reproduce:
1) Create a new maven project using standard archetype.
2) Add the following system dependency on javac
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<type>jar</type>
<systemPath>${JAVA_6_HOME}/lib/tools.jar</systemPath>
</dependency>
This assumes you have a system variable declared for JAVA_6_HOME
3) In the main method of your class put the line
Main.compile(null);
and fix imports.
4) Compile
5) Firstly, right click (on file) and run. NPE will be observed as expected since we are passing null to the compile method.
6) Now right click on project, choose properties and set the main class.
7) Now run the project (instead of using run file). Instead of the NPE get message:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main

----------------------------------------------
Comment by Milos Kleint [ 07/Apr/08 02:47 AM ]
----------------------------------------------
I have rewritten the way run/debug projct is implemented fro j2se projects.
instead of a custom profile with a bunch of stuff in it, we will use just plain "mvn exec:exec java -classpath
%classpath org.myapp.Main"
build #370 and later
http://deadlock.netbeans.org/hudson/job/mevenide/
I believe that gets rid of this issue as well. I haven't tried, please reopen if it doesn't help

----------------------------------------------
Comment by Daniel Mutch [ 07/Apr/08 03:22 AM ]
----------------------------------------------
It seems the new run / debug system has made the problem worse. Now it fails with class not found no matter how I try to
run the application.

----------------------------------------------
Comment by Milos Kleint [ 07/Apr/08 03:26 AM ]
----------------------------------------------
ok, so it probably only worked because the exec:java goal runs in the same VM as the maven build, thus in the same VM as
the IDE which has it on classpath I guess..
I'll have to try to debug the setup.

----------------------------------------------
Comment by Milos Kleint [ 07/Apr/08 03:53 AM ]
----------------------------------------------
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
system dependencies are similar to "provided" dependencies. as such these are not put in runtime classpath of the
project. That's why the old setup failed and the new one is failing as well.

----------------------------------------------
Comment by Daniel Mutch [ 07/Apr/08 09:02 PM ]
----------------------------------------------
Ah...I see of course and applications are being run using the jre, so tools.jar is not available.

----------------------------------------------
Comment by Daniel Mutch [ 08/Apr/08 04:45 AM ]
----------------------------------------------
Sorry to give you the run around on this Milos, but I'm confused. It seems all of the Maven examples declare tools.jar
as a system dependency but tools.jar isn't in the classpath for jre or jdk. So i fail to see what the standard way to
get tools.jar into the runtime classpath is? Any suggestions? thanks

----------------------------------------------
Comment by Milos Kleint [ 08/Apr/08 07:39 AM ]
----------------------------------------------
indeed the system scope in general looks like a workaround only. it works only because the examples assume the
compilation only.
the only solution that comes to mind is editing the action mapping and do exec:exec java -classpath
<path-to-tools>:%classpath <main class>
Comment 1 Milos Kleint 2009-02-13 09:52:30 UTC
this is a maven use issue primarily, 
a possible workaround is define the execution action as --classpath %classpath:<PATH_TO_TOOLS.JAR> in the actions panel
in project properties dialog.

closing as later as the issue is not primarily of netbeans integration but maven itself.
Comment 2 Quality Engineering 2009-11-02 11:01:41 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX