Related
This error is just bizarre, my code compiles fine, I can see there are no problems with it, yet this error has just popped up. I have tried re-starting NetBeans and there is no additional exception information.
What can cause this?
If it is Netbeans, try to uncheck "Compile on save" setting in the project properties (Build -> Compiling). This is the only thing which helped me in a similar situation.
I guess you are using an IDE (like Netbeans) which allows you to run the code even if certain classes are not compilable. During the application's runtime, if you access this class it would lead to this exception.
It's caused by NetBeans retaining some of the old source and/or compiled code in its cache and not noticing that e.g. some of the code's dependencies (i.e. referenced packages) have changed, and that a proper refresh/recompile of the file would be in order.
The solution is to force that refresh by either:
a) locating & editing the offending source file to force its recompilation (e.g. add a dummy line, save, remove it, save again),
b) doing a clean build (sometimes will work, sometimes won't),
c) disabling "Compile on save" (not recommended, since it can make using the IDE a royal PITA), or
d) simply remove NetBeans cache by hand, forcing the recompilation.
As to how to remove the cache:
If you're using an old version of NetBeans:
delete everything related to your project in .netbeans/6.9/var/cache/index/ (replace 6.9 with your version).
If you're using a newer one:
delete everything related to your project in AppData/Local/NetBeans/Cache/8.1/index/ (replace 8.1 with your version).
The paths may vary a little e.g. on different platforms, but the idea is still the same.
I also got the same error and I did clean build and it worked.
Add selenium-server-standalone-3.4.0.jar. It works to me.
Download Link
Recheck the package declarations in all your classes!
This behaviour has been observed in NetBeans, when the package declaration in one of the classes of the package refers to a non-existent or wrong package. NetBeans normally detects and highlights this error but has been known to fail and misleadingly report the package as free of errors when this is not the case.
I had the same issue with one of my netbeans project.
Check whether you have correctly put the package name on all the classes. I got the same error message because i forgot to put the package name of a certain class (which was copied from another project).
Disable Deploy on Save in the Project's Properties/Run screen. That's what worked for me finally. Why the hell NetBeans screws this up is beyond me.
Note: I was able to compile the file it was complaining about using right-click in NetBeans. Apparently it wasn't really compiling it when I used Build & Compile since that gave no errors at all. But then after that, the errors just moved to another java class file. I couldn't compile then since it was grayed out. I also tried deleting the build and dist directories in my NetBeans project files but that didn't help either.
Organize your code as a maven module.
Once done run the command from terminal
$mvn installl
to check if your code builds fine.
Finally import the project in netbeans or eclipse as maven project.
change the package of classes, your files are probably in the wrong package, happened to me when I copied the code from a friend, it was the default package and mine was another, hence the netbeans could not compile because of it.
I had this problem with NetBeans 8.0.1. Messages about problem in project deleted class. Deleting the ~/.netbeans didn't work. Also I looked for ANY reference to the deleted class in ALL my projects, nothing found. I deleted the build classes, everything. Then, when I started Netbeans again, compile and magically appears the message in Run and into the mother compiled class. I tried the uncheck "Compile on save" Dime solution, and works, but it's not practical.
Finally, my solution was edit and force recompile of the mother class. This way the new .class doesn't contains the message and Run works OK.
Just check the packaging, the simplest answer I can provide is that your package has been mislabeled (within a class).
Also, you may have some weird characters. Try white-flushing the code in a Notepad (or Gedit) and then pasting it into a newly created class with your IDE.
If you are using Netbeans, try to hit the Clean and Build button, let it do the thing and try again. Worked for me!
I had the same problem. My error was the packaging. So I would suggest you first check the package name and if the class is in the correct package.
Implementing my own functional interfaces resolved this for me (so instead of using java.util.function.* just create your own single-method interface with the parameters and return-type you want).
I get this error during compile-time of my GWT project, there is no such folder as 'gwt-UnitCache' to delete, as suggested in the following questions
Weird GWT compile error
exception in GWT RPC app
I'm using IntelliJ IDEA (IDE), SmartGWT EE (Framework), JBoss AS (Server) and JPA
Here's the error log:
If you change the value of your <module rename-to='<appname>'> in .gwt.xml it will give the same error :) but then you can just delete your gwt-unitCache and all is ok :)
IntelliJ IDEA stores GWT cache files in other location than <ProjectFolder>/gwt-unitCache, which is a default directory for a cache if you are using, for example, Eclipse with GPE (Google Plugin for Eclipse).
In IDEA, GWT cache should be located by default at <your_home>/.IntelliJIdea12/system/gwt (IntelliJ IDEA 12, Linux). For other operating systems you can check Project and IDE Settings.
If you delete mentioned gwt folder contents, IntelliJ will create a new cache, which in turn might solve your Failure in unit cache... (and similar Unable to read from byte cache) problem.
I had the same problem with Eclipse.
Unfortunately looks like the only solution is the one given by Crowlix.
I tried to delete gwtCache and Temp files, but nothing worked.
The problem only got fixed when deleting the entire project and re-importing it.
I was able to fix it by systematically removing, compiling and re-adding every artifact piece.
If you're having this problem, make sure you have a structure like this:
lib contains your compile-time libraries
I am face off this same error, this tip doesn't works for me, moreover, I keep about looking for a solution, and finally, I got this advice:
Java stack overflow error
I tried with -Xss1m, but the error persists, I keep on trying, my final value was -Xss5m
I am using GWT 2.5.1 and IntelliJ 12.
I've got same problem building a project with maven.
Usign both suggestion of Nishant and #iVieL:
$ export MAVEN_OPTS="-Xms512m -Xmx1024m -Xss32m"
$ mvn clean package
you must clean your project first (Project -> Clean)
then remove /gwt-unitCache
then rebuild it.
I know this question may seems stupid since i cannot give a lot of infos about it, but I think that the problem has to be some kind of bug...
I have written a java program whith NetBeans 7.1, which now gets me this error when trying to run. 10 mins ago it was perfectly running, and i have changed nothing to the class the error refers to
Could this be some kind of NetBeans error? Maybe it is a well know problem?
It also got this exception in NB 7.2
'clean an build' and restarting NB didn't work
updating NB with the latest updates and performing 'clean and build' also didn't work.
So i renamed the cache directory:
c:\Users\userabcd\AppData\Local\NetBeans\Cache\7.2\index\
started NB, waited for it to finish 'background scanning' and pressed 'Debug project' and voila. The cache gets corrupted every once in a while :-/
EDIT: Added Solution B below.
Solution A:
Project Properties
Build >> Compiling
un-check: Compile on Save
Clean and Build
Notes A:
If you leave Compile on Save un-checked, you won't have this problem any longer for this project.
If you enjoy the benefits of the Compile on Save feature, you can re-check the option after you clean and build, and continue work on your project as normal.
Compile on Save is meant to save time by constantly recompiling your .java files into .class files in the background as you save changes to your source code. That way when you build or run your project, most of the compiling work has already been completed allowing you to run and test your code quickly, even for large projects.
NetBeans uses some fancy caching and versioning to avoid having to recompile your entire project every time you save a file. That's why the other solutions listed here will often work; they are ways of defeating this caching-and-versioning system when it occasionally fails, as it has above.
Solution B:
Create empty folder e. g. C:\Temp\mine
Create a new shortcut for NetBeans
with command line parameter in Target:
"C:\Program Files\NetBeans 8.2\bin\netbeans64.exe" --userdir "C:\Temp\mine"
When compile errors occur
(ClassNotFoundException, MethodNotFoundException, etc...)
delete C:\Temp\mine\var\cache
Notes B:
You'll lose all your NetBeans settings the first time.
Much easier to solve future compile errors caused by caching bugs.
Allows running multiple copies of NetBeans, one per userdir.
I got also this exception. My solution was:
edit and save mentioned class (.java file)
clean & build project
deploy to tomcat server
I just had this happen to me with Netbeans 7.4 Beta.
Things I tried:
Restarting Netbeans.
Clean and build.
Shutting down netbeans, renaming the cache dir, starting netbeans and waiting for scanning to complete.
What worked for me:
Making the source file writable and saving a meaningless change (inserting a space).
I don't know why any of the other steps didn't fix the error. Maybe it would have worked if I had done a clean and build after renaming the cache dir?
Its a very frustrating situation to be in - Hopefully this helps someone (perhaps a future me?).
The JDK says for ClassFormatError:
Thrown when the Java Virtual Machine attempts to read a class file and
determines that the file is malformed or otherwise cannot be
interpreted as a class file.
Perhaps a class file has become corrupted. I am going to do the standard IT support statement.
Have you tried restarting NetBeans?
Hope that helps
Got right the same thing with Netbeans 7.1.
Working on a project that works fine for several months.
Now I changed a bean which gets persisted with javax.persistence and now this exception got thrown. Reverted my few changes, clean and compile the project, reboot the whole system: still exceptions.
The curious thing about it: the generated .war works perfectly in a Tomcat at another machine.
UPDATE:
Today I got the same problem again and I couldn't recall how to solve it, but I found this post again. ;)
After a half hour I found the solution: Just change value of the property serialVersionUID, redeploy the app and then you can change the value to its original value and redeploy again -> working.
Seems like Tomcat is holding that class somewhere deep inside – deleting working directories didn't led to success.
I have an urgent and puzzling problem with Eclipse. My system crashed on itself this morning, and after I rebooted, I can run a program perfectly within Eclipse, by right-click on the Java file and choose 'Run as Java Application'. However, after I make the project into a .jar file, and execute that, the behavior of the program simply does not reflect what the code does.
I have checked that I am compiling the right project, and running the same code from the same project within Eclipse does not cause any problem. And btw, I am using a plug-in called fat jar to compile the .jar file, if that makes any difference. I have used the same plug-in numerous times before to compile the very same project, and never had any problem.
Does anyone know what might be causing this weird/inconsistent behavior of Eclipse? Do I need to re-install Eclipse and fat jar to fix this? Thanks.
My usual procedure for strange things like this is,
A) Clean and build again i.e. Project -> Clean
B) (not so eclipse related) Since I am usually using a build tool, do the same thing from the tool to ensure its eclipse.
C) If it gets really bad, I'll start a new eclipse workspace and try from there.
D) Iff I had just installed a new plugin before things went strange I'd think about reinstalling
It sounds extremely strange :)
But Eclipse can, and has, acted strange before. I have had problems in both Java, C++ and PHP development during the years that could only be fixed with a resinstall of Eclipse. You could probably fix it by digging around, but the time it takes to find and fix these types of strange problems in Eclipse is simply not worth it.
Good luck!
Please try to Reset Perspective first (Before reinstall eclipse)
Window->Reset Perspective.
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