Unable to resolve javax.annotation.Priority dependency issue in maven project - spring-boot

I'm starting a Jersey, Springboot project with swagger integration but I'm having issues resolving the javax.annotation.Priority dependency. I came across
this link and I have experimented with adding the suggested modules and also added
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
but so far nothing resolves this issue for me.
I'm working on MacOS and compiling in Java 10.

Related

Imported Packages : com.day.cq.wcm.api,version=[1.29,2) and org.apache.sling.api.resource,version=[2.12,3) -- Cannot be resolved

I am facing a weird issue after creating the AEM project using the archetype 24 from https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/archetype/overview.html?lang=en#available-properties
The project build successfully and deployed perfectly and somehow the osgi bundle is not "Active" because of below issue in bold: com.day.cq.wcm.api,version=[1.29,2) -- Cannot be resolved and org.apache.sling.api.resource,version=[2.12,3) -- Cannot be resolved
Imported Packages:
**com.day.cq.wcm.api,version=[1.29,2) -- Cannot be resolved**
**org.apache.sling.api.resource,version=[2.12,3) -- Cannot be resolved**
I have tried to add these dependencies in the parent pom finding in http://localhost:4502/system/console/depfinder
Somehow my efforts failed to resolve this issue, could anyone help me to resolve the issue.
thanks in advance
What you did to "solve" the issue is telling your bundle to accept any version of the packages. This very likely will cause problems later as you might get an incompatible implementation.
Instead what you should do is use the system console bundle view in AEM/sling to find out which versions of the packages are offered by the bundles. Probably the versions are lower than 1.29 and 2.12.
So the correct solution would be to use an older version of the archetype that matches the versions offered by your AEM/sling system.
Please change the language of the website to English and read the article here: https://flagtick.com/post/getting-started-with-aem-sites-setup-project-eduzone-system-part-7
It might help you a little bit.
</executions>
<dependencies>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.caconfig.bnd-plugin</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</plugin>
I had same problem with archetype 26.
resolved by adding this dependencies inside core/pom.xml
<!-- https://mvnrepository.com/artifact/com.day.cq.wcm/cq-wcm-api -->
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.9.4</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.sling/org.apache.sling.api -->
<dependency>
<artifactId>org.apache.sling.api</artifactId>
<version>2.18.4</version>
<groupId>org.apache.sling</groupId>
<scope>provided</scope>
</dependency>

Unable to debug a gradle plugin

I have developed a Gradle plugin. Since the latest upgrade of gradle, that plugin is failing, and I need to debug the plugin in order to find out what exactly is going wrong. I am, however, unable to debug the plugin.
I'm doing the following:
I set the following environment parameters: GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
I execute the build running the plugin from the commandline
I attach my IntelliJ debugger to the running process.
This immediately fails however with a ClassNotFoundException in IntelliJ: org.gradle.launcher.GradleMain.
The plugin should work with all gradle versions. The plugin itself has following gradle relevant dependencies:
<dependency>
<scope>provided</scope>
<groupId>org.gradle</groupId>
<artifactId>gradle-core</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<scope>provided</scope>
<groupId>org.gradle</groupId>
<artifactId>gradle-plugins</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<scope>provided</scope>
<groupId>org.gradle</groupId>
<artifactId>gradle-base-services</artifactId>
<version>1.12</version>
</dependency>
I have tried adding following dependency as well:
<dependency>
<scope>provided</scope>
<groupId>org.gradle</groupId>
<artifactId>gradle-wrapper</artifactId>
<version>4.5.1</version>
</dependency>
But that doesn't make any difference.
The difficulty here is that the plugin should work with all Gradle versions (version 1.12 up to 4.5). That is the reason why the plugin itself depends on old versions of Gradle at compile time. Where the different versions of Gradle differ, I currently resort to reflection to achieve my goal at runtime.
While Gradle 1.12 is in the dependencies of the project, the build being debugged uses Gradle 4.5.1. However, even if I switch the gradle version of the project being debugged, the same error remains. Also, as the plugin works fine on all versions prior to 4.5, such a debug session wouldn't help alot even if I would get it working.
Any ideas on how I can get the debugger to debug the plugin?

