opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.79k stars 1.82k forks source link

[BUG] Cannot resolve symbol 'RestStatus' #13886

Closed leo-lucky-hub closed 5 months ago

leo-lucky-hub commented 5 months ago

Describe the bug

org.opensearch.client spring-data-opensearch 1.4.0

image image

Related component

Clients

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

no error

Additional Details

Plugins Please list all plugins currently enabled.

Screenshots If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

Additional context Add any other context about the problem here.

dblock commented 5 months ago

It's likely something to do with the setup of your dependencies, RestStatus is here.

I'll close this, but feel free to comment with repro steps, and/or post your code to a GitHub repo that shows the failure if you're stuck. The public Slack clients channel is also a good place to ask this.

leo-lucky-hub commented 5 months ago

@dblock Thank you for your answer What I want to ask is, why RestStatus is a class, not java. In this jar, other classes are java, not class

image image

pom.xml `<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.3.0</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
    <java.version>17</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.opensearch.client</groupId>
        <artifactId>spring-data-opensearch-starter</artifactId>
        <version>1.4.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>

`

leo-lucky-hub commented 5 months ago

@dblock 2.11.1 RestStatus is java image

dblock commented 5 months ago

@reta do you know what changed?

reta commented 5 months ago

@reta do you know what changed?

Oh, it was moved to different package @dblock :(

dblock commented 5 months ago

@reta do you know what changed?

Oh, it was moved to different package @dblock :(

I am confused. Where? When?

https://github.com/opensearch-project/OpenSearch/blob/2.11/libs/core/src/main/java/org/opensearch/core/rest/RestStatus.java

https://github.com/opensearch-project/OpenSearch/blob/2.14/libs/core/src/main/java/org/opensearch/core/rest/RestStatus.java

reta commented 5 months ago

Oh sorry @dblock , it was moved in 2.10.0, I haven't checked the full issue details. Seems like IDE issue.

dblock commented 5 months ago

https://github.com/opensearch-project/OpenSearch/blob/2.9/libs/core/src/main/java/org/opensearch/rest/RestStatus.java

dblock commented 5 months ago

@luckyyaxianzhi The java/class thing is a red herring, RestStatus is an enum, so it shows up correctly.

leo-lucky-hub commented 5 months ago

@dblock Thank you for your answer So what should I do so that I don’t get an error? The same IDE, there is no error when using 2.11.1

dblock commented 5 months ago

What do you see in your IDE with 2.11.1 vs. 2.14 for RestStatus?

leo-lucky-hub commented 5 months ago

2.11.1 image 2.14 image

dblock commented 5 months ago

They look identical, what am I missing @luckyyaxianzhi ?

leo-lucky-hub commented 5 months ago

@dblock Why is 2.14 a RestStatus.class file, and 2.11.1 is a RestStatus file without the .class suffix? What I hope is that 2.14 is also a RestStatus file without the .class suffix.

dblock commented 5 months ago

Why is 2.14 a RestStatus.class file, and 2.11.1 is a RestStatus file without the .class suffix?

I don't know. Note though that your screenshot is cut off and I can't see this.

Going back to the problem, you're saying that your project's build works with 2.11 but not 2.14. Put a complete project up on GitHub that reproduces the problem (a branch that uses 2.11 where I can type ./gradlew build and it works, and a branch that uses 2.14 where I can type ./gradlew build and it doesn't work), and I can try to take a look.

leo-lucky-hub commented 5 months ago

@dblock Why is 2.14 a RestStatus.class file, and ReportingService is a .java file image image

dblock commented 5 months ago

@dblock Why is 2.14 a RestStatus.class file, and ReportingService is a .java file

I don't know how the IDE resolves references, but this doesn't seem to be the real problem. Happy to help resolve the actual problem of building the project if you can put up a repro.

mcc0393 commented 3 months ago

I'm experiencing the same issue with RestStatus not being resolved in my project, even though I can see it in the library. I'm using IntelliJ IDEA, and I’ve tried various solutions, including clearing Gradle's cache, re-downloading dependencies multiple times, and cleaning the IDE's cache.

When I use OpenSearch 2.11.1, the problem is resolved, but it persists with versions 2.15 and 2.13. I'm not sure if this is related to how IntelliJ resolves references or if it’s something else in my project setup. Any further guidance or steps to reproduce would be greatly appreciated.

Thanks!

asbajwa5190 commented 1 month ago

Hi, I am also facing similar issue as mentioned by others. RestStatus is not getting resolved when using opensearch-rest-high-level-client dependecy for version 2.12.0 and above. It works fine for version 2.11.0. I am using IntelliJ.

Could someone please suggest, how to resolve this issue?

Thanks!

mcc0393 commented 1 month ago

Hi, my conclusion was that the problem was associated with IntelIj. I recommend using another IDE or trying again with the latest versions of IntelIj.