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 246300 - Wrong classpath when profile is activated
Summary: Wrong classpath when profile is activated
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0.1
Hardware: PC Windows 7
: P1 normal (vote)
Assignee: Martin Kozeny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-06 11:37 UTC by jherkel
Modified: 2014-08-14 02:40 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample project (180 bytes, application/zip)
2014-08-06 15:35 UTC, Martin Kozeny
Details
Sample project (6.63 KB, application/zip)
2014-08-07 06:18 UTC, Martin Kozeny
Details
Sample test project (5.53 KB, application/x-zip-compressed)
2014-08-07 12:47 UTC, jherkel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jherkel 2014-08-06 11:37:29 UTC
I have probably found one regression between 8.0.0 patch 2 version and 8.0.1 RC1. When I tried to debug main file in 8.0.1, I got ClassNotFoundException. I investigated what was wrong and it seems that there is a problem with classpath which Netbeans sends to maven exec plugin. It works correctly for "default config" but not for profiles. In our case the pom.xml contains profiles that add some additional dependencies. I checked classpath variable via debugger and for Netbeans 8.0.0 I could see that classpath contained all dependencies,with 8.0.1 I could see only "default" dependencies.

Environment : Windows 7 64,JDK 7 update 67, Maven 3.2.2
Comment 1 Martin Kozeny 2014-08-06 15:34:32 UTC
It works fine for me on attached project using the same environment, hope I've created it correctly. Could you please attach your sample project? Thank you.
Comment 2 Martin Kozeny 2014-08-06 15:35:22 UTC
Created attachment 148577 [details]
Sample project
Comment 3 jherkel 2014-08-06 15:57:21 UTC
It seems that attached project is empty. Could you resend it?
Comment 4 jherkel 2014-08-06 17:23:36 UTC
I checked output one more time and I can see that when I build project the command line contains :
cd C:\projects\servio-ng\application\trunk\servio-ui-app; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.7.0_67" M2_HOME=C:\\java\\apache-maven-3.2.2 cmd /c "\"\"C:\\java\\apache-maven-3.2.2\\bin\\mvn.bat\" -Dmaven.ext.class.path=\"C:\\java\\NetBeans 8.0.1 RC1\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 -PJetty-test install\""

but when I debug main function in test classes I can see this :
NetBeans: JPDA Listening Start...
JPDA Address: xxx:64031
Port:64031
cd C:\projects\servio-ng\application\trunk\servio-ui-app; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.7.0_67" M2_HOME=C:\\java\\apache-maven-3.2.2 cmd /c "\"\"C:\\java\\apache-maven-3.2.2\\bin\\mvn.bat\" -Dexec.args=\"-XX:MaxPermSize=512m -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=64031 -classpath %classpath sk.posam.servio.ui.ServioUiJettyServer\" -Dexec.executable=java -Dexec.classpathScope=test -Djpda.listen=true -Djpda.address=64031 -Dmaven.ext.class.path=\"C:\\java\\NetBeans 8.0.1 RC1\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
Scanning for projects...

main difference is missing "-PJetty-test" so I suppose it is a reason for ClassNotFoundException. Any idea what is wrong? Something in my environment?
Comment 5 Martin Kozeny 2014-08-07 06:17:44 UTC
Sorry for that, resending.
Comment 6 Martin Kozeny 2014-08-07 06:18:19 UTC
Created attachment 148584 [details]
Sample project
Comment 7 Martin Kozeny 2014-08-07 11:14:21 UTC
But as I understand you've added -PJetty-test install parameter manually? I think it has nothing to do with our problem. As far as I know Jetty is some servlet container for running maven web projects. You probably do something with classpath using Project Properties->Actions->select_your_Configuration->in_Actions_select_Debug_project->and you change exec args or whatever. Check please project properties classpath settings or attach your sample project in order I can investigate it. Thank you.
Comment 8 jherkel 2014-08-07 12:45:54 UTC
I found out what is wrong. I have created test project which contains similar setup as I have in my big project which I cannot send to you. Unfortunately this new project has worked correctly under 8.0.0 and also 8.0.1. So I compared differences between them and found out that test doesn't contain file "nbactions.xml". When I removed this file, everything was working. 
So, with this file, 8.0.1 has a problem, 8.0.1. has not.
Comment 9 jherkel 2014-08-07 12:47:20 UTC
Created attachment 148590 [details]
Sample test project
Comment 10 Martin Kozeny 2014-08-07 13:01:34 UTC
Ok in this case closing as INVALID for now.
Comment 11 jherkel 2014-08-07 13:58:16 UTC
The same situation happens (wrong classpath based on default profile) when I set some properties for VM for default profile. (in background nbactions.xml file will be generated). 
For example, you can try to add "-Xmx1024" for "debug main file" action for default profile and after it try to debug main file and check the classpath.
From my point of view it is serious regression and it should be fixed before final release of 8.0.1.
Comment 12 Martin Kozeny 2014-08-07 14:22:11 UTC
You mean probably to add -Xmx1024m, otherwise you get: Error occurred during initialization of VM, Too small initial heap. What is exactly wrong with the classpath or what do you have on your cp?
Comment 13 jherkel 2014-08-07 19:43:33 UTC
When file nbactions.xml exists then classpath contains dependencies from "default" profile even if I have set "Jetty-test" profile. Dependencies from Jetty-test are missing. Result is that during debugging main file I get ClassNotFoundException, in this case for example "Exception in thread "main" java.lang.ClassNotFoundException: org.eclipse.jetty.jmx.ConnectorServer". As you can see when Netbeans sets wrong maven profile (argument -PJetty-test is missing), you cannot debug any main file which is executed via maven-exec-plugin. 