Serialization errors due to jackson-databind version mismatch?

I am running into the following error
java.lang.NoSuchFieldError: WRITE_DURATIONS_AS_TIMESTAMPS
at com.fasterxml.jackson.datatype.joda.ser.DurationSerializer.<init>(DurationSerializer.java:28)
at com.fasterxml.jackson.datatype.joda.ser.DurationSerializer.<init>(DurationSerializer.java:25)
at com.fasterxml.jackson.datatype.joda.JodaModule.<init>(JodaModule.java:45)
I checked to see what versions of jackson-datatype-joda are available. It appears that maven has excluded all version mismatches.
Any other reason this might cause serialization errors?
The problem is that among the maven dependencies (mind that it could be a transitive one) you have incompatible versions of jackson-datatype-joda and jackson-databind. Incompatible in the sense that jackson-databind's SerializationFeature class is missing the WRITE_DURATIONS_AS_TIMESTAMPS field. To see what dependencies maven brings you can run the following command in the terminal (or you can use an IDE's maven plug to search and analyse the maven dependency tree):
mvn dependency:tree | grep databind
the outcome will most probably be something like:
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.1:compile
The version of course can vary but the important thing is that the WRITE_DURATIONS_AS_TIMESTAMPS field is only available since version 2.5
You can exclude a transitive dependency like this:
<dependency>
<groupId>group.id</groupId>
<artifactId>artifact-id</artifactId>
<version>${artifact.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
If it's not a transitive dependency you need to update version of jackson-databind.
I got it resolved by using following dependency as this dependency has overridden any other version used:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.5.3</version>
</dependency>
I had same error. I had included all jackson*2.7.0 libraries under WEB-INF/lib/ and i was still getting that error. I am using wildfly 8.2 and it had jackson 2.4.1 libraries under modules and somehow it was loading 2.4.1 jars from that location. So I had to manually upgrade them to 2.7.0 which fixed the issue. I was under impression that if I did not mention it to load jackson jars in deployment configuration file, it would not load wildfly jars. I guess I was wrong.

Drools 6 sisu-guava conflicts with guava

We have recently upgraded from Drools 5 to Drools 6 and have run into disturbing conflict issues.
We have kie-ci imported into out project. kie-ci brings in sisu-guava. sisu-guava changes the accessibility of some of the classes from google's guava. Unfortunately, it uses the same package name as google's guava.
Since we're working with google's guava in our project, we are running into conflicts of classes.
An attempt to remove sisu-guava from the project (using a maven exclusion) results in accessibility exceptions, as the kie-ci code attempt to access classes which are public in sisu-guava but are private in google's guava.
Any idea how to get round this.
This may not be correct solution for all situation, but I was able to resolve this issue by excluding the susi-guava jar in my pom:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-kie-services</artifactId>
<version>${jbpm.version}</version>
<exclusions>
<exclusion>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guava</artifactId>
</exclusion>
</exclusions>
</dependency>
I seem to have the same problem using drools 6.2. Drools is dependent on guava 10.0.1, where as my project had a dependency on guava 16 and maven was picking the version 16 (correctly).
On inspecting the dependency tree, I find that the drools dependency on guava is dictated by "org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.0.0.M5:runtime".
There is a newer version of org.eclipse.sisu.plexus, so I added the following to my project's pom to pick up the latest version, which is:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.3.1</version>
</dependency>
</dependencies>
</dependencyManagement>
Now, there does not seem to be a dependency on guava, for drools and the problem is solved and my project can use version 16 of guava.

How to include custom type converter using Maven and Grails

I am working on a Grails project that needs to compile with both Grails and Maven. Everything worked great except for my GSON converter I added (using the grails-gson plugin). Now I get the following when I run mvn install.
unable to resolve class grails.plugin.gson.converters.GSON
Anyone know how to overcome this
Plugin has to be added as a dependency in pom.xml too
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>gson</artifactId>
<version>1.1.4</version>
<type>zip</type>
</dependency>
Mavenized grails project refer pom file for all dependencies (including plugin dependencies).

Resources