Netbeans always running maven build before debugging - java

I am running Netbeans 8.0.2 and I am trying to debug a web app. This app is a module in a larger suite. Normally just the parent gets compiled which set's up property values for db connections etc. So, that being said the web app I am trying to debug never gets built independently.
So, I want to be able to do right-click > debug without netbeans running the maven build (this will mess up the prop values).
I have the "Always perform build before running application" unchecked in the Run configuration. But every single time, it builds it anyways!
Is there something I'm missing? Or is there some bug in Netbeans?
Edit: I've also tried deleting the cache.

I know this is an old question which you probably (and hopefully) solved already. However, as I had the same problem and could not find an answer here, I want to share my solution to this problem for others.
My application also first built itself and then started debugging. I checked the run/debug configuration and they were fine. So I deleted the local maven repositories of all dependencies of my application and rebuilt them. Seems like NetBeans confused something with the dependencies and therefore rebuilt the application every single time again. After deleting and rebuilding the dependencies I was able again to debug the application without building it before.

Related

Issues with WildFly 10.10 and Eclipse JSF application [duplicate]

I'm currently experiencing a problem with 'hot code replace' not working on Eclipse Galileo and JBoss 4.2.3.
Among other applications I'm running an exploded Java WAR on my local JBoss. The project from which it is build is managed by Maven. I build the project using the Maven goal war:exploded and then I copy that directory to JBoss with an ANT script.
When I'm now running the application and set a breakpoint anywhere in the code, Eclipse properly halts at that line in the debug mode.
But when I'm making a change to the source file and save it, Eclipse doesn't apply this change to the JBoss.
For example, when I make a normal code line into a comment, the debugger still steps over this comment as if it was regular Java code. Or when I remove a line, the debugger seems to get out of sync with the file and starts stepping over parenthesis.
But I'm not getting any 'hot code replace error'-messages either. It seems to me that Eclipse applies the changes to the source files, but doesn't apply it to the JBoss.
Are there any special preferences that have to be turned on in order to make hot code replace work? Or are there any mistakes in how I build and deploy the application to the JBoss?
I did not work with JBoss but I have two suggestions.
If you run your application in eclipse using the launch configuration
Is your "Project" - "Build Automatically" flag enabled?
If not, the code is not compiled and ignored t runtime.
When you debug an application in remote mode, you can not change the code, but you can change the value of parameters. (I think)
I had issues in a project with Maven and Eclipse. No errors were shown, but hot code replacement was not working. I read that "Build Automatically" has to be checked. I checked this and it still didnt work. I had some errors in other projects in my build path. I believe that was the error. When i researched, I found that the we had to uncheck the "Abort build when buildpath errors". I have given the details in the link below.
I had a similar problem with Open Liberty. Let me build on the accepted answer plus the answer from #user513365 (since a link there is now dead).
In my case I had two issues:
1. Build path errors
In my case my Incomplete build path was because I was using a Maven project with only src/main/java but without a src/test/java (so probably could have solved this by creating the latter).
But I was able to fix Hot Code Replace by going to Preferences -> Java -> Compiler -> Building and make one of two changes:
Either:
uncheck Abort build when build path errors occur OR
using the drop-down, change Incomplete build path from Error to Warning.
2. Make sure Eclipse-built classes are getting loaded
In my case my remote JVM was using a full JAR artifact from my local .m2 Maven repository. The accepted answer of enabling: "Project" - "Build Automatically" misses a subtlety here.
The Eclipse project build in my case is only going to do a hot code replace, if I do the Eclipse build after the debugger is attached. Yes, it will do the Eclipse build automatically, but if I restart my remote JVM and simply attach the debugger, it is still configured to load this class from my local .m2 JAR, and NOT pick up my local change.
FINAL NOTE ON THIS ANSWER VS. OTHER ANSWERS
If you are constantly changing the class that you are building automatically you might not notice the subtlety in point 2., and the accepted answer combined with the build path error mentioned in #user513365's answer will be all you need.
First check is the Project/Build automatically.
It may be also required to check the application server deployment configuration,
E.g. for JBoss, in Eclipse, in the Servers view, double click on the server and there is a Deployment Scanners section with two check boxes:
Add missing deployment scanners
Remove added deployment scanners before shutdown
https://docs.jboss.org/author/display/AS7/Deployment+Scanner+configuration
JBoss AS/ Deployment Scanner configuration
I just recently had this problem in Eclipse 2019-06 and found I had to uncheck the option in "Replace classfiles containing compilation errors" in Preferences->Java->Debug->Hot Code Replace group. All the other options there were checked.
Previous to doing that I was getting "Hot code replace failed - Delete method not implemented" despite my only change being to ass a System.out.println call.
As soon as I changed that option ( in the same debug session ) it started working for me.

