Upgrade to Spring boot 2 breaks Groovy-Eclipse compiler - spring

I have a mixed java/groovy project with spring boot 1.5 with groovy-eclipse compiler version 2.4 I think? (I think because groovy-all/groovy-compiler/groovy-batch versions do not line up exactly?) Everything compiles fine, I had no issues. Been working this way for about a year or more.
Today I upgraded to spring-boot 2.0.3.RELEASE and now I'm getting:
Error:(1, -1) Groovy-Eclipse: Groovy:Internal groovy compiler error.
On every single groovy file.
I looked for whether spring-boot 2 and groovy are compatible but couldn't really find any answers.
It's very odd that this would happen as I have not changed the groovy portion of the code at all.
Here are some relevant POM settings:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.12</version>
</dependency>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- 2.8.0-01 and later require maven-compiler-plugin 3.1 or higher -->
<version>3.6.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.2-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.4.3-01</version>
</dependency>
</dependencies>
</plugin>

not sure if you ever got this resolved, but I had the exact same issue and upgrading the version dependencies from Bintray as suggested in the following link seemed to do the trick. Hope it helps:
https://github.com/groovy/groovy-eclipse/issues/425

Related

Transitive Dependency: Using Elasticsearch Rest High Client problem in AEM

I am trying to use Java High Level Rest Client in Adobe Experience Manager to finish project of comparison between Lucene, Solr and Elasticsearch search engines.
I am having some problems with elasticsearh implementation.
Here is the code:
Dependency in the parent pom.xml (the same is defined in core pom.xml)
<!-- Elasticseach dependencies -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.4.0</version>
</dependency>
The only line of code that I am using that is from dependencies above
try (RestHighLevelClient client = new
RestHighLevelClient(RestClient.builder(new HttpHost(server, port,
protocol),
new HttpHost(server, secondPort, protocol)));)
{
}
catch (ElasticsearchException e)
{
LOG.error("Exception: " + e);
}
protocol = "http", server = "localhost", port = 9200, secondPort =
9201
Error
Dependencies from IntelliJ
I know that there is usually problem with dependencies versions, but all are 7.4.0 in this case. Also elasticsearch 7.4.0v is running locally on 3 nodes.
This project is done on We.Retail project so it is easy to replicate. Also all the code with this error is available here:
https://github.com/tadijam64/search-engines-comparison-on-we-retail/tree/elasticsearch-integration
AEM 6.4v.
Any info or idea is appreciated.
UPDATE
I tried with adding the following to embed these dependencies externally since they are not OSGi dependencies:
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>org.apache.servicemix.bundles.solr-solrj, log4j, noggit, zookeeper,
elasticsearch-rest-high-level-client
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Export-Package>we.retail.core.model*</Export-Package>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Private-Package>we.retail.core*</Private-Package>
<Sling-Model-Packages>
we.retail.core.model
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
The error remains. I also tried adding it to the "export-package", but nothing helps.
And by Elasticsearch documentation, all I need to use Elasticsearch is
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.4.0</version>
</dependency>
but then NoClassDefFoundErrors occurs. It seems like a problem with transitive dependencies maybe. Not sure, but any idea is appreciated.
Some other suggestions can be found here: https://forums.adobe.com/thread/2653586
I have also tried adding it's transitive dependencies like org.elasticsearch and org.elasticsearch.client, but it does not work. The same error, just other class.
AEM version 6.4, Java version: jdk1.8.0_191.jdk
So my guess was right, transitive dependencies were not included altho <Embed-Transitive>true</Embed-Transitive> exists.
The following is necessary when running elasticsearch as a search engine on AEM the problem:
I have added all transitive dependencies in pom.xml (versions are defined in parent/pom.xml):
<!-- Elasticsearch -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-x-content</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>rank-eval-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>lang-mustache-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
</dependency>
It is important to add all third-party dependencies as <Embed-Dependency> inside maven-bundle-plugin like this:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>org.apache.servicemix.bundles.solr-solrj, noggit,
elasticsearch-rest-high-level-client,
elasticsearch,
elasticsearch-rest-client,
elasticsearch-x-content,
elasticsearch-core,
rank-eval-client,
lang-mustache-client,
httpasyncclient;
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Export-Package>we.retail.core.model*</Export-Package>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Private-Package>
we.retail.core*
</Private-Package>
<Sling-Model-Packages>
we.retail.core.model
</Sling-Model-Packages>
<_fixupmessages>"Classes found in the wrong directory";is:=warning</_fixupmessages>
</instructions>
</configuration>
</plugin>
Important to notice:
All third-party dependencies (the ones outside of OSGi) must be included in the "Embed-Dependency"
"Embed-Transitive" must be set to true to include transitive dependencies
"Import-Package" must include "*;resolution:=optional" to exclude all dependencies that could not be resolved so that the program can run
normally
For some reason, there was an error in compile time when "elasticsearch" dependency was added which is not important for this
task, so I've decided to ignore it this way:
<_fixupmessages>"Classes found in the wrong directory";is:=warning</_fixupmessages>
Though challenging, I finally resolved it. There are many similar or the same problems on Google, so I hope this will help someone. Thanks to everyone that tried to help.

