Compile error when using elastic search 2.0


(yifan) #1

Hi, all, I'm evaluating new elastic search 2.0 recently, try to upgrade from 1.4.2 to 2.0, but found some problem compiling my application.

I used the following setting in my pom,

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>2.0.0</version>
    </dependency>

but got errors when building my application. It complains can't find org.apache.lucene.util.BytesRef and org.joda.time.ReadableInstant class. I checked elasticsearch-2.0.0.jar, found they really doesn't exist there. And this is my lib list. Does anyone know what is the problem? How can I fix this? Thank you in advance.


(David Pilato) #2

Lot of dependencies are missing here.
You should may be reimport your maven project?


(yifan) #3

I tried reimport, but it didn't help
is it enough only include elastic search in pom?

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>2.0.0</version>
</dependency>

(David Pilato) #4

It's enough but apparently transitive deps are not here.

   mvn dependency:tree 

should give an idea


(yifan) #5

Thank David for your suggestion.
I ran the command, what confused me is when I use elastic search 1.4.2, it has a complete transitive deps, like this

but when I use 2.0.0, it has deps missing, like this

is it caused by my maven? I'm using maven 3.3.3


(David Pilato) #6

Can you share your pom.xml?


(yifan) #7

I removed some internal information.

<?xml version="1.0" encoding="UTF-8"?><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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.mogujie.trace</groupId>
<artifactId>lurker-logCenter</artifactId>
<version>1.0.2-SNAPSHOT</version>

<properties>
    <local.repo.host></local.repo.host>
</properties>

<dependencies>
    <dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>1.7.1</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.6</version>
    </dependency>
    <dependency>
        <groupId>com.mogujie.jafka</groupId>
        <artifactId>jafka-client</artifactId>
        <version>0.0.9.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.6</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Class-Path>../etc/</Class-Path>
                    </manifestEntries>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>com.mogujie.trace.logcenter.LurkerLogCenter</mainClass>
                    </manifest>
                </archive>
                <excludes>
                    <exclude>*.properties</exclude>
                    <exclude>logback.xml</exclude>
                    <exclude>logcenter.xml</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.9.1</version>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions> 
                <execution>
                    <id>make-zip</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptors> 
                            <descriptor>src/main/assembly/zip.xml</descriptor>
                        </descriptors>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

(David Pilato) #8

I tried your pom.xml but excluded jafka-client as I don't know it and I got this:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ lurker-logCenter ---
[INFO] org.mogujie.trace:lurker-logCenter:jar:1.0.2-SNAPSHOT
[INFO] +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.7.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.1:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.0.6:compile
[INFO] |  \- ch.qos.logback:logback-core:jar:1.0.6:compile
[INFO] +- org.elasticsearch:elasticsearch:jar:2.0.0:compile
[INFO] |  +- org.apache.lucene:lucene-core:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-backward-codecs:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-analyzers-common:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-queries:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-memory:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-highlighter:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-queryparser:jar:5.2.1:compile
[INFO] |  |  \- org.apache.lucene:lucene-sandbox:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-suggest:jar:5.2.1:compile
[INFO] |  |  \- org.apache.lucene:lucene-misc:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-join:jar:5.2.1:compile
[INFO] |  |  \- org.apache.lucene:lucene-grouping:jar:5.2.1:compile
[INFO] |  +- org.apache.lucene:lucene-spatial:jar:5.2.1:compile
[INFO] |  |  \- com.spatial4j:spatial4j:jar:0.4.1:compile
[INFO] |  +- com.google.guava:guava:jar:18.0:compile
[INFO] |  +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] |  +- joda-time:joda-time:jar:2.8.2:compile
[INFO] |  +- org.joda:joda-convert:jar:1.2:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.5.3:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.5.3:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.5.3:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.12:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.5.3:compile
[INFO] |  +- io.netty:netty:jar:3.10.5.Final:compile
[INFO] |  +- com.ning:compress-lzf:jar:1.0.2:compile
[INFO] |  +- com.tdunning:t-digest:jar:3.0:compile
[INFO] |  +- org.hdrhistogram:HdrHistogram:jar:2.1.6:compile
[INFO] |  +- commons-cli:commons-cli:jar:1.3.1:compile
[INFO] |  \- com.twitter:jsr166e:jar:1.1.0:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.2:compile
[INFO] \- com.alibaba:fastjson:jar:1.2.6:compile

So may be you have a problem there?


(yifan) #9

well, I removed jafka-client and still has those deps missing, what a bad luck...
There must be something wrong, it's so weird... I need time to figure it out

Anyway, thank you all the same, David .


(system) #10