Adding org.apache.kafka to dependencies with Gradle - gradle

I started a Gradle project with gradle init --type java-application using Kotlin as the build script DSL, and I just wanted to add org.apache.kafka library
dependencies {
// This dependency is used by the application.
implementation("com.google.guava:guava:28.0-jre")
implementation("org.apache.kafka:kafka_2.10:0.8.0")
// Use JUnit test framework
testImplementation("junit:junit:4.12")
}
But gradle build returned this:
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find jmxtools.jar (com.sun.jdmk:jmxtools:1.2.1).
Searched in the following locations:
https://jcenter.bintray.com/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
> Could not find jmxri.jar (com.sun.jmx:jmxri:1.2.1).
Searched in the following locations:
https://jcenter.bintray.com/com/sun/jmx/jmxri/1.2.1/jmxri-1.2.1.jar
What's this about? Conflicts with JCenter?

As already mentioned in the comments upgrading the kafka version will solve the problem (probs go to #cricket_007).
The root cause for that problem is actually not kafka itself but it's transitive dependency log4j in a version 1.2.15. This log4j version requires jmxtools and jmxri. Due to some licensing issues these artifacts are NOT available on maven central and jcenter. The good news is: You most likely don't need it at all. You simply override the log4j dependency to use 1.2.16 (or above) or exclude jmxtools and jmxri.
You can also find some more insights in this blog article: http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/
So 3 ways to solve this issue:
use a more recent kafka-version OR
use a log4j version > 1.2.15 OR
exclude jmxtools and jmxri
Hope that helps and make things more clear

Related

Could not able resolve javax.inject: javax.inject:1.0 - Gradle

I am getting below error while running Gradle build in Unix terminal.
Could not resolve all files for configuration ':imcalmsvc-service:compileClasspath'.
Could not find javax.inject:javax.inject:1.0.
Searched in the following locations:
- https://jcenter.bintray.com/javax/inject/javax.inject/1.0/javax.inject-1.0.pom
- https://repo.maven.apache.org/maven2/javax/inject/javax.inject/1.0/javax.inject-1.0.pom
However, there is no error while doing Eclipse-> Gradle refresh.
The error means the dependency wasn't found in either JCenter or Maven Central. When you are usure about the exact name of dependency or which repositories it is uploaded to, I recommend a search engine like mvnrepository.com. It aggregates metadata from a lot of different Maven repositories and even shows you how to use them in Gradle.
In your case, you can find the javax.inject library here. Notice that the only published version is simply 1 and not 1.0. Change this and it should work.

Gradle refers jars but they are not in POM nor in the code links

We migrated our maven code to gradle. When we build, we are getting error as Could not resolve all files for configuration ':***-war:compileClasspath'.
Could not find mockito-core.jar (org.mockito:mockito-core:2.8.9).
We are not referring to this jar itself.. neither we are able to locate in our code nor in pom...
How to figure out?
how to configure gradle to compile code if jar doesn't exist and pom exists in the repository or locally ?
If you can't work out where it's coming from and you don't use it at all, then you can exclude the dependency from all the configurations:
configurations.all*.exclude group: "org.mockito", module: "mockito-core"
If the dependency isn't appearing in the dependency report, then I'm somewhat at a loss as to why Gradle is complaining about it. The only other option I can think of is that some plugin is adding it in a non-standard way.

Gradle cannot resolve dependency for spring framework uaa client?

I have just started using gradle, and facing same issue in multiple gradle projects. The dependency for 'org.springframework.uaa.client:1.0.1.RELEASE'
is not resolved.
I checked and the repository used, contains the given artifact but still gradle reports an error like below:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve org.springframework.uaa:org.springframework.uaa.client:1.0.1.RELEASE.
I googled a lot and found similar problems being faced by others, but no particular solution.
Here Gradle Discussion it is discussed that the problem maybe due to the 'relativePath' in the pom, which is not resolved by gradle. And that it might be a problem in the pom, and not with gradle.
But what is the exact solution at the present, or any work around to resolve this issue ?
Note : 1. An issue has been open in reference to the above gradle discussion but it's still marked as un-resolved !!
2. The project I am trying to run are using a gradle wrapper 'gradle-1.0-bin.zip'
EDIT 1
I am trying to run the gormish project from GIT and I have faced same issue in another gradle project for using gorm-stadalone here
The repository used is :
repositories {
mavenCentral()
mavenRepo name: "Grails", url: "http://repo.grails.org/grails/repo/"
}

Gradle plugin compatibility - how to find out?

Can Gradle plugins for 1.11+ be expected to work for 2.+, and if not, how can one find out the state of compatibility?
Specifically, I have had success using Gradle 1.11 in a project spring-boot project. When upgrading to Gradle 2.2, I noticed that the spring-boot plugin does not seem to be available, although I haven't found any references to a particular Gradle version in the Spring Boot Gradle documentation (http://docs.spring.io/autorepo/docs/spring-boot/1.2.0.BUILD-SNAPSHOT/reference/html/build-tool-plugins-gradle-plugin.html).
Using Gradle 2.2, I get:
* What went wrong:
A problem occurred evaluating root project 'NN'.
> Failed to apply plugin [id 'spring-boot']
> A problem occurred configuring project ':webapp'.
> Extension of type 'SpringBootPluginExtension' does not exist. Currently registered extension types: [DefaultExtraPropertiesExtension, DefaultArtifactPub
licationSet_Decorated, ReportingExtension_Decorated, DefaultProjectSourceSet_Decorated, DefaultBinaryContainer_Decorated]
It depends on the particular plugin, and would ideally be tested/documented there. 1.x to 2.x was a big jump in terms of the Groovy version used by Gradle, which can cause compatibility issues for plugins implemented in Groovy. Also, 1.x plugins using deprecated or internal APIs may not work in 2.x.

Maven java compile error can not access CommonClassA

Background:
I am developing Maven multi module project.
One of the module is common module needed by other all modules.
This module contain CommonClassA.java.
common module is properly compiled.
It is installed into maven local repository properly.
One of the class(Billtype.java) in other module (EmployeeBilling) refers this class(CommonClassA.java).
Maven Dependency for common module is properly specified in pom.xml of EmployeeBilling module.
Problem:
While compiling EmployeeBilling module it throws
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project EmployeeBilling: Compilation failure
[ERROR] \MyWorkspace\Biz\EmployeeBilling\src\main\java\com\employee\Billtype.java:[79,19] error: cannot access CommonClassA
[ERROR] -> [Help 1]**
Supporting details:
dependency defined in EmployeeBilling> pom.xml:
Other classes from common module seems accessible as no error observed
There are no other errors like Class not found/file not found.
The class CommonCLassA implements Serializable
Same error occurs from Eclipse as well as commond line
I am using M2E plugin
Tools:
jdk1.7.0_02
OS: Windows 7
Eclipse JUNO and apache-maven-3.1.0
Thanks in advance!
If project builds properly using eclipse compiler then it should work with Maven.
Few things to check if its not working with maven:
Manually check in repository that jar is installed properly and it contains your class file.
Try to build project using locally installed Maven instead of maven in eclipse.
Set -DskipTest=true while installing your jar, as it can cause issues at times.
If these steps don't work then show us your pom.
With no more information it's hard to find the cause. But I also had this problems now and then, and there are some things which could go wrong:
Are you using the right JAVA version (everywhere) ?
... and the right java PROVIDER? (Oracle, IBM, OpenJDK) In my case it's often this issue, I'm sometimes bound to IBM JDK, although I try to use Oracle where I can and this sometimes breaks my build.
Is the right maven dependency VERSION used? If you depend on it multiple times, and all in the same (lower than root) dept of dependencies, Maven will just "choose" a version. It could be that thát version is incompatible with your code of thát particular dependency
Skipping tests sometimes WORKS! It has something to do with maven phases and getting stuff ready for using it elsewhere.
Good luck :)
I had the same problem. Even the jar dependency has the required class files. Finally I deleted the local maven repo and restarted the build. Now it worked without any issue.
It looks like you are using an old version of maven-compiler-plugin (v2.3.2).
I suggest you upgrade it to 3.x. it won't magically fix your issue but it will definitely give you better / more detailed error message.

Resources