It seems like many people are having this problem, but none of the problems i have researched so far are that basic like my problem.
I only got this object:
and a basic call in my main method:
Bamm... already not working. The compilataion fails with this error
I am using IntelliJ and have installed the Lombok plugin.
If it helps... here is my build.gradle:
Any ideas ?
Lombok uses the annotation processor to do its magic so you have to add lombok annotationProcessor dependency in your build.gradle file. Add this line inside your dependencies block:
annotationProcessor 'org.projectlombok:lombok:1.18.6'
Related
I am getting java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/PropertyNamingStrategies which is used in another project. I have included jackson jar in current gradle project as well. But while starting the project I am getting the above mentioned error. Seems like we need to add com.fasterxml.jackson.core.exc.InputCoercionException as an dependency but I am not able to understand where to add this as a dependency ? Can someone please help ?
java.lang.NoClassDefFoundError Either means - missing dependency with class com/fasterxml/jackson/databind/PropertyNamingStrategies or class was removed meaning jackson libs versions used in your project dependencies won't work together.
How to start solving problems like those.
1, Via IDE try to find missing class if is present. If is not present then try to find jar with missing class on internet and add as dependency. In case your IDE show class is present then problem may be with import scope. Scope management differ per used technology so provide detail which one you use or paste dependencies from build.kts . Make sure you use implementation in case you import this class in project and not runtimeOnly.
2, You found class then try to print project dependency tree command differ per used technology. For gradle ./gradlew dependencies or for submodule ./gradlew submoduleName:dependencies and look at versions of jackson in your project.
3, Check jackson lib with version listed via dependency tree contains missing class.
How to avoid problem like those with spring boot.
I would recoment to use BOM provided by spring boot project, versions in there should work together.
For gradle with kotlin DSL we import it like this
import org.springframework.boot.gradle.plugin.SpringBootPlugin
plugins {
id("org.springframework.boot") version "2.6.2"
}
dependencies {
val springBootPlatform = platform(SpringBootPlugin.BOM_COORDINATES)
annotationProcessor(springBootPlatform)
implementation(springBootPlatform)
//this version has to be searched for spring boot version
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:2021.0.0"))
//put desired jackson dependencies
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
}
IDE:IntelliJ IDEA 2020.3.2 (Ultimate Edition)
Play:1.4.4
Lombok:1.18.18
Exception:play.exceptions.CompilationException: The method getId() is undefined for the type Order
at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:264)
at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:678)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:522)
at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:300)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:420)
at play.classloading.ApplicationClassloader.getAssignableClasses(ApplicationClassloader.java:466)
at play.templates.GroovyTemplateCompiler.endTag(GroovyTemplateCompiler.java:362)
at play.templates.TemplateCompiler.generate(TemplateCompiler.java:93)
at play.templates.TemplateCompiler.compile(TemplateCompiler.java:15)
at play.templates.GroovyTemplateCompiler.compile(GroovyTemplateCompiler.java:39)
at play.templates.TemplateCompiler.compile(TemplateCompiler.java:28)
at play.templates.TemplateLoader.load(TemplateLoader.java:85)
at play.templates.TemplateLoader.load(TemplateLoader.java:180)
at play.server.PlayHandler.serve500(PlayHandler.java:836)
at Invocation.HTTP Request(Play!)
I already checked the settings here, but that didn't fix the problem:
I managed to make it work on a gradle project (Intellij 2020.3.2)
by using exactly this in build.gradle :
annotationProcessor 'org.projectlombok:lombok'
I think important point is to declare it as "annotationProcessor" type and not "compile" or so.
if someone gets the same issues, I found the answer
just keep the IntelliJ setting all the right
then I trying to change the Lombok version
Playframework - 1.4.4
Lombok - 1.18.2
IntelliJ - 2020.3
IntelliJ Plugins - Lombok 0.32-EAP
that's work ...
I'm trying to set up the PubNub jar as a library in my Android Studio project. The project is something I am porting over from another computer, so I'm mostly copying things in.
It appears between then and now that I now have to configure the AnnotationProcessor of this jar, but I'm really not sure what that requires, nor have I been able to find an example that fits my issue.
When I try to compile my project, I am left with this message:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:javaPreCompileDebug'.
Annotation processors must be explicitly declared now.
The following dependencies on the compile classpath are found to contain annotation processor.
Please add them to the annotationProcessor configuration- pubnub-gson-4.19.0-all.jar (pubnub-gson-4.19.0-all.jar).
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.
Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error- message.html for more details.
I'm really not sure at all what this is telling me to do, and the examples I can find of annotationprocessor on the internet (none for PubNub) all are pointing to packages and classes, which I don't see what I am suppose to do with.
Can someone lead me down the correct path?
I apologize for the formatting of the error, but the site wouldn't let me submit it in blockquotes because it was "improperly formatted code."
Try to add this line in your dependencies{} block:
annotationProcessor files('libs/pubnub-gson-4.19.0-all.jar')
(along with the implementation files('libs/pubnub-gson-4.19.0-all.jar'))
It works in my case.
I'm trying to implement my own annotation processor in my android studio project. All is working well and compiling until I add this simple line to build.gradle dependencies block:
dependencies {
.
.
.
annotationProcessor(':processor')
}
At that point I get this error when compiling:
Could not find :processor:. Required by:
project :app Search in build.gradle files
I've followed endless tutorials and nothing seems to help. I've just recently upgraded to AS 3.1 and thinking maybe it relates?
Here is the project structure: (mind you - here I add the annotation processor as a jar file. I've also attached an image trying to do it as a different module and same result)
Here is a different I'm trying to add it - creating the annotation processor in the same project with a different module and still no go:
Some extra info in pics...
Project structure:
app.build:
processor.build:
annotation:
MainActivity:
Processor implementation:
If you have everything inside the same artifact, — annotation processor, it's annotations and library classes, used by processor users, Android Gradle plugin requires you to declare two dependencies on the same artifact:
annotationProcessor project(':processor')
compile project(':processor')
or
annotationProcessor files('libs/processor.jar')
compile files('libs/processor.jar')
Note, that such setup might become unsupported in future. It is advisable to split your processor in separate module and make it depend on the rest of code. After doing so you will be able to declare dependencies like this:
annotationProcessor project(':processor') // processor-only jar
compile project(':processor-api') // annotations and classes for user code
I am building a web application and I am using Dropwizard 1.3.0, which has a dependency on jetty-io 9.4.8. This dependency has conflicts with another package (dropwizard-websocket-jee7-bundle 2.0.0), because it seem to fetch the wrong version number.
I looked into tha package, and found the method that has been renamed in 9.4.x - AbstractWebSocketConnection.java from 9.3.x - AbstractWebSocketConnection.java. The issue is that even though in Gradle the dependency tree shows I fetched 9.4.8 (the new one which I need), I still get the older, 9.3.x java file which causes the conflicts. I tried to Invalidate Caches / Restart and rebuild the whole project, but I seem to get the outdated file all the time.
What are the possible solutions for this?
If your bad class are imported by a transitive dependency, try to exclude explicit the transitive dependency.
For example if your required library is 'my.group:requiredLibrary:2.0.0' and there are another version in 'my.group:someDependency:0.1.5' you can do like this:
dependencies{
compile 'my.group:requiredLibrary:2.0.0'
compile ('my.group:someDependency:0.1.5'){
exclude group: 'my.group' module:'requiredLibrary'
}
}
Try forcing a particular version in your build.gradle
Example here: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html