debugging elasticsearch github project on intellij - elasticsearch

I have cloned the elasticsearch github repo on my linux machine and i have java 8. I go to the directory elasticsearch and run the command "gradle build" . But it throws me error saying there is an error in :
Build file '/home/tracxn-lp-354/Documents/sanchit/elasticsearch/benchmarks/build.gradle' line: 31
What went wrong:
A problem occurred evaluating project ':benchmarks'.
Failed to apply plugin [id 'elasticsearch.build']
Java 1.9 or above is required to build Elasticsearch

As the error says, you need to install a newer version of java.
What version of java does it say it's running?
java -version
If it doesn't say 1.9 then you need an upgrade!
sudo apt-get purge openjdk*
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer
java -version
sudo apt-get install oracle-java9-set-default
--
Once all this is done:
Make sure to open Project Structure in IntelliJ and navigate to:
Project->Project SDK.
Specify the latest version of the Java JDK (9) and click Apply.

First of all, make sure you installed Java 9 (JDK 9 is required to build Elasticsearch).
Now, run the following command from Elasticsearch root directory (it automatically configures IDE):
gradle idea
After that, open Elasticsearch project from IntelliJ IDEA with enabled Gradle auto-import. This step is important, because it setups correct project structure for IDEA (content root, source folders, etc):
File -> New -> Project from Existing Sources... -> Import Gradle Project
And make sure that Project SDK is set to the Java version 9.
Now, to debug Elasticsearch, go to the Run -> Edit Configurations menu and add the following configurations:
Add breakpoint somewhere, for example in:
server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java
And run Debug 'Elasticsearch' (Shift + F9 in IntelliJ IDEA).
P.S. The process might be time consuming, so be patient and enjoy the result!

Related

Gradle init isn't interactive

I am using gradle through command line for the first time. I am running the latest version of Ubuntu. My professor's instructions indicate that upon typing "gradle init" I should be prompted to say what type of project it is as well as the language, etc. Mine simply skips all of that and says "build successful" afterwards, my professors' file ends up with the proper directory structure and mine only has the basic root folders. From the quick searches I've done, I see that there is a difference between interactive and non-interactive responses, but I can't find anything regarding how to make it interactive.
My issue was I installed gradle with sudo apt install gradle which installs a very old version. Instead you can install sdk and then run sdk install gradle
If it says something along the lines of:
> Task :init SKIPPED
The build file 'build.gradle' already exists. Skipping build initialization.
BUILD SUCCESSFUL in 5s
Then it means you already have a Gradle build structure present. In order to initialize a new one, the directory you run it in must be empty.
I had this problem, too. Seems to be a bug.
You can tell gradle non-interactively what type to create, for example:
gradle init --type java-library
Other build types

How do I turn Keycloak old version 4.1.0 into 'Standalone server distribution'?

I tried something (readme.md, blog etc).But I don't turn 'standalone server distribution'.
I can give an example. What I want to say:
The following is a 'standalone server distribution' files. This is ready for running.
Picture-1
I need to run old version keycloak (version 4.1.0). This package seem like this :
Picture-2
According to Picture-2, this packages don't ready for running.
How can I ready for running ? Like to Picture-1.
I need your suggestions and suggestions. Can you help me?
Greetings,
That's the source code.
You have to build it by executing the following command from parent directory (you need Java JDK and Maven installed and configured):
mvn -Pdistribution -pl distribution/server-dist -am -Dmaven.test.skip clean install
Resulting release distribution will be in ./distribution/server-dist/target/keycloak-4.1.0.Final.zip archive.
Compiling the sources is described here: https://github.com/keycloak/keycloak/blob/master/docs/building.md
You can download the latest release version 4.X from archive: https://www.keycloak.org/archive/downloads-4.8.3.html

Elasticsearch use icu_tokenizer from ICU Analysis plugin

I am trying to install ICU Analysis plugin manually in Elasticsearch 1.4.0. I have downloaded elasticsearch-analysis-icu-2.4.1.jar, lucene-analyzers-icu-4.10.2.jar and icu4j-54.1.1.jar. The plugin appears normally in the console, but when I try to use icu_tokenizer, I get the following error:
NoClassDefFoundError[Could not initialize class org.apache.lucene.analysis.icu.segmentation.DefaultICUTokenizerConfig]
This class actually exists in lucene-analyzers-icu. Is there something I am missing?
Did you try using the plugin installer instead of downloading the jar files manually as suggested in the documentation?
./bin/plugin -install elasticsearch/elasticsearch-analysis-icu/2.6.0
Run the command and restart the server. The plugin will be registered and functional.
Document
sudo bin/elasticsearch-plugin install analysis-icu

Gradle not working after fresh new install on debian linux

I just installed gradle on debian using the sudo apt-get install gradle command. When i try to run gralde afterwards it throws the following stack trace :
org.gradle.api.internal.classpath.UnknownModuleException: Cannot
locate JAR for module 'ant' in distribution directory 'null'.
at org.gradle.api.internal.classpath.DefaultModuleRegistry.findExternalJar(DefaultModuleRegistry.java:242)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getExternalModule(DefaultModuleRegistry.java:101)
at org.gradle.api.internal.DefaultClassPathProvider.findClassPath(DefaultClassPathProvider.java:46)
at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(DefaultClassPathRegistry.java:34)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:43)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Gradle by default gets installed into
/usr/share/gradle
I have all the jars gradle requires in my jdk, so is there any way to tell gradle to search for the libraries there and start to work ?
Try to set your GRADLE_HOME
export GRADLE_HOME=/usr/share/gradle
Is there a lib under that directory? It should have the ant jar.

how to install a plugin in elasticsearch

i have downloaded the zip package for hello world plugin from https://github.com/brusic/elasticsearch-hello-world-plugin/blob/master/src/main/java/org/elasticsearch/plugin/helloworld/HelloWorldPlugin.java
and have installed maven also but i want to know where to unzip this package and which command will be used to install and run it.I am working on windows so please provide a stepwise procedure according to it.please help
Check the project from github, build it, place the jar from the directory
elasticsearch-hello-world-plugin/target
Into the lib folder in Elastcsearch
elasticsearch/lib
Restart Elasticsearch

Resources