azure-sdk-for-java: Getting "resource" is null with Spring Data REST and azure-spring-data-cosmos

Hi

I am trying to use azure-spring-data-cosmos with Spring Boot Starter Data REST, but encountering the following error on Spring Boot app’s startup: Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.data.rest.core.mapping.ResourceMetadata.isExported()" because "resource" is null

Dependencies in pom.xml:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
            <version>2.7.7</version>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-spring-data-cosmos</artifactId>
            <version>3.31.0</version>
        </dependency>

Environment JDK 17 - java version “17.0.5” 2022-10-18 LTS Java™ SE Runtime Environment (build 17.0.5+9-LTS-191) Java HotSpot™ 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing) Windows 10 x64

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

@backwind1233 Thanks for reproducing the error. As per your suggestion, I have removed SpringFox from the deps but the issue is still coming:

2023-01-20 13:05:36.883 DEBUG 7804 --- [nio-8080-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Writing [org.springframework.data.rest.webmvc.support.ExceptionMessage@cd0ae5b]
2023-01-20 13:05:36.884 DEBUG 7804 --- [nio-8080-exec-3] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [java.lang.NullPointerException: Cannot invoke "org.springframework.data.rest.core.mapping.ResourceMetadata.isExported()" because "metadata" is null]
2023-01-20 13:05:36.884 DEBUG 7804 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Completed 500 INTERNAL_SERVER_ERROR

The web app starts and on hitting the API (GET) it gives 500 status code image

Attaching new project without SpringFox - SpringDataRESTNoSpringFox.zip

@backwind1233 could you please follow up?