Maven Versions Plugin - Exclude Major Version With Suffix

I am implementing the Maven versions plugin to manage our dependencies, but am having trouble excluding the next Spring major release due to the ".RELEASE" suffix.
Here's a snippet of my pom.xml:
<properties>
<spring.version>4.2.0.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>[${spring.version},5.0.0.RELEASE)]</version>
<dependency>
</dependencies>
What I am trying to do is update to the latest 4.X.X (4.3.something) WITHOUT allowing the 5.0 series which could introduce breaking changes. Unfortunately, due to the suffix, it ignores the ")" which is supposed to ignore the 5.0.0 releases.
I do not currently have an externalized rules XML file (getting to it).
Can anyone assist?
Edit: I am using the following command to update:
mvn versions:use-latest-releases
Edit 2: Below is my configuration for the maven plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<allowIncrementalUpdates>true</allowIncrementalUpdates>
<allowMinorUpdates>true</allowMinorUpdates>
<allowMajorUpdates>false</allowMajorUpdates>
<allowSnapshots>false</allowSnapshots>
</configuration>
</plugin>

Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags when using lombok

I have following dependency in pom.xml:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.8</version>
</dependency>
When I run mvn clean install, I have following error:
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags
at java.lang.ClassLoader.findClass (ClassLoader.java:711)
at java.lang.ClassLoader.loadClass (ClassLoader.java:566)
at lombok.launch.ShadowClassLoader.loadClass (ShadowClassLoader.java:418)
I tried to use java 1.8, 1.9, 1.10. And I tried lombok 1.6.10, 1.6.12, 1.6.20. All of them have the same problem.
I am able to solve the problem in my maven project with any Java-8+ version and Lombok 1.18.2 version
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
<scope>provided</scope>
</dependency>
I had changed the lombok version and it worked for me.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.22</version>
<scope>provided</scope>
</dependency>
I have the same problem and I solve it by adding this code in pom.xml
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.0.0</version>
</dependency>
Solved the issue by upgrading lombok version from 1.16.18 to 1.16.22 . I suspect any compatible version higher than .22 might do the trick.
my project uses java1.8,and this problem have be solved by using lombok 1.18.4.
Solved this by:
1) download the lombok-edge.jar,
2) using following dependency:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.21</version>
<scope>system</scope>
<systemPath>/Users/xxx/Downloads/lombok-edge.jar</systemPath>
</dependency>
This happened with me when I installed maven with brew which also installed Java.15.x that leads to this error.
To validate, add debug option -X while building with maven and check the Java version that maven is using.
Delete the Java.15x directory and set JAVA_HOME in your .bashrc with the correct version of Java.
I always managed to resolve this issue with numerous old projects using older version of Lombok by simply upgrading the Lombok version
With this upgrade of Lombok; for projects with heavy memory during test running phases I have also had to start specifying memory configurations for maven-surefire-plugin which generally seems to now need more memory to avoid Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
errors
See below for example working pom.xml configs
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
</properties>
...
<lombok.version>1.18.2</lombok.version>
...
</properties>
<dependencies>
...
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
...
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--Extra memory to prevent jvm crash during heavy Integration/unit test with newer lombok and jdk8-->
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
...
</plugins>
</build>
</project>
I tried the following lombok dependency on java-1.8 and java-11, and it build successfully.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
I encountered this issue when upgrading my project from JDK 8 to JDK 12 and using gradle instead of maven and using the io.franzbecker:gradle-lombok gradle plugin to configure lombok automatically.
In this scenario changing buildScript.dependencies from classpath "io.franzbecker:gradle-lombok:1.14" to classpath "io.franzbecker:gradle-lombok:3.2.0" did the trick for me.
I had the same issue with Java 8 and had my lombok dependency with no version at all. ALl i did was downgrade the lombok version to an older one, enough to be compatible with my Spring Boot 1.4
Just check at: https://mvnrepository.com/artifact/org.projectlombok/lombok and choose newer version. For me using <version>1.18.24</version> fixed the problem

