I'm using grails 2.5 and was using grails spring websockets in my project and everything was ok. Now, as I want to implement login with Google added the maven dependency to BuildConfig for google api client:
compile 'com.google.api-client:google-api-client:1.20.0'
And now, when I run the app I get this error
java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()
This is because there's a conflict between the Jackson libraries that spring websocket plugin and google api client are using.
As I could see, it looks like google api is using an outdated version of jackson.
Is it possible to exlude jackson to be imported from a maven dependency? I know that from a grails plugin is possible adding 'exclude'. But it doesn't seem to work for a maven dependency, I've added this but with no luck:
compile 'com.google.api-client:google-api-client:1.20.0', { excludes "com.google.api-client:google-api-client-jackson2:1.20.0" }
Just to remind, the google api client dependency is under 'dependencies' group in BuildConfig, which is using mavenCentral() to get the dependencies, not under 'plugins'.
Does anybody know how could I fix this?
thanks
EDIT: Probably not ideal, but I could solve this problem just adding the latest jackson dependency
compile 'com.google.api-client:google-api-client:1.20.0', {
excludes "com.google.api-client:google-api-client-jackson2:1.20.0"
}
compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
I don't think what you are trying to do is possible. Exclusions can work for plugins because the source is downloaded and compiled locally. For dependencies, you are using maven, which is downloading jars. You can't tell maven to exclude part of the jar.
The Google code you want to use may depend on other methods of the Jackson version it depends on that are not present in the version you want to use. In that case, if Maven allowed excluding Google's declared version of Jackson, the Google library would not even work. (The same problem would occur for plug-ins if they needed a different version of some library at compile time.)
You could try making your own version of the Google jar that uses your preferred version of Jackson. If it doesn't depend on methods from the older version of Jackson, that could work.
Related
I was trying to include graphql integration test cases in an already existing maven project using java springframework v.4.1.0, for which I added library com.graphql-java-kickstart » graphql-spring-boot-starter-test v.6.0.0.
But after adding this, I got the following error for an existing and working test case:
java.lang.NoClassDefFoundError: org/springframework/core/annotation/MergedAnnotations$SearchStrategy
Could someone please help resolving this conflict. Is there some version of this library that is compatible with MergedAnnotations library of springframework. Or is there some other similar library available for implementing java graphql test cases. Also it will be very difficult to upgrade the springframework version because its a huge project and has a lot of dependencies.
I tried upgrading a few versions of com.graphql-java-kickstart » graphql-spring-boot-starter-test but nothing really worked as some or the other part of the project was getting affected.Also tried upgrading springframework version but could not do so because of the libraries and dependencies included.
I had imported a Third party SDK from another project. I had set it up and it wouldn't read a certain Dependency, even when I had put the dependency in the build gradle.
Here's the SDK
And in the build.gradle
// dependency needed to use SDK
implementation "org.altbeacon:android-beacon-library:2.16.3" <- That's the dependency
implementation project(':parabit_beacon_sdk')
implementation 'org.jetbrains:annotations:20.1.0'
implementation "com.google.android.gms:play-services-location:21.0.1"
I've tried a few things already, but nothing seems to be working. Any help is appreciated. Thanks
There is no version 2.16.3 of org.altbeacon:android-beacon-library in Maven central repository:
https://mvnrepository.com/artifact/org.altbeacon/android-beacon-library
Unless you have configured an additional repository where this library is present, Android Studio can simply not resolve this library and thus the import statements for this library show an error.
Note that JCenter repository does no longer exists. The version you want to use was once published there but as the repository no longer exists you can not use it anymore from there.
Change your gradle config to use a version that exists on Maven central.
I am using gradle 6.7 and creating a library project which is compiled to a jar that is placed in my own s3 artifacts repository.
In my project I have dependencies to other artifacts and I use implementation dependency.
The jar is created (not a fat jar) and uploaded to the s3 repository.
When in another project I am using my library by fetching it as implementation dependency I am getting errors NoClassDef for other dependencies I used in my library, which means that no runtime is found for the dependencies I was using in my library.
My question is, whether it is a good idea to create a fat jar? I don't think that other libraries (e.g. springboot and others) are using fat jars, right? however when I use them as dependency other dependencies are found on runtime.
Does it mean that using implementation in my project for other dependencies is not the right way? shall I use something else? Could you please contribute a bit more about what is the right way?
Thank you
Check out the Java Library Plugin for gradle. It exists for this exact situation.
If a dependency of your library needs to be exposed to the consumer of your library, then you would use api instead of implementation. There is a nice section within the plugin documentation here that can be used to help you identify when to declare a dependency as api vs implementation.
So I ran into a problem with a project. Where Eclipse would say that java.util.* has an import error The package java.util is accessible from more than one module: <unnamed>, java.base
I dug around a lot it appears that for some reason no one else is really having this issue. Everyone in our office was. They have told me though that a RC version of Eclipse from 2018 I think Sept works, but that is the only one they can get it to work in. I'll try to post the real version later. So I searched a lot and then started playing with the gradle file for includes. And found that the problem only exists if I include the Cassandra-unit-spring testCompile requirement and because of that it only causes a problem on the test case side.
My assumption is that this is somehow a bug with eclipse as gradle itself has no problem with it. As well as intelij. Let me know what else I can provide here to narrow this down further.
Eclipse Build id: 20190917-1200
Eclipse with Lombok Lombok v1.18.10
Gradle 5.6.4
Oracle JDK 11.0.5
tried cassadnra-unit-spring versions 3.5.0.1 - 3.11.x
Also using spring boot 2.1.3.release
Thanks.
I have excluded all (transitive) dependencies of cassandra-unit and re-included them one by one. Eventually, I found out that the library com.boundary:high-scale-lib, i.e., a transitive dependency included by org.apache.cassandra:cassandra-all, is responsible for the import errors.
The library is not Java 9+ ready, since it uses a java.base package name, i.e., java.util. This is not allowed. Unfortunately, you cannot exclude this transtive dependency, since it is required.
I found out that the release version of Eclipse 4.10 does not indicate errors in projects using the library. This is probably a UI bug in newer Eclipse versions, since I can compile and build my application with Gradle without any errors.
You can try this Eclipse version.
Thank you very much for your hard work Sincostan
So with the information you provided, if you put into your build.gradle file the inclusion of the cassandra unit test like this
testImplementation ('org.cassandraunit:cassandra-unit-spring:3.11.2.0') {
exclude module: 'high-scale-lib'
}
This allowed it to work in my case. you would of course need to use your own version etc. This is with Gradle 6.3 at this time.
I have a project that has two needed dependencies for it. These dependencies have in turn apache cxf dependencies. Dependency A uses apache cxf versions 2.4.0 where dependency B uses apache cxf versions 3.1.0.
Because classes were changed between the versions, using one or the other results in ClassNotFoundException's.
A little description of what they are, Dependency A is the client jar for some old SOAP webservices. This includes the autogenerated files from wsdl2java. Dependency B is the client jar for a new REST webservice.
The main project uses Maven to handle dependencies, is a war, and is on tomcat 7.
Any thoughts for what I could do to try and get this to work correctly? I have already tried making the REST client a jar-with-dependencies and bringing it in through Tomcat's common classloader with no luck.
EDIT
After reviewing the dependencies I am bringing in, I can't simply update the dependencies because I do not have control of some of the dependencies being brought in. I would need to alter what those jars are doing and that will not work.
Its never a good idea to use two version of same dependency as it can create discrepancies in your project.
Ideally you should latest version and then make the old code compatible with latest version