We have a Gradle project that I'm trying to use in Eclipse.
After other users made changes and I had to do a Gradle Refresh, Eclipse now can't compile the project.
The project was not built since its build path is incomplete. Cannot find the class file for
org.springframework.retry.support.RetryTemplate. Fix the build path then try building this project
The type org.springframework.retry.support.RetryTemplate cannot be resolved. It is indirectly
referenced from required .class files RabbitMQConfig.java /Account/src/main/java/com/efi/metrix/config line 1 Java Problem
If I use Ctrl-T, I can see the class and what jar it is in. The jar IS in the classpath and can be seen under the "Project and External Dependencies" section in Package Explorer.
I've tried deleting the jar and re-running Gradle Refresh, which downloads the jar again, and I get the same error with the build failing. I've also tried an Eclipse Clean on the project.
(I did try restarting eclipse as well.)
Any hints on what might be causing this?
Finally tracked this down.
Eclipse project, Properties -> Java Compiler -> Errors/Warnings
In the "Enable annotation-based null analysis" section, if you have "Inherit null annotations" enabled, you get the compile errors.
I turned off that option, and it now compiles without errors.
Related
I have a JEE project and I use maven to build it. In the pom.xml, I specify certain dependencies, e.g. for org.jboss.ejb3 or org.jboss.logging.
Building the application works, both inside/ with the IDE as well as manually invoking "mvn clean install" from the cmd. My issue now is that all imports from the dependencies included in the pom.xml are marked as "cannot be resolved" which results in correct code being marked as incorrect as well as auto-completion not working. I have tried re-importing the project but that has not yielded anything at all.
Also, I have already searched the internet (including Stackoverflow) but none of the answers found were able to help me fix it.
Without knowing what errors you are seeing I am going to assume that your issue is with eclipse project properties (build path, src directory specification, output classes directory, etc).
You tagged m2eclipse plugin, so you should be able to right click on your project in eclipse select maven->update project configuration. If you do not see that option under maven then you should first see an option called maven->enable dependency management. Click that first and then you should be able to see update project configuration option.
If this does not fix it, then open your project directory containing the pom.xml file in command prompt and run mvn eclipse:eclipse.
One of the above should resolve those pesky error messages provided that your maven build itself is successful.
In an eclipse project, I referenced a class that was currently not in project's build path.
In the context sensitive pop-up that opens by hovering the mouse over the error, "Fix project setup" option has offered me to add a jar to the build path of the project. This jar is in my local maven repository.
However, the "correct" way to fix it is obviously by adding the relevant dependencies to my project's pom, instead of adding this jar to the build path of the project.
So is there a way to configure eclipse, so that it won't offer to add a maven repo jar to the build path, but it will offer to fix the project's pom?
This feature used to exist in m2eclipse (the predecessor of m2e), see e.g.
https://blog.sonatype.com/2010/03/adding-dependencies-using-m2eclipse/ which shows a "Search dependency for XXX" quickfix above the "Fix project setup..." quickfix.
Unfortunately it didn't make it into m2e, see https://www.eclipse.org/lists/m2e-users/msg01130.html
Make sure:
your project is fine outside of eclipse using only maven/pom, mvn
clean install (or similar) in an external shell/console
your eclipse project has maven nature
Eclipse -> Project -> Build Automatically is checked
Refresh your eclipse project
Do something in the pom.xml (save file) should trigger a build
I'm getting compilation errors when I open a specific class file in Eclipse. However, the class doesn't show a compilation error icon in the Project Explorer. I have enabled dependency management by right-clicking the project and using the Maven menu.
I'm using Eclipse 3.7.1 and Maven 2.2.1.
I've not seen this problem before, but I'd try performing the obligatory clean and build all on the project. I suggest making sure the following options are checked in Preferences -> Java -> Compiler -> Building:
Scrub output folders when cleaning projects
Rebuild class files modified by others
There are several good suggestions in the question linked by bdill, specifically to try updating your project configuration from the pom.
Use Package Explorer, not Project Explorer. It's a lot more reliable for Java projects.
I am getting a class not found exception for my Login Controller when I try to login to my application(It is a spring MVC Application). Before running the maven clean command the Application was running perfectly, I used maven clean and then again done a build using maven package command, suddenly it stopped working. I tried restarting the TomCat, re-deployed the application on TomCat, restarted the Eclipse IDE but nothing has worked so far.
Why this happens and what is the possible solution to this ??
Are you trying to run your project under Eclipse?
And does it generate source files?
If these are both true, you probably need to update the project config (select project or pom, right-click, Maven..Update..Project Configuration and Maven..Update..Project Dependencies).
The problem is that when Maven does a clean, it gets rid of the generated directories, which Eclipse observes and removes from your Build Path. But then when Maven rebuilds the directories, Eclipse doesn't notice it - you have to give it a hint.
Check your project for build errors and build path errors.
Make sure you've defined an M2_REPO classpath variable in Eclipse (Preferences - Java - Build Path - Classpath Variables).
If you're using the m2eclipe plugin, right-click your project and click on Maven - Update project configuration. That will configure an Eclipse build path for your project based on your pom dependencies.
If you're not using m2eclipse, execute mvn eclipse:clean eclipse:eclipse in your project folder. Then refresh your project in Eclipse.
What you haven't said is that you've checked and the missing class is in fact present.
A quick way to check is in the code editor SHIFT+CTRL+T and type the name of the missing class. Eclipse should not only show you the class if it exists, on highlighting the class, Eclipse should tell you which jar it is in.
Based on the info you have provided, I would say some dependecy in your POM has been removed by mistake or you need a newer version of some jar. If you find the class is not present, then you can figure out which jar you need by googling something like Maven 2 MyMissingClass jar that usually works for me.
Delete the .metadata folder in your eclipse workspace and then again open the workspace and import the required project.
This will solve your problem.
In .metadata folder it maintains the temporary copy of the project.
what worked in my case was simply removing the project from work space and importing it back again.
But I still don't know why it worked Vs why other things mentioned did not work (I tried updating dependencies in fact I removed all the dependencies from pom.xml and added everything again)
How to export java project to JAR with Netbeans ? I cannot find options like in Eclipse.
You need to enable the option
Project Properties -> Build -> Packaging -> Build JAR after compiling
(but this is enabled by default)
Do you mean compile it to JAR? NetBeans does that automatically, just do "clean and build" and look in the "dist" subdirectory of your project. There will be the JAR with "lib" folder containing the required libraries. These JAR + lib are enough to run the application.
If you disable "Compile on save" in the project properties, then it is no longer necessary to do "clean and build", simply "build" will suffice in most cases. This will save time if you want to change just a bit of the code and rebuild the JAR. However, note that NetBeans sometimes fails to handle dependencies and binary compatibility properly, which will lead to a faulty JAR throwing "no such method" or other obscure exceptions. Therefore, if you made a lot of changes since the last full rebuild and even remotely unsure that it will still work even if some classes aren't recompiled, then you must still do a full "clean and build" in order to get a perfectly working JAR.
It does this by default, you just need to look into the project's /dist folder.
Right click your project folder.
Select Properties.
Expand Build option.
Select Packaging.
Now Clean and Build your project (Shift +F11).
jar file will be created at your_project_folder\dist folder.