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

1.0.1 Java API compilation error on source download #5464

Closed
nfx opened this issue Mar 19, 2014 · 17 comments
Closed

1.0.1 Java API compilation error on source download #5464

nfx opened this issue Mar 19, 2014 · 17 comments
Assignees

Comments

@nfx
Copy link

nfx commented Mar 19, 2014

After downloading sources i started to get compilation errors like

java: for-each not applicable to expression type
  required: array or java.lang.Iterable
  found:    org.elasticsearch.common.collect.UnmodifiableIterator<org.elasticsearch.cluster.metadata.IndexMetaData>

With 0.90x versions this was not a problem. What is temporary solution and what is proper solution?

@hhoffstaette
Copy link

It would be helpful to see the context (aka source file + line) where you get this error.

@spinscale
Copy link
Contributor

do you run into this problem with windows with java 7? can you try to start elasticsearch like this:

bin/elasticsearch.bat -XX:-UseSplitVerifier

does this change anything?

@nfx
Copy link
Author

nfx commented Apr 9, 2014

this issue does not affect ES itself, it affects working with it's Java API, when looking at the sources

@clintongormley
Copy link

hi @nfx

Did you manage to resolve this issue?

@nfx
Copy link
Author

nfx commented Aug 25, 2014

@clintongormley hi, i managed to do it only as a hack - i had to manually run perl command replacing com.google.guava.collect with org.elasticsearch.collect or smth like it. i didn't need to do it with v0.90 though. could you maybe try to update source artifact compilation to be fixed after mvn-shade plugin gets guava and jodatime inside of elasticsearch artifact?

@clintongormley
Copy link

Could this be related to #3557?

@spinscale
Copy link
Contributor

@clintongormley doesnt look like it

@clintongormley
Copy link

@nfx I don't follow the problem or the solution that you employed exactly. Could you show us some example code demonstrating the issue?

@nfx
Copy link
Author

nfx commented Aug 27, 2014

@clintongormley it could be related to #3557, also i might add "Avoid shading Google Guava". Would it make sense to create custom Maven build without Guava/Joda for applications that use Java API?

@clintongormley
Copy link

@nfx We've talked about this and we don't understand exactly what you are doing here. Could you talk us through how you are setting things up?

@nfx
Copy link
Author

nfx commented Oct 21, 2014

Let's say:
i go and download http://search.maven.org/remotecontent?filepath=org/elasticsearch/elasticsearch/1.4.0.Beta1/elasticsearch-1.4.0.Beta1-sources.jar (usually done from IDE), after that i try to look at the sources - and IDE gives me compilation errors, because maven shade plugin (?) is not replacing com.google.collect with org.elasticsearch.common and IDE cannot find classes from Guava. Proof:
$ grep "import com.google.collect" org/elasticsearch/common/collect/ImmutableOpenMap.java
import com.google.common.collect.UnmodifiableIterator;

so what i do after downloading ES sources: go to ~/.m2/repository/org/elasticsearch/elasticsearch/1.1.0/, manually unpack *-sources.jar and replace imports that are causing errors with org.elasticsearch.common. but that's a hack, i guess....

@clintongormley
Copy link

This is very odd - Eclipse and IntelliJ show you the sources without trying to compile them. Which IDE are you using?

@nfx
Copy link
Author

nfx commented Oct 27, 2014

IntelliJ 13...

@dadoonet
Copy link
Member

@nfx I guess you are trying to compile your own plugin or your own application, right?
Are you using maven? Could you paste here your pom.xml?

Could you also paste your .iml file?

@nfx
Copy link
Author

nfx commented Nov 3, 2014

@dadoonet i guess my IDE tried to compile dependencies. The funny thing is that this didn't appear in 0.90.x

$ grep -r '<orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch' *
a.iml:    <orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch:1.1.0" level="project" />
b.iml:    <orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch-hadoop:1.3.0.M2" level="project" />
c.iml:    <orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch-hadoop:1.3.0.M2" level="project" />
d.iml:    <orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch:1.1.0" level="project" />
e.iml:    <orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch:1.1.0" level="project" />
f.iml:    <orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch:1.1.0" level="project" />

@dadoonet
Copy link
Member

@nfx Sorry to answer lately. So you are using IntelliJ 13 (may be 14 now)?
I think you are trying to attach elasticsearch source code to your own project instead of using only the JAR files.
I mean that in IntelliJ, when using Maven, you just need when importing to check "download source" button and you're done.

For example, here is what I can see when I import elasticsearch as a Maven dependency in analysis-phonetic plugin project.

<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    <facet type="Python" name="Python">
      <configuration sdkName="Python 3.3.3 (/usr/local/bin/python3.3)" />
    </facet>
  </component>
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
    <output url="file://$MODULE_DIR$/target/classes" />
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
      <excludeFolder url="file://$MODULE_DIR$/target" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Python 3.3.3 (/usr/local/bin/python3.3) interpreter library" level="application" />
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-all:1.3" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.apache.lucene:lucene-test-framework:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.apache.lucene:lucene-codecs:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-core:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: com.carrotsearch.randomizedtesting:junit4-ant:2.1.6" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.apache.ant:ant:1.8.2" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.1.10" level="project" />
    <orderEntry type="library" name="Maven: org.elasticsearch:elasticsearch:2.0.0-SNAPSHOT" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-backward-codecs:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-analyzers-common:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queries:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-memory:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-highlighter:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queryparser:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-sandbox:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-suggest:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-misc:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-join:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-grouping:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-spatial:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-expressions:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
    <orderEntry type="library" name="Maven: org.ow2.asm:asm:4.1" level="project" />
    <orderEntry type="library" name="Maven: org.ow2.asm:asm-commons:4.1" level="project" />
    <orderEntry type="library" name="Maven: com.spatial4j:spatial4j:0.4.1" level="project" />
    <orderEntry type="library" name="Maven: com.vividsolutions:jts:1.13" level="project" />
    <orderEntry type="library" name="Maven: org.codehaus.groovy:groovy-all:indy:2.3.2" level="project" />
    <orderEntry type="library" name="Maven: log4j:apache-log4j-extras:1.2.17" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
    <orderEntry type="library" name="Maven: org.fusesource:sigar:1.6.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-analyzers-phonetic:5.0.0-snapshot-1641343" level="project" />
    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
    <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.elasticsearch:elasticsearch:test-jar:tests:2.0.0-SNAPSHOT" level="project" />
  </component>
</module>

You might have different settings?

May be you could paste your full .iml file?

@dadoonet
Copy link
Member

dadoonet commented Dec 3, 2014

@nfx I'm closing this for now. If you have any new information on this, feel free to reopen it.

Thanks.

@dadoonet dadoonet closed this as completed Dec 3, 2014
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

5 participants