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 236438 - Groovy classes not found during run. Not in target directory. Maven project.
Summary: Groovy classes not found during run. Not in target directory. Maven project.
Status: RESOLVED DUPLICATE of bug 256367
Alias: None
Product: groovy
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.4
Hardware: PC Linux
: P3 normal (vote)
Assignee: bruno.flavio
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-26 20:52 UTC by aiterate
Modified: 2016-02-10 22:11 UTC (History)
1 user (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 aiterate 2013-09-26 20:52:50 UTC
Similar to closed bug 233416.

Reproduced on 7.4 RC1 and nightly build netbeans-trunk-nightly-201309260002-linux.

1)  Fresh install of Netbeans.

2)  File / New Project / Maven / Java Application.

3)  Run.  See "Hello World" ok.

4) Right-click on project name in Project navigator, "New / Groovy Class".

5)  Define one method in Groovy class as follows:

def doit()
  {
      println "Groovy!!"
  }

6)  Modify Java main as follows:

public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        GroovyClass g;
        g = new GroovyClass();
        g.doit();
    }

7)  Makre sure everything is saved.  Editors are happy.  Compiler is happy.

8)  Run.

Java class successfully prints "Hello World" then blows up with ClassNotFound when Groovy method is invoked.

Hello World!
Exception in thread "main" java.lang.NoClassDefFoundError: com/mycompany/mavenproject1/GroovyClass
	at com.mycompany.mavenproject1.App.main(App.java:13)
Caused by: java.lang.ClassNotFoundException: com.mycompany.mavenproject1.GroovyClass
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 1 more
------------------------------------------------------------------------
BUILD FAILURE

9)  Noticed that no class files exist in the project for the Groovy classes.  So, groovy didn't get compiled and it's not using the source groovy file either at runtime.
Comment 1 Martin Janicek 2013-12-10 14:37:12 UTC
It looks that you don't have correctly setup your pom.xml to compile Groovy sources together with Java sources. It should be done automatically in case if you have IDE installed with Groovy bundle but in case you have pure Java bundle for example, it is possible it does not get updated. Could you please share your project? Or at least show me the content of your pom.xml?
Thanks in advance
Comment 2 Martin Janicek 2013-12-11 12:55:01 UTC
Closing as incomplete until information asked in comment 1 will be provided. Thanks.
Comment 3 everflux 2016-01-17 10:21:48 UTC
I have a similar problem with NB 8.1 on linux, maven 3.3.9

 NetBeans maven-groovy project with the error message

"Error: Could not find or load main class XXX"

After maven clean/build the target classes folder looks like

ls -l target/classes/     
total 24
-rw-rw-r-- 1 tkruse tkruse 5261 Jan 17 11:13 FullCrawl.class
-rw-rw-r-- 1 tkruse tkruse 2788 Jan 17 11:13 FullCrawl$_crawlPosts_closure1.class
-rw-rw-r-- 1 tkruse tkruse 4172 Jan 17 11:13 FullCrawl$_crawlPosts_closure1$_closure3.class
-rw-rw-r-- 1 tkruse tkruse 2305 Jan 17 11:13 FullCrawl$_main_closure2.class

and excution works.

After a change in the groovy file and saving in NetBeans

ls -l target/classes/
total 16
-rw-rw-r-- 1 tkruse tkruse 2788 Jan 17 11:13 FullCrawl$_crawlPosts_closure1.class
-rw-rw-r-- 1 tkruse tkruse 4172 Jan 17 11:13 FullCrawl$_crawlPosts_closure1$_closure3.class
-rw-rw-r-- 1 tkruse tkruse 2305 Jan 17 11:13 FullCrawl$_main_closure2.class

and execution is broken.

When doing a mvn clean and then run-file in NB it works for one execution.

If I disable compile on save for the project it works for every execution.
Comment 4 bruno.flavio 2016-02-10 22:11:04 UTC
Marking as duplicate of #256367: The Compile On Save feature is not handling the compilation of groovy classes in maven projects correctly.

*** This bug has been marked as a duplicate of bug 256367 ***