Cannot access org.springframework.core.env.EnvironmentCapable error in Java

I am stuck since morning figuring this thing out (wasted nearly 6-7 hours) and could not do anything.
I was trying to add RestEasy module in my web app. Added few dependencies but somehow my api calls were not working. So removed it and this exception started floating around.
Things I tried: -
Did a complete git checkout . Build the project. Did not work.
Tried reimporting the project in IntellijIdea 13 (which I am using). It did not help either.
Deleted my local .m2 folder and downloaded every dependency again.
Restarted my system couple of times.
The project builds just fine. But when I try running it - Tomcat 7.0.56 - this exception appears. Did whatever I could, but nothing worked.
Well, its not less than a Eureka moment for me. I tried figuring out the soltion and found out that my project's Spring Facet was not properly set up. Now when I try fixing that, there is one more issue -
For this error, try removing the source root of the module. It will be added later on its own. Now when the source root is removed, the Spring Facet is easily fixed.
After adding Spring library, just rebuild the project and start the server.

Eclipse java project suddenly stopped working

I had my hibernate/sevrlet project working fine in eclipse yesterday,
but now I'm suddenly getting NoClassDefFoundError exceptions and
unresolved imports that require me to add to the build path and
check entries on the properties order & export tab.
All I did since it last worked was work on a different project which shouldn't have affected this particular project.
Why would my project suddenly start requiring all this configuring now, whereas it worked before?
Your class-path probably got broken when you switched projects.
Eclipse usually does some background work upon closing and re-opening a project. Depending on your version, some things could have happened like Maven dependencies (if you use Maven) not being re-added in the deployment assembly.
When all of the sudden Eclipse begins causing me this kind of trouble, I do the following:
Refresh all the projects (click + F5 on all the projects)
Clean the server for a full reload
Sometimes, Project -> Clean also works
Usually any broken reference I have gets fixed by this. Still, check your project's deployment assembly to see if anything that should be there is amiss.
Finally, the definitive test is to open your file system's server folder and check what has been deployed there. If a class is missing, you will see that the jar is not in its place. Assuming you work with Tomcat, the physical location of your server will be somewhere like:
(Eclipse workspace folder).metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps

Java Play! Startup Problems

When I first ran eclipsify on my Project I noticed that Eclipse complained about the:
return ok(index.render("Your new application is ready."));
Line. It did not recognize the index method. The application still ran so I ignored it for the time being. Now, however, I am getting a new error. I think I just added a few dependencies to Mongo, attached some Model files and rebuilt but I am now getting this error:
compile: sbt.InvalidComponent: Could not find required component 'compiler-interface-src'
I'm not sure why this is happening, especially because I'm a bit of a sbt idiot. As a side note, Eclipse is reporting that my "classes_managed" build path entry is missing, but I think that is due to my inability to compile after doing a clean. (Clean and update are working).
1) Templates are compiled by Play, not by eclipse. After the "eclipsify", you need to run play compile (or play run) and refresh your eclipse project. See How to make Eclipse see the changes in Play! compiled templates?
2) After adding dependencies, launch a new time the play eclipsify command.
But i think it's not the problem. What is the dependency you add ? And what is your Play2 version? (I suspect an incompatibility with a Play2.1 library)
And for your information, a general rule: Play doesn't depend on Eclipse to compile files. Do not try to clean in eclipse, but run play clean (and refresh eclipse).
Happen to run into this issue few times, tried above, also following
Clean up Play-framework based project
But nothing worked.
What it turned out to be was a IntelliJ Idea cache corruption issue, and invalidate and restart Idea worked fine.

