Eclipse java project suddenly stopped working - java

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

Related

IntelliJ only compiles files once

IntelliJ (Ultimate 2018.1) is not building my project properly. The project is using Maven which doesn't seem to have any problems (all libs are there). The problem is as follows:
Everytime I start up IntelliJ, I am able to build all changes exactly one time. I can change contents of my files and those changes will be contained in the build. But every change I do after that first build is ignored by the build tool. So, every time I build the project (ctrl+f9) after that, I get "All files are up-to-date" and nothing is compiled. (If I am running the app on the application server and try a hot swap, the build says "loaded classes are up to date ...")
Only a restart of the IDE lets me rebuild the project.
Edit: As I just found out, a restart of the IDE is not the only possibility to make a build possible again. In the state of not being able to compile, I changed a setting in the compiler settings. After that, I was able to build again. But only once. I then changed the setting back and well, I could build again. Looks like something odd in the IDE. /Edit
Edit2: Oddly enough, the explicit compiling of the class (ctrl+shift+f9) is working. So the problem circles around the compiling of the whole project. While this is making IntelliJ usable again, it's error prone regarding multiple changed files... /Edit2
A few notes and configurations of the project:
The build produces a .war
It is deployed on a wildfly (which is not started once in this cycle, so this shouldn't be the root of the problem)
The exact same project was formerly developed in Eclipse where building and Hot-Swap worked flawlessly (and still do when I try Eclipse again)
Maven Config:
Compiler config:
Check with Intellij version. As I am using 1.4 community edition and for me its running proper.
Even I have updated few dependencies after building First Time and it get's rebuild automatically.
So for my understanding what you can do it just check with the Intellij update or change the default directory and rebuild it.
The problem with the "Build Project" command is the source discovery of IntelliJ. A long time ago, we made the choice to place our sources inside a folder named ".git" (not the folder in the repository), so IntelliJ had problems to discover the code inside that directory. The reason for that was an old approach of Eclipse to clone repositories into a .git folder. The directory looked like this:
C:\dev\.git\workspace and inside that folder was another .git folder (from the repository).
So, the answer is:
Don't put your git repository in a folder named ".git" or IntelliJ will not compile it (unless you only compile class wise).

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.

Why is Eclipse hanging at 57% with the status "Verifying launch attributes..." when launching a run configuration?

After recently converting to Maven from Ant, run configurations that launched immediately pre-Maven take an excessive amount of time and consume an abnormal amount of resources while Eclipse prepares to launch the projects.
Eclipse shows this status message:
Verifying launch attributes...
At 57% completion, Eclipse hangs for several minutes before finally launching the run configuration. Once launched, the project runs fine and without a problem.
I found this blog article that suggested to clean the local workspace, but that did not solve the problem, especially considering the author is using Git and I am not.
I am only using the latest m2e maven plugin, with the latest version of Eclipse.
What is causing Eclipse to block when launching these run configurations, and how can I fix it?
I had the same symptoms. I could fix it by adjusting
Eclipse -> Preferences -> Maven -> User Settings
My maven user settings file was stored on a remote folder. After moving the file to a local disk, the test now start instantly again.
I know this is a rather old question, but I've been having this issue for a while now and none of the solutions found online seemed to work:
Disable IPv6: didn't work
Disable Ivy classpath resolution: not applicable
Moving the maven settings: not applicable
Delete src classpathentry's from .classpath: this removes all source folders from Eclipse
I did eventually found out (somehow) that having duplicate .classpath files in your workspace can cause serious issues. When importing a multi-module maven project you can easily do this by importing all your modules and your master module (the pom-type module). Doing so, you effectively import everything twice. Closing this master module in Eclipse solved the issue for me.
Another workaround would be to not rely on m2eclipse and to use mvn eclipse:eclipse and then import your projects as an 'existing project'.
This could be caused by duplicate / erroneous entries in the project's .classpath file. These entries are not necessary, as the maven plugin will take care of properly setting the classpath to launch your project.
To prevent Eclipse from hanging, open all of the referenced projects' .classpath files, which should be in the root directory of the project.
Remove all of the entries who have src as their kind attribute value.
For example:
<classpathentry kind="src" path="src"/>
Once all of these entries are removed, Eclipse will now launch your project instantly.
Unfortunately the progress information of the launching in Eclipse is not very accurate. The value of 57% is where all the hard work happens (see e.g. bug 354338).
If you are launching an Eclipse Application or JUnit Plug-in Tests, make sure you have the following plug-ins in your target platform:
org.junit
org.eclipse.jdt.junit.runtime
org.eclipse.jdt.junit4.runtime
org.eclipse.pde.junit.runtime
Otherwise Eclipse will search the whole p2 cache (in my case over 6000 plug-in jars, takes > 5min) for those plug-ins.
I know this is a very old thread, but I just ran into it, and wanted to let anyone who sees this know how I resolved it; maybe it will help the next person. I switched to a new computer at work, and because I was lazy, I just copied my local Maven repository (%UserProfile%.m2) from the old computer to the new computer. After running into the "Launch Attributes" issue and trying everything else, I moved my local Maven repository to another location so that eclipse would be forced to rebuild the local Maven repository. This pretty much fixed the problem; while I sometimes have an occasional delay of 2-5 seconds when launching, it is a big improvement over the 30-90 seconds it was taking previously. Happy coding.
I found this way to avoid 'verifying launch attributes... 57%' in Eclipse-Luna-SR2
have the launch configuration and the main class in different projects
delete the following line from the launch configuration:
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
With eclipse 2018-12 I had a delay of about 10 seconds at "57%, verifying launch attributes" for every start of a main class or a junit test. I used the windows tool "procMon" to identify about 500.000 failed accesses to jars in this period that I don't have in my classpath. I found those jar references inside the Manifest "Class-Path" entry of many jars I use.
After removing the Class-Path entry from all jars the delay now is only 1 second!
Some jars were signed. Then I had to remove the signature files (META-INF/*.SF|*.DSA|*.RSA|*.EC) from the jar, too.
One thing that makes a huge difference is how you tell Eclipse what tests you want to run.
When specifying the project name, our tests could take more than 5 minutes to be discovered (the 57%).
If we rather specify the directory containing the test source files, we are down to less than 30 seconds.

IDEA JetBrains IntelliJ - Compile error on 'make' but fine when compiled using Maven and no errors reported by IntelliJ in the class file

So I have a maven module (module-A) in IntelliJ. I recently moved some classes from it into another new maven module (module-B) and added a dependency to it. Once I had done this I also modified the signature of a method of one of the moved classes (now in module-B).
I re-imported the poms so that IntelliJ would pick up the dependency changes and ensured all Java imports for the affected files were correct again. Now when I attempt to run my webapp (which depends on the two modules) I get a compile error in a class in module-A calling the modified method of the class in module-B.
The error message is basically saying that that method doesn't exist but believes the old method still exists! I click on the 'make' error and it takes me to the line in a class in module-A calling the modified method...the weird thing is, IntelliJ knows it is fine in the file. i.e. The method is not underlined in red like a compile error would normally be, but the class file name is :(
I compiled it from the command line using 'mvn install' (having also installed module-B) and it is all successful. I have deleted the classes directory in the target of both module-A and module-B and also invalidated IntelliJ's caches and restarted...still happening...any ideas?
I found out that this might help:
File -> Invalidate Caches
Maven Projects -> Reimport should help.
I spent a few hours on this same issue. All of the cleans in the world didn't help.
I deleted my out and target directory in my project and recompiled - that cleared it.
Edit: There is also a magic feature under the file menu: "Invalidate Caches / Restart" This fixes a bunch of "intellij is confused" problems.
Change "Java Compiler" setting in IDEA (User compiler javac in-process) to fix the problem.
Try to mvn clean your projects and mvn install your project B.
The maven integration with intelliJ is kind of buggy when you use the make command directly provided by Intellij. You should directly use the mvn commands, or start them from the maven panel.
I ran across a very similar problem that was driving me insane.
My code would compile fine with the ant task I normally run, but it would not build in IntelliJ, complaining about "Cannot Find Symbol blah blah"
Turns out, you can add "Excluded" files for the compiler. My file somehow got added to that list.
This list is located in File > Settings > Compiler > Excludes (IntelliJ 13)
Following steps should fix this problem :
delete .IntelliJIdea12 / .IdeaIC12 older under c:/user/.../
Invalidate Intelli's cache: File > Invalidate Caches.
This re-indexes your workspace on start-up and also clears your local history. Before you do this, commit or back up all your uncommitted changes.
Once your workspace is back after indexing, do a maven clean install.
when the build is successful, click on Maven Re-imports
This worked for me, I think it should work for others too with a similar problem.
So just stated it up this morning and it's all working!
Last night what I did do was open a new project (intelliJ project) from module-A's and module-B's parent pom and successfully got it to build, possibly doing that and then opening my original project again fixed it somehow...very annoying though
The behavior I see is similar to the one described by the original author.
Error markers show up on the right side of the editor in Intellij 14 and less so in 13.
This happens also if using Scala instead of Java and using SBT instead of Maven.
Also noticed this occurs after the second project is loaded. The first is always fine.
(After much trial and error) Figured it might be caused by Intellij's internal caches becoming somehow corrupt. "Invalidate caches" worked sometime and sometimes did not.
I work with a number of projects using Play! Framework and they use different versions of Scala and lots of dependencies.
I hypothesized the caches become corrupt because the internal key Intellij uses is not good enough to handle situations when the same class, loaded multiple times in different jars, has different signatures, and this results in the editor errors while external builds work fine.
Then the "Changing Ivy Cache Location for sbt projects in IntelliJ IDEA?" post gave the idea to segregate the ivy cache SBT and Intellij use in the hope that the ivy path is part of the internal cache key.
Paul Phillips of TypeSafe provide the "SBT extras" tooling and here I found a way to instruct SBT to use a project based ivy home, cache and SBT boot:
https: //raw.githubusercontent.com/paulp/sbt-extras/master/sbt
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
How to configure Intellij
: see http://content.screencast.com/users/SemanticBeeng/folders/Snagit/media/ec8ec491-6d0c-4691-9598-916a63ba65ef/12.02.2014-08.59.png
Then did the same for the external SBT build to work in sync
: see http://content.screencast.com/users/SemanticBeeng/folders/Snagit/media/dcb287c4-200f-47f3-a937-42865675a22b/12.02.2014-09.01.png
Finally got rid of the user home based .ivy2 and all the contents.
To be sure Intellij does not use this folder I made it readonly.
This was a mistake. Intellij seems to silently fail resolve dependencies if you do this.
This solved the errors and believe they will not come back. :-)
If Intellij guys hear this: please test your releases (Scala, SBT, editor) with all the Play Framework templates from TypeSafe. The problem becomes apparent quickly this way.
I just had a similar issue that was driving me insane. I had done all the other things mentioned in the answers above because I have used Intellij forever, but none worked. In the end I found out that in the maven projects portion of Intellij, one of my modules had been marked "ignore" a simple unignore command from the context menu did the trick.
In my case, I had manually marked a directory as "Test Sources Root" but IDEA marked it on a parent Maven project. Unmarking it in File->Project structure...->Modules fixed the problem.
This could happen if you are using different version of java while building outside IntelljJ. My IntelliJ had java10 and I was using java8 while building at terminal. Changing java version to IntelliJ fixed this issue for me.
I had a very similar behavior. Running (Scala-)tests would always fail due to errors in unrelated java classes during the 'make' step.
It turned out, I had included a 'global' SDK library that collided with one of the dependencies from the project. A proper helpful error message only showed up after I deleted the 'make' step from the test.
I then deleted the duplicate library, re-added the make step to the test and everything is now working fine.
I ran into this problem today after upgrading from 12 to 13.
Later I fixed issue as I used the same name for Project and Module and looks Intellij allows this but cannot handle it correctly.
No idea why setting will impact the compilation, although there is no error in java editor. Should be a bug in version 13.
I was facing a similar issue after upgrading from IntelliJ 12 to 13. After multiple uninstalls and re-installs (of multiple intelliJ versions), numerous cleans and .m2 repository clearing, I finally figured out what my issue was.
In my intelliJ settings, the repositories mentioned in my main POM file could not be connected to. this was in turn due and alternate repository that was mentioned as a part of my pom file.
Once the POM was made to point to the correct repository, all my classes had their compilation issues resolved.
To check if your repositories are being connected to, go to File -> Settings -> Maven -> Repositories
Here, your indexed maven repositories should be connected to successfully. If they are not, then intelliJ will not be able to resolve most 3rd party and module dependencies.
I'm embarrassed to say, but we also had this problem, but it was due to a mistake in our package name.
When creating the packages for a new project I accidentally created a package called "org.package".
My project then had a directory structure like:
/src/main/java/org.package/
Which caused all sorts of havoc with IntilliJ.
Once the correct folder structure was created on the file system, IntelliJ worked great.
/src/main/java/org/package/
Note the difference in /org.package/ vs /org/package/
The fix was i made it javac instead of Ajc and i put 1.8 of course according to your jdk version.
for some reason when i invalidate and restart intellij it was set to be the default !
my version is
This happened to me...what fixed it was realising there was an extra main.iml file in the source directory. Deleting that instantly made the compile errors go away.
None of the above answers worked for me.
In my case, I had to finally create an explicit Maven Run Configuration for the module (with Command Line as "clean install") and then run it.
It is in Run > Edit Configurations
close the project
go-to the project folder and delete idea project file and .iws file
run mvn idea:idea
restart the project.
seems idea keeping the old project dependencies without cleaning even though we run file -> invalidate caches
Setting the proper Java SDK solves the issue
Right click on the project and select "Open Module Settings"
Check if you have the right Java SDK under platform settings
Check the SDK under Modules
Rebuild the project from "Build" menu
Delete the installation directory.
Remove the following directories:
~/.config/JetBrains/
~/.cache/JetBrains/
~/.local/share/JetBrains/
This will remove each and every configuration plus installation of jetbrains tools, be it IDEA, goland,etc.
Now install everything from scratch.
That's the only way it worked for me

'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