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 153644 - Running applications fails when classpath to long
Summary: Running applications fails when classpath to long
Status: RESOLVED DUPLICATE of bug 188864
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P3 blocker with 1 vote (vote)
Assignee: David Simonek
URL:
Keywords:
: 154467 158564 167311 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-21 14:26 UTC by sgtgarcia
Modified: 2010-07-23 11:43 UTC (History)
2 users (show)

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 sgtgarcia 2008-11-21 14:26:30 UTC
In a Maven project, right click on project and Run or Debug.

Application doesn't start for various reasons:
- Maven Dependencies with "Runtime" (only "Compile" do) scope are not included
- Many dependencies makes a too long command which is not supported by exec-maven-plugin under MS Windows

In previous NetBeans and Maven plugin for NetBeans, a netbeans-run-plugin was used and was working better...
Comment 1 Milos Kleint 2008-11-24 14:10:49 UTC
unfortunately the netbeans-run-plugin required clumsy configuration of the pom.xml and required the mvn install phase to
be run along with copying the dependency jars to target/ folder. That's inherently slow. It also required embedded maven
for it's invokation, which is unfortunately buggy and incompatible with latest release of maven and was causing problems
to people with more complex setups.

exec-maven-plugin shall be more generic, requires no pom customization and is faster.

1. runtime vs. compile. Compile seems to be the default scope, no idea why. However currently setting the classpath
scope to runtime will not include the output directory (exec plugin bug). in post 6.5 when executed main method in test
sources, the test scope shall be already used
2. too long command is a real problem without a clear solution so far. At least to me. any insights welcome

Comment 2 sgtgarcia 2008-11-24 17:20:36 UTC
My current workaround:
In pom.xml, I use a mix of Jar and Assembly plugin to build a jar with classpath included in Manifest pointing to
librairies in gathered in a local folder
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib</classpathPrefix>
                            <mainClass>com.mycompany.myapp.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>directory-inline</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>assembly-descriptor.xml</descriptor>
                            </descriptors>
                            <finalName>myapp</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

And then use Exec plugin to start app from NetBeans (nbactions.xml):
<actions>
  <action>
    <actionName>run</actionName>
    <goals>
      <goal>package</goal>
      <goal>org.codehaus.mojo:exec-maven-plugin:1.1:exec</goal>
    </goals>
    <properties>
      <exec.workingdir>${project.build.directory}/working-dir</exec.workingdir>
      <exec.args>-jar ${project.build.finalName}.jar</exec.args>
      <exec.executable>java</exec.executable>
    </properties>
  </action>
  <action>
    <actionName>debug</actionName>
    <goals>
      <goal>package</goal>
      <goal>org.codehaus.mojo:exec-maven-plugin:1.1:exec</goal>
    </goals>
    <properties>
      <exec.args>-Xdebug -Djava.compiler=none -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
-jar ${project.build.finalName}.jar</exec.args>
      <exec.workingdir>${project.build.directory}/working-dir</exec.workingdir>
      <jpda.listen>true</jpda.listen>
      <exec.executable>java</exec.executable>
    </properties>
  </action>
</actions>

As you stated, this is not quick, but works: runtime dependencies+compile are included and as classpath is described in
manifest there is no problem of command length.
Comment 3 Milos Kleint 2009-02-02 12:51:57 UTC
runtime vs. compile classpath is fixed in 7.0 M2 (using exec-maven-plugin 1.1.1)

the classpath length issue still persists, I chnaged the summary accordingly.
Comment 4 Milos Kleint 2009-02-11 09:45:39 UTC
*** Issue 154467 has been marked as a duplicate of this issue. ***
Comment 5 Milos Kleint 2009-02-15 14:41:03 UTC
*** Issue 158564 has been marked as a duplicate of this issue. ***
Comment 6 sreedhar37 2009-02-28 09:24:37 UTC
could you tell me if thisbug is fixed in 6.7 m2 ? If not when will this be fixed ??

Thanks
Comment 7 Milos Kleint 2009-06-18 20:29:59 UTC
*** Issue 167311 has been marked as a duplicate of this issue. ***
Comment 8 Milos Kleint 2009-06-22 13:31:54 UTC
http://jira.codehaus.org/browse/MEXEC-68 is the issue filed against the exec-maven-plugin.
Comment 9 uprooter 2009-09-07 17:38:08 UTC
http://support.microsoft.com/kb/830473
it says maximum length on XP is 8191 chars. on linux it's about ~32000
This problem is not really windows specific. it just a matter of time until some linux user will create a huge project
on a wired long path and get this error as well.
I tried very hard to use sgtgarcia solution but it didn't work.
Any further explanation/comments will be very appreciated as I'm very stuck on this one.
some day this bug just showed up, probably after adding deps.
Can't debug/run any of my maven projects on windows and my project mates are very upset.

Comment 10 mutchd 2009-10-01 17:08:51 UTC
@uprooter

A robust workaround for this is to create a second project to wrap the first that delegates the classpath management to
classworlds http://classworlds.codehaus.org/

This is bit of a pain but works well.
Comment 11 mutchd 2009-10-01 17:21:37 UTC
If anyone is still using a version of Netbeans for the runtime path issue isn't fixed you can work around it byrolling
the exec plugin back to 1.1-Beta-1.
Comment 12 Milos Kleint 2009-11-10 06:15:08 UTC
the too long classpath problem should be fixed in current svn trunk of the exec-maven-plugin codebase.
I've deployed a snapshot for testing at 
http://snapshots.repository.codehaus.org/org/codehaus/mojo/exec-maven-plugin/1.1.2-SNAPSHOT/

to use it, declare the s.r.c.org repository in settings.xml file and then change the action mapping in the IDE to 1.1.2-SNAPSHOT (instead of the current 1.1.1)

thanks.
Comment 13 Antonin Nebuzelsky 2010-07-23 11:37:39 UTC
Presumably fixed by integration in issue 188864.

*** This bug has been marked as a duplicate of bug 188864 ***
Comment 14 David Simonek 2010-07-23 11:43:54 UTC
Someone should verify that this is indeed fixed - sgtgarcia, could we ask you to verify with dev build? Thanks.