'Hot code replace' not working -- Eclipse doesn't change any code on JBoss

I'm currently experiencing a problem with 'hot code replace' not working on Eclipse Galileo and JBoss 4.2.3.
Among other applications I'm running an exploded Java WAR on my local JBoss. The project from which it is build is managed by Maven. I build the project using the Maven goal war:exploded and then I copy that directory to JBoss with an ANT script.
When I'm now running the application and set a breakpoint anywhere in the code, Eclipse properly halts at that line in the debug mode.
But when I'm making a change to the source file and save it, Eclipse doesn't apply this change to the JBoss.
For example, when I make a normal code line into a comment, the debugger still steps over this comment as if it was regular Java code. Or when I remove a line, the debugger seems to get out of sync with the file and starts stepping over parenthesis.
But I'm not getting any 'hot code replace error'-messages either. It seems to me that Eclipse applies the changes to the source files, but doesn't apply it to the JBoss.
Are there any special preferences that have to be turned on in order to make hot code replace work? Or are there any mistakes in how I build and deploy the application to the JBoss?
I did not work with JBoss but I have two suggestions.
If you run your application in eclipse using the launch configuration
Is your "Project" - "Build Automatically" flag enabled?
If not, the code is not compiled and ignored t runtime.
When you debug an application in remote mode, you can not change the code, but you can change the value of parameters. (I think)
I had issues in a project with Maven and Eclipse. No errors were shown, but hot code replacement was not working. I read that "Build Automatically" has to be checked. I checked this and it still didnt work. I had some errors in other projects in my build path. I believe that was the error. When i researched, I found that the we had to uncheck the "Abort build when buildpath errors". I have given the details in the link below.
I had a similar problem with Open Liberty. Let me build on the accepted answer plus the answer from #user513365 (since a link there is now dead).
In my case I had two issues:
1. Build path errors
In my case my Incomplete build path was because I was using a Maven project with only src/main/java but without a src/test/java (so probably could have solved this by creating the latter).
But I was able to fix Hot Code Replace by going to Preferences -> Java -> Compiler -> Building and make one of two changes:
Either:
uncheck Abort build when build path errors occur OR
using the drop-down, change Incomplete build path from Error to Warning.
2. Make sure Eclipse-built classes are getting loaded
In my case my remote JVM was using a full JAR artifact from my local .m2 Maven repository. The accepted answer of enabling: "Project" - "Build Automatically" misses a subtlety here.
The Eclipse project build in my case is only going to do a hot code replace, if I do the Eclipse build after the debugger is attached. Yes, it will do the Eclipse build automatically, but if I restart my remote JVM and simply attach the debugger, it is still configured to load this class from my local .m2 JAR, and NOT pick up my local change.
FINAL NOTE ON THIS ANSWER VS. OTHER ANSWERS
If you are constantly changing the class that you are building automatically you might not notice the subtlety in point 2., and the accepted answer combined with the build path error mentioned in #user513365's answer will be all you need.
First check is the Project/Build automatically.
It may be also required to check the application server deployment configuration,
E.g. for JBoss, in Eclipse, in the Servers view, double click on the server and there is a Deployment Scanners section with two check boxes:
Add missing deployment scanners
Remove added deployment scanners before shutdown
https://docs.jboss.org/author/display/AS7/Deployment+Scanner+configuration
JBoss AS/ Deployment Scanner configuration
I just recently had this problem in Eclipse 2019-06 and found I had to uncheck the option in "Replace classfiles containing compilation errors" in Preferences->Java->Debug->Hot Code Replace group. All the other options there were checked.
Previous to doing that I was getting "Hot code replace failed - Delete method not implemented" despite my only change being to ass a System.out.println call.
As soon as I changed that option ( in the same debug session ) it started working for me.

Categories