How to reproduce this problem :
1) Open my test project
2) Add some argument to "default" profile for example "-Xmx1024m". Check if netbeans creates "nbactions.xml"
3) Set Jetty-test profile and execute "clean and build" (I don't use Compile on Save).
4) Try to debug main file JettyServer.java - I can see an exception during this step. In command line you can see missing "-PJetty-test"
Comment 14 Martin Kozeny 2014-08-08 08:04:28 UTC
I can see you're right. Appears as a regression.
Comment 15 Martin Kozeny 2014-08-08 13:41:22 UTC
Caused by changeset:
http://hg.netbeans.org/main-silver/rev/db0646a1dc55
Comment 16 Jaroslav Tulach 2014-08-08 19:42:11 UTC
I need steps to reproduce. I did:

$ unzip https://netbeans.org/bugzilla/attachment.cgi?id=148590
# open the project in NetBeans
# but I can see nbactions.xml and nbactions-Jetty-test.xml
# so I don't know what to change in configuration, etc.

when I choose Jetty-test configuration. Select JettyServer. Choose Debug Test file, I see the right profile specified on the command line:

$ mvn -Dtest=test.JettyServer -DforkMode=once "-Dmaven.surefire.debug=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=58445" -Djpda.listen=true -Djpda.address=58445 -PJetty-test test-compile surefire:testo
Comment 17 Martin Kozeny 2014-08-11 06:37:48 UTC
@Jarda: Are you using 8.0.1 RC1?
Comment 18 Jaroslav Tulach 2014-08-11 06:44:59 UTC
I am using custom build from release801
Comment 19 Martin Kozeny 2014-08-11 07:22:58 UTC
Steps to reproduce:

1) Download, extract and open in 8.0.1 RC1 Sample test project

2) Open test.JettyServer class file

3) Select Jetty-test profile

4) Right click and select Debug file.
Comment 20 Jaroslav Tulach 2014-08-11 10:23:32 UTC
OK, when I follow the describe steps and use "Debug File" instead of "Debug Test File", I see following in the output window:

NetBeans: JPDA Listening Start...
JPDA Address: logouticek:51789
Port:51789

cd /home/tmp/246300/test; JAVA_HOME=/usr/lib/jvm/java-8-oracle /netbeans/java/maven/bin/mvn "-Dexec.args=-XX:MaxPermSize=512m -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=51789 -classpath %classpath test.JettyServer" -Dexec.executable=java -Dexec.classpathScope=test -Djpda.listen=true -Djpda.address=51789 process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec

e.g. there is no profile specified.
Comment 21 Jaroslav Tulach 2014-08-11 12:07:32 UTC
changeset:   7f2892307f6b
tag:         tip
parent:      703ecc6b7c50
user:        Jaroslav Tulach <jtulach@netbeans.org>
date:        Mon Aug 11 14:05:06 2014 +0200
summary:     #246300: Use fallback only if there is <profiles> section in the nbactions.xml file


Martine, could you verify my fix? I can backport it when it is found to be sane.
Comment 22 Jaroslav Tulach 2014-08-11 12:11:25 UTC
http://hg.netbeans.org/ergonomics/rev/7f2892307f6b
Comment 23 Martin Kozeny 2014-08-11 12:42:55 UTC
Thank you Jarda, it works ok now, closing as VERIFIED.
Comment 24 Antonin Nebuzelsky 2014-08-11 13:53:02 UTC
+1 for 8.0.1 if considered safe
Comment 25 Martin Kozeny 2014-08-12 14:14:05 UTC
Appears in 8.0.1.
Comment 26 Jaroslav Tulach 2014-08-12 15:29:15 UTC
The ergonomics build was broken after my change (an accidental change in Maven module API). Had to bump spec version:
http://hg.netbeans.org/ergonomics/rev/be5829d289ac

Hopefully that is not required for release801 branch.
Comment 27 Quality Engineering 2014-08-13 02:10:49 UTC
Integrated into 'releases/release801', will be available in build *201408122300* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/c43e1eea7ac7
User: Martin Kozeny <mkozeny@netbeans.org>
Log: #246300: Wrong classpath when profile is activated.
Comment 28 Quality Engineering 2014-08-14 02:40:53 UTC
Integrated into 'main-silver', will be available in build *201408140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/7f2892307f6b
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #246300: Use fallback only if there is <profiles> section in the nbactions.xml file