ClassNotFoundException on spring beans inside jboss fuse camel application

I'm trying to create a spring-based fuse integration making external soap calls.
Using the code in a standalone java apps works fine but when importing it in my Fuse Integration project, I have the following error:
...
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.InitializingBean not found by org.apache.servicemix.bundles.spring-ws-core [439]
I don't know where to start to debug this.
Here are relevant part of my pom:
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-ws</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${version.maven-bundle-plugin}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>myBundle</Bundle-SymbolicName>
<Bundle-Name>Empty Camel Spring Example [myBundle]</Bundle-Name>
<DynamicImport-Package>*</DynamicImport-Package>
<Import-Package>*,org.springframework.beans.factory</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
I also double-checked that spring components are loaded in fuse:
At this point, I just don't know what to do to get this working!
Many thanks for your help !
edit:
Checking by bundles imports shows:
Which tends to confirm that
org.springframework.beans.factory.InitializingBean
is loaded !
In fact it's the following bug here: https://issues.jboss.org/browse/ENTESB-6856 which is already fixed and will be made available through 6.3.0 R4 (which is due to be released these days).
Since you are using Fuse 6.3 187 I'd highly recommend to follow their patch cycle and apply the updates regularly (schedule can be seen here: https://access.redhat.com/articles/2939351).
If you are brave, you can also play around with the internal builds (http://repository.jboss.org/nexus/content/groups/ea/org/jboss/fuse/jboss-fuse-karaf/6.3.0.redhat-280/), however these versions won't be supported unless they are part of an official patch release.

Intellij + springboot + maven + spring-loaded

I have an issue where debugging stops working in Intellij, when applying Spring-loaded as a dependency to the maven plugin.
Situation 1 (working):
Using a autogenerated spring-boot maven (pom.xml) file with a declared "Spring-boot-maven-plugin" I can debug my my app using the debug-maven command in intellij. The pom file looks like this:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Situation 2 (not working):
Following the guide lines here: spring-boot-hot-swapping one should add a dependency for spring-loaded, to make use of spring-loaded. The pom file now looks like:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Debugging the same run-configuration as before does not work. The break-points simply never turns into a "checkmark" and the code never suspends. Code is now hotswapping as one would expect... If I remove the plugin-dependency again, debugging starts working again...
Please help me make situation two work!
IntelliJ 14.1.3 Ultimate, Java 7, Spring boot 1.2.4, Spring loaded 1.2.3
Since it seems there is no one with an answer to this (nor in IntelliJ forums) i've created an issue:
https://youtrack.jetbrains.com/issue/IDEA-142078
Did you try with spring-devtools (since 1.2.3) ? Use this dependency :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
There is already a ticket here, it seams the same issue.

Resources