Building the project using gradle in eclipse after Using #Slf4j annotation of lombok is throwing below error :
Task :compileJava FAILED
error: cannot find symbol
log.trace("logging now");
^
symbol: variable log
But it is generating the .class file with the log variable correctly : private static final Logger log = LoggerFactory.getLogger(NetsuiteWebSecurityConfig.class);
There is no problem with the #Data lombok annotation. It is generating getters/setters in .class file and also not throwing any error .
Note : i referred this Cannot make Project Lombok work on Eclipse (Helios) for lombok installation . I can say lombok is working because it is generating the code in .class file . Not sure why it is failing while giving gradle build
I installed lombok correctly and set the annotations processor. But still nothing worked . What i have done is created a new folder at another place and cloned my git repository freshly there. To my surprise it worked . Dont know how , but the trick worked .
Related
Getting
java.lang.NoClassDefFoundError error when running xml file using
testng.
Error details: java.lang.NoClassDefFoundError: Could not
initialize class com.listeners.ExtentTestManager at
com.listeners.Listeners.onTestFailure(Listeners.java:56)
I am using testng version 6.9.10 in pom.xml.
Hi, I am getting this error when I use listeners in my xml file. If I remove listeners and run the xml file, it is working. Please let me know if anything wrong with ExtentTestManager class or the dependencies. I am unable to add code in stackoverflow, so I have attached in this link: selenium99.com/java-lang-noclassdeffounderror Pls check.
You can try maven update project in eclipse after that use clean install, it should work.
Basically
NoClassDefFoundError can occur for multiple reasons like
ClassNotFoundException -- .class not found for that referenced class irrespective of whether it is available at compile time or not(i.e base/child class).
Class file located, but Exception raised while initializing static variables
Class file located, Exception raised while initializing static blocks
But in this case it looks like you are missing some dependency in the building.
you can try cleaning whole project and build again.
If it's a eclipse project
mvn clean eclipse:eclipse
mvn clean package
try above commands
In my Jhipster generated file entityNameQueryService.java , eclipse indicates the following line as error, but project compiles successfully.
So, this must be the configuration issue with the eclipse ide. Couldn't figure it out myself..
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), FRCommunications_.id));
}
The error message is
"FRCommunications_ cannot be resolved to a variable"
For your information, FRCommunications is my entity name.
Does anyone have a fix for this?
For eclipse, After
mvn clean install -nsu
just right click on target/generated-sources/annotation and select "Use as Source Folder"
JPA static metamodel which is used for JPA filtering in JHipster requires generating classes (named like the entity but suffixed with '_') at build time through an annotation processor, this is configured for maven and gradle so you can run a build and it will generate missing classes.
Alternatively, if you don't want to build using maven or gradle see https://docs.jboss.org/hibernate/orm/5.0/topical/html/metamodelgen/MetamodelGenerator.html#_eclipse
I am trying to introduce Lombok into my project. Everything builds fine when I compile it locally but on Jenkins it reports this problem and then it fail on all the getters and setter which I replaced with #Data anotation. Jenkins uses Java 1.8. Any idea what might be wrong?
[INFO] Compiling 154 source files to /var/lib/jenkins/jobs/MERGE REQUEST build error_prone/workspace/com.betradar.betpal.server.app.api/target/classes
/var/lib/jenkins/jobs/MERGE REQUEST build error_prone/workspace/com.betradar.betpal.server.app.api/src/main/java/com/betradar/betpal/server/app/message/ObjectFactory.java:22: warning: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.google.errorprone.MaskedClassLoader$1$1 extends com.sun.tools.javac.file.JavacFileManager
public class ObjectFactory {
^
at lombok.javac.apt.LombokFileObjects.getCompiler(LombokFileObjects.java:148)
at lombok.javac.apt.InterceptingJavaFileManager.<init>(InterceptingJavaFileManager.java:40)
...
Errorprone uses the java9 compiler under the hood. There are two possible solutions:
Upgrade the Lombok dependency to 1.16.20
Downgrade the errorprone dependency
I use eclipse for my optaplanner project development and I am able to execute my code from eclipse without any problem. To make this project as an executable, I exported it as a jar file using eclipse export wizard.
Then I run my jar from terminal using the command java -jar myOptaPlanner.jar, then, I get below error
WARN given scan urls are empty. set urls in the configuration
Exception in thread "main" java.lang.IllegalStateException: The scanAnnotatedClasses
(ScanAnnotatedClassesConfig()) did not find any classes with a PlanningSolution
annotation.
Maybe you forgot to annotate a class with a PlanningSolution annotation.
Maybe you're using special classloading mechanisms (OSGi, ...) and this is a bug.
If you can confirm that, report it to our issue tracker and workaround it by
defining the classes explicitly in the solver configuration.
at org.optaplanner.core.config.domain.ScanAnnotatedClassesConfig.loadSolutionClass(ScanAnnotatedClassesConfig.java:106)
at org.optaplanner.core.config.domain.ScanAnnotatedClassesConfig.buildSolutionDescriptor(ScanAnnotatedClassesConfig.java:86)
at org.optaplanner.core.config.solver.SolverConfig.buildSolutionDescriptor(SolverConfig.java:270)
at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:216)
at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:57)
at org.roster.app.WorkerRosteringApp.main(WorkerRosteringApp.java:36)
Is this really a bug or am I exporting it wrong?
Update: I tried to export jar using maven-shade-plugin and here also I am getting the same error.
Thanks
scanAnnotatedClasses doesn't seem to work in a jar file. Instead, use following workaround:
<solutionClass>path.to.your.SolutionClass</solutionClass>
<entityClass>path.to.your.EntityClassI</entityClass>
<entityClass>path.to.your.EntityClassII</entityClass>
and delete the scanAnnotatedClasses in your config file.
If you don't want to declare the solution and entity classes manually, including the packages containing the solution and entity classes also works as workaround:
<scanAnnotatedClasses>
<packageInclude>your.package.here</packageInclude>
</scanAnnotatedClasses>
Documentation about <packageInclude> can be found here
I'm using Lombok to add logging to my Java applications. I've been using this for some time, but since I upgraded my IDE from IntelliJ 13 Community edition to 14 Ultimate, I get the following compile errors (using maven):
error: log has private access in SesameServer
This error originates in a subclass of SesameServer:
#Slf4j
public class AnnotatorServices extends SesameServer {
#Override
protected void initialiseRDFStoreManager(Series<Parameter> parameters) throws RepositoryConfigException, RepositoryException {
log.info("<< ------ Annotator Services ------- >>");
}
}
Of course SesameServer also uses the #Slf4j annotation to add logging. The #Slf4j annotation adds the line:
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(SesameServer.class);
to the class in which it is used (both SesameServer and AnnotatorServices where SesameServer.class is of course replaced by AnnotatorServices.class).
Apparently the compiler thinks I want to use the log variable from SesameServer instead of AnnotatorServices (both classes have variables with the same name).
How can I prevent this problem, i.e. that the SesameServer.log is used instead of AnnotatorServices.log?
NOTE: This still comes up for anyone else googling this error message; so adding my fix hope this helps.
I had a similar issue after reopening a project from pom.xml.
Since my parent class SesameServer was already built in a different module and used a dependency; when I compiled my AnnotatorServices I also saw the error: log has private access in SesameServer
To fix it I just had to turn on Annotation Processing for the module containing AnnotatorServices.
In IntelliJ Community 2017.1.6 the check box was found under:
File -> Settings
"Build, Execution Deployment -> Compiler -> Annotation Processors"
Tick the "Enable annotation processing"
Following steps worked for me
Install Lombok Plugin in Settings=>plugins under Marketplace search for Lombok and install.
Then in IntelliJ Community 2017.1.6 go to File->Invalidate Caches/ Restart and click on both.
Did the trick for me. All the best.
Make sure your subclass is also annotated properly with #Slf4j.
Update your lombok plugin. Sometimes idea does not display the new updates so goto settings => plugins and search for "lombok"
Click "update" and restart idea