Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running ElasticSearch code base as a Java application in your IDE #100

Closed
vynguyenchantal opened this issue Sep 2, 2016 · 15 comments
Closed

Comments

@vynguyenchantal
Copy link

Hi,
I follow this https://github.com/sscarduzio/elasticsearch-readonlyrest-plugin/wiki/Development

I can't find this class:
Main class org.elasticsearch.bootstrap.Elasticsearch

Thank you.
v/r
Chantal

@sscarduzio
Copy link
Owner

Just paste that string in the run configuration, that class is contained in an external dependency jar (Elasticsearch).

@vynguyenchantal
Copy link
Author

Hi,
FYI, I still use an eclipse project so that I can pull in libraries as needed quickly. Until I get everything working, I will create a Maven project loading all the dependencies into Nexus.

I did what you suggested above and now I got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
Likely root cause: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:226)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

I will have to pull in all the jars required by ES. I will let you know if I have more problem.

Thank you for being so responsive!!!
v/r
Chantal

@vynguyenchantal
Copy link
Author

Hi,
I checked the elasticsearch pom.xml and found:

commons-cli
commons-cli

I added commons-cli-1.2.jar and then commons-cli-2.0.jar as referenced libraries and I still get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/Option$Builder
Likely root cause: java.lang.ClassNotFoundException: org.apache.commons.cli.Option$Builder
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.elasticsearch.bootstrap.BootstrapCLIParser$Start.(BootstrapCLIParser.java:93)
at org.elasticsearch.bootstrap.BootstrapCLIParser.(BootstrapCLIParser.java:44)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:226)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

I will keep looking into it but if you have any ideas as to why, please help.

Thank you.
v/r
Chantal

@sscarduzio
Copy link
Owner

Once again can you make sure you covered the troubleshooting section of the development page in the wiki?

@vynguyenchantal
Copy link
Author

Hi,
I followed this link from the troubleshooting section elastic/elasticsearch#14348 and the issue is not relevant to mine. I'm using Eclipse (Luna and Mar versions) running on Windows Server 2012 R2 and not OS X. My IDE is configured using jdk1.8.0_60 and the error I got is NOT "java.lang.RuntimeException: found jar hell in test classpath"

The thread showing people using commons-cli-1.2.jar. I use the same jar version. I also use Elasticsearch ReadonlyRest 2.3.5 source code. This is my error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/Option$Builder
Likely root cause: java.lang.ClassNotFoundException: org.apache.commons.cli.Option$Builder
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.elasticsearch.bootstrap.BootstrapCLIParser$Start.(BootstrapCLIParser.java:93)
at org.elasticsearch.bootstrap.BootstrapCLIParser.(BootstrapCLIParser.java:44)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:226)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

I have elasticsearch 2.3 source and I checked BootstrapCLIParser.java line 93:
private static final CliToolConfig.Cmd CMD = cmd(NAME, Start.class)
.options(
optionBuilder("d", "daemonize").hasArg(false).required(false),
optionBuilder("p", "pidfile").hasArg(true).required(false),
optionBuilder("V", "version").hasArg(false).required(false),
Option.builder("D").argName("property=value").valueSeparator('=').numberOfArgs(2)
)

commons-cli has Option.class but it does not have builder() method. Therefore it blows up on Option.builder("D")...

@sscarduzio
Copy link
Owner

Does maven build all right from the command line? mvn package ?

@vynguyenchantal
Copy link
Author

Hi,
As I mentioned above I don't use maven yet because our Nexus lib repository is controlled and I can't just load any libraries in. Therefore, I do this exercise using eclipse project (and not maven project). The "Build Project" shows 0 error and 29 warnings.

This is a run-time error because BootstrapCLIParser.java is within elasticsearch-2.3.5.jar. It does not get compiled as part of the ReadonlyRest.

Two things that could fix this issue:

  1. BootstrapCLIParser.java (within elasticsearch.jar) not calling Option.builder()
    or
  2. commons-cli with updated Option to expose builder() method

I still don't know why I encounter this situation when the others don't seem to be.

Thank you.
v/r
Chantal

@ivssh
Copy link

ivssh commented May 23, 2018

I am facing the exact same issue. Is there any solution for the same?

@sscarduzio
Copy link
Owner

@abhilash1994 what ES version? And what error?

@ivssh
Copy link

ivssh commented May 24, 2018

I configured IntelliJ IDE as per the wiki. I also added the elasticsearch.jar from /usr/share/elasticsearch/lib. Then I get exception as below when I run the "Whole ES".
Unaware of elasticsearch version, I have 2.4.5 installed on my laptop as a service.
Does the Whole ES interact with the elasticsearch service running on 9200 port?

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser Likely root cause: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:242) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:45) Refer to the log for complete error details.

@sscarduzio
Copy link
Owner

@abhilash1994 you should switch off the local ES installation, as the one in the IDE will try to bind to the same port.

Having said that, your issue is another because it can't load the ES dependencies.

for reference, here is my java options in the launcher I have:

-Djava.security.policy=/me/ror/integration-tests/src/test/eshome/plugins/readonlyrest/plugin-security.policy
-Djava.awt.headless=true
-Des.insecure.allow.root=true
-Dfile.encoding=UTF-8
-Djna.nosys=true
-Des.path.home=/me/ror/integration-tests/src/test/eshome
-Dlog4j2.disable.jmx=true
-Xms2g
-Xmx2g
-Dlog4j2.disable.jmx=true

"use classpath module: es23x_main"
use JDK8

screen shot 2018-05-24 at 11 24 37

@ivssh
Copy link

ivssh commented May 25, 2018

@sscarduzio Thanks a lot for the help. I have followed everything as mentioned and I was able to solve majority of the dependencies. Although now I get this error.

log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.IllegalArgumentException: Plugin [readonlyrest] must be at least a jvm or site plugin
	at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:107)
	at org.elasticsearch.plugins.PluginsService.getPluginBundles(PluginsService.java:378)
	at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:128)
	at org.elasticsearch.node.Node.<init>(Node.java:158)
	at org.elasticsearch.node.Node.<init>(Node.java:140)
	at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:143)
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:45)
Refer to the log for complete error details.

This is how my configuration looks.

bug_read_only

@sscarduzio
Copy link
Owner

you need to edit plugin-descriptor.properties. Add:

site=false
jvm=true
isolated=false

@ivssh
Copy link

ivssh commented May 25, 2018

I have added those in plugin-descriptor.properties in the es23x folder as per the screenshot attached. The issue still persits.

plugin_properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants