Gradle : Unresolved compilation problem: log cannot be resolved in eclipse - java

I am stuck with a very weird problem.
I have a spring boot project managed by gradle, which has no errors in workspace. But when I run the spring boot application from eclipse (right clicking on #SpringBootApplication file and doing run as java application), it throws the following error:
Application startup failed
java.lang.Error: Unresolved compilation problem:
log cannot be resolved
But the weird thing is, when I run the same application from command line using ./gradle run it works perfectly fine.
Also I have imported few other gradle projects which makes use of lombok and they works perfectly fine from eclipse, so you can assume that lombok is set up perfectly in eclipse.
Just to give you some info, I have already tried the following steps
Refreshed gradle project
cleaned the project and restarted the eclipse
I already have lombok dependency in gradle
Lombok setup is done and other project are able to pick lombok annotations
Downloaded new eclipse version, problem stills exists
I am not able to figure out the problem. Please help!!.

Related

Can't run very simple Java application in Eclipse IDE for Enterprise Java and Web Developers , but can run it in Eclipse IDE for Java Developers

I get a java.lang.ClassNotFoundException for the class that I'm trying to run. The class itself has nothing but a static main function which prints test.
I created the project in the exact same way in Eclipse IDE for Java developers, where it does run. Then I looked through project properties to see if anything was different. I also checked the run configuration. Everything seems the same.
I have cleaned the project. It is a gradle project and I have also tried running the clean task and the CleanEclipse task. The gradle build task runs successfully.
I have tried creating a default Java project without gradle and it gives me the same problem.
I do have a project using gretty that is functioning properly, but it has a dedicated gradle runApp task.
I could just try and reinstall Eclipse IDE for Enterprise Java and Web Developers again, but then I'll never know what the problem was.

Groovy files throwing ClassNotFoundException in Java Spring Boot application

I have updated my STS to v4 few days ago,since then I unable to run my application which has groovy files.
I have installed Groovy Development plugin and tried to build the project using the maven command "clean install".
Maven build has been successfully executed, but when I started my project it throws that the Groovy class has not found exception.
I tried cleaning the project many times, but getting the same ClassNotFoundException for the Groovy classes.
My STS v4 installation details:
Java Build path details:
Error Details, while I am running the project:
That parser class is the groovy class which throws ClassNotFoundException.
Moreover, I the project explorer some strange icon is shown next to those kind of groovy files.
I am also attaching the maven build details,
these build information shows that those groovy files are compiled successfully, but still it throws ClassNotFoundException while starting the application.
NOTE: I gave clean - build, "clean compile" and updated maven project more than 15 times. Yet no luck.
Please help me in reSolving this issue SO!
Found the answer!
Compiler mismatch is the culprit here.

Lombok : constructor is undefined

I am using lombok in a spring project and building with gradle. All of the things were woking fine before. suddenly some errors have started coming.
Error is "Constructor(Constructor name) is undefined".
Have given all the DTO #Data,#NoArgsConstructor,#AllArgsConstructor, so ideally all the constructor should be available.
I have tried to build the project with old and new versions of Spring tool suite and changed lombok jar as well. but still same or different errors are coming.
Tried with STS4 and STS 3.9.7, 3.9.8 same issue is coming.
Tried lombok 1.16.22, 1.18.0,1.18.2,1.18.8.
Please help me to resolve this issue.
Might be issue with Lombok setup.
Did you follow below listed steps.
Copy the lombok.jar to your STS installation path.
Run the command and update your STS path.
java -jar /path/to/your/lombok.jar
Update the STS.ini (aka SpringToolSuite4.ini) with
-javaagent:lombok.jar
Restart STS/Eclipse.
Steps To Setup Lombok

Maven issues in Eclipse when trying to use Selenium 3.4

I am trying to move a Java project from Selenium 2.53 to 3.4. I am using Eclipse Mars under Windows 7. Eactly the same problem happens in a fresh installation of Eclipse Neon.
I have changed the Maven dependency to selenium-java 3.4 and got NullPointerException when trying to run the project in Eclipse. After a Maven build of pom.xml, the resulting jar runs fine.
I thought the project might have gotten corrupted, so I started a new Maven project, hoping to move the code into it eventually. After creating a simple Maven project I added selenium-java 3.4 as a dependency - and immediately got an error during the project build in Eclipse. The details say, again, NullPointerException. Then I installed Neon,created a new project again, added selenium-java 3.4 as a dependency and got the same issue.
Unfortunately I have no way of knowing on what line the NPE happens. When trying to save pom.xml, I get a windows saying:
'Building workspace' has encountered a problem. Errors occurred during the build.
When I click Details I see:
Errors occurred during the build.
Errors running builder 'Maven Project Builder' on project 'service.apm.ui_auto.dataentry'.
java.lang.NullPointerException
When I look into Errors, all I see is "Project configuration is not up to date with pom.xml. Select Maven -> Update project from the project context menu or use Quick fix". When I do that, I just get another window with "'Updating Maven Project' has encountered a problem". And the Details button shows a message about the NPE again.
After a lot of "trying stuff" I have stumbled upon an apparent solution.
I rename C:\Users\myuser\.m2 and then the new project starts working just fine - it builds, runs, Maven Update project works... until I try to build the old project. As soon as I try to build the old project or update it (right click old project > Maven > Update project), the Null Pointer Exception returns, and then it affects the new project too.
Moreover, even if I do not touch the old project, the NPE eventually returns, apparently during downloading sources and javadoc. While I will try disabling downloading sources and javadoc, this does not look like a complete solution.
After a lot of "trying stuff" I have finally stumbled upon an apparent solution. It was not great, but I am placing it here for the benefit of others who get the issue.
I have:
Installed Eclipse Neon in a separate directory and with a separate workspace
deleted C:\Users\myuser\.m2
created a new project from scratch, and did NOT import the old projects into the new Neon
Now things seem to work fine, though at one point, the NPE returned - I think updating the indexes corrupted the repository again. I deleted .m2 and the NPE went away.
It seems there is a maven build issue with current version of selenium jars 3.4.0, so what worked for me was adding dependency for a lower version of selenium, in this case, version 3.3.1. Once added and saved, no error was seen and the project was successfully built.

Error when opening eclipse with Spring Tools Suite

I am using the Spring Tool Suite for eclipse. When I launch the program. I get the following message:
An internal error occurred during: "Initializing Spring Tooling".
Attempted to beginRule: P/some.package.name, does not match outer
scope rule: Beans Model Initialization
But I don't understand what it means
Thanks for your help
It will work if you clean your project.
Eclipse-project-clean.
It works for me.
It was a problem with the eclipse project. As this was a maven project, I was able to do the following:
I deleted the project in eclipse (right click - delete). I then deleted the .project file from the directory and imported the project as existing maven project.
(I think you can only do this if you are using maven)

Categories

Resources