Micronaut data : No backing RepositoryOperations configured for repository
Asked Answered
C

4

10

I am getting this following exception when I try configuring micronaut-data with inmemory h2 database and Jpa.
I have been following the documentation

I created the project from command line with maven as build tool. I have the following

<dependency>
     <groupId>io.micronaut.configuration</groupId>
      <artifactId>micronaut-jdbc-tomcat</artifactId>
      <scope>runtime</scope>
    </dependency>
<dependency>
     <groupId>com.h2database</groupId>
     <artifactId>h2</artifactId>
     <scope>runtime</scope>
</dependency>
<dependency>
     <groupId>io.micronaut.data</groupId>
     <artifactId>micronaut-data-hibernate-jpa</artifactId>
     <version>1.0.0.M3</version>
</dependency>

And Also I have added annotation processor like this

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
   ......
  <configuration>
    ...
    <annotationProcessorPaths>
      <path>
        <groupId>io.micronaut</groupId>
        <artifactId>micronaut-inject-java</artifactId>
        <version>${micronaut.version}</version>
      </path>
      <path>
        <groupId>io.micronaut</groupId>
        <artifactId>micronaut-validation</artifactId>
        <version>${micronaut.version}</version>
      </path>
      <path>
        <groupId>io.micronaut.data</groupId>
        <artifactId>micronaut-data-processor</artifactId>   
        <version>1.0.0.M3</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
  .....
</plugin>

My Entity class and Repository class are exactly as mentioned in the guide. When I try to save using the repository, I get this exception

18:16:37.787 [pool-1-thread-3] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: No backing RepositoryOperations configured for repository. Check your configuration and try again
io.micronaut.context.exceptions.ConfigurationException: No backing RepositoryOperations configured for repository. Check your configuration and try again
..............................
Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.data.operations.RepositoryOperations] exists. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).

I have already looked into this. This is completely different and it doesn't help my issue.

Interestingly if I change the order of micronaut data annotation processsor I mean If I put like this

<plugin>                                                    
  <groupId>org.apache.maven.plugins</groupId>               
  <artifactId>maven-compiler-plugin</artifactId>            
   ......                                                   
  <configuration>                                           
    ...                                                     
    <annotationProcessorPaths>                              
      <path>                                                
        <groupId>io.micronaut</groupId>                     
        <artifactId>micronaut-inject-java</artifactId>      
        <version>${micronaut.version}</version>             
      </path>                                               
      <path>                                                
        <groupId>io.micronaut</groupId>                     
        <artifactId>micronaut-validation</artifactId>       
        <version>${micronaut.version}</version>             
      </path>                                               
      <path>                                                
        <groupId>io.micronaut.data</groupId>                
        <artifactId>micronaut-data-processor</artifactId>   
        <version>1.0.0.M3</version>                         
      </path>                                               
    </annotationProcessorPaths>                             
  </configuration>                                          
  .....                                                     
</plugin>  

I get a different exception.

Internal Server Error: All possible Introduction advise exhausted and no implementation found for method: Iterable saveAll(Iterable entities) 

Any pointers are much appreciated.

Clownery answered 9/10, 2019 at 16:26 Comment(0)
C
3

The documentation was incomplete. Did a pull request (https://github.com/micronaut-projects/micronaut-data/pull/197) with the documentation update. It has been accepted. The updated documentation can be found here

Need another dependency for this to work

<dependency>
    <groupId>io.micronaut.data</groupId>
    <artifactId>micronaut-data-hibernate-jpa</artifactId>
</dependency>
Clownery answered 30/3, 2020 at 10:20 Comment(0)
W
7

I was getting this error and the solution for my case was to add the following to the application.yml:

jpa:
  default:
    properties:
      hibernate:
        bytecode:
          provider: none

This is based on the example project here: https://github.com/micronaut-projects/micronaut-data/blob/v1.0.0.M3/examples/example-jpa/src/main/resources/application.yml#L15

Watertight answered 21/10, 2019 at 23:53 Comment(1)
Thanks for the answer. I realised the same looking at the example. So I changed the documentation and raised a pull request github.com/micronaut-projects/micronaut-data/pull/197 ... Waiting for approval. I will update the answer here once that is doneClownery
C
3

The documentation was incomplete. Did a pull request (https://github.com/micronaut-projects/micronaut-data/pull/197) with the documentation update. It has been accepted. The updated documentation can be found here

Need another dependency for this to work

<dependency>
    <groupId>io.micronaut.data</groupId>
    <artifactId>micronaut-data-hibernate-jpa</artifactId>
</dependency>
Clownery answered 30/3, 2020 at 10:20 Comment(0)
P
1

Add the model entity package path to the application.yml:

jpa:
  default:
    packages-to-scan:
      - 'com.entity' 

kindly add the component scan path in yml file because app entity not able to find

Progenitor answered 16/2, 2021 at 9:26 Comment(0)
P
0

What worked for me is excluding jaxb from micronaut:

<dependency>
    <groupId>io.micronaut</groupId>
    <artifactId>micronaut-http-server-netty</artifactId>
    <scope>compile</scope>
    <exclusions>
        <exclusion>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Pindus answered 29/8 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.