spring-projects / spring-projects/spring-data-rest
Could not resolve repository metadata error - 500 for profile endpoints
@odrotbohm is already working on this.
Since Jun 8, 2021.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
This issue is similar to https://github.com/spring-projects/spring-data-rest/issues/1729 .
Our app works as expected most of the time but occasionally we get a 404 error for some of our API endpoints.
When we check the /profile endpoint for that repository, it returns 500 with "Could not resolve repository metadata"
It works after a restart but then fails again after a while.
We use Spring-boot-starter-data-rest : 2.2.6.RELEASE
Example UseCase :
3 Entities :
- Customer
- AppTwitter
- CustomerTwitter
A Customer can have multiple twitter Accounts (CustomerTwitter). One Twitter App( AppTwitter) can be used to handle multiple Customers

All of these entities have been exposed as repositories
Entites:
Customer.java
@Entity
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column( unique = true)
@NotBlank
private String name;
@ManyToOne
@JoinColumn(foreignKey=@ForeignKey(name = "FK_CustomerToAppTwitter"),name="appTwitter_id",referencedColumnName = "twitterAppId")
private AppTwitter appTwitter;
@OneToMany(cascade = CascadeType.ALL,mappedBy = "customer")
private List<CustomerTwitter> customerTwitter;
// Getters and Setters here
}
AppTwitter.java
@Entity
public class AppTwitter implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer twitterAppId;
// Other fields specific to App
@OneToMany(mappedBy = "appTwitter")
private List<Customer> customer;
//Getter and Setter
}
CustomerTwitter.java
@Entity
public class CustomerTwitter implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String twitterId
// Other fields related to twitter account
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(foreignKey=@ForeignKey(name = "FK_CustomerTwitterToCustomer"), name="cust_id",referencedColumnName = "id")
private Customer customer;
// Getters and Setters
}
Repositories
CustomerRepository.java
@RepositoryRestResource
public interface CustomerRepository extends JpaRepository<Customer, Integer>{
}
AppTwitterRepository.java
@RepositoryRestResource
public interface AppTwitterRepository extends JpaRepository<AppTwitter, Integer>{
}
CustomerTwitterRepository.java
@RepositoryRestResource
public interface CustomerTwitterRepository extends JpaRepository<CustomerTwitter, String>{
}
Sometimes making a GET call to any one of these endpoints returns 404 error and the /profile endpoint gives 500 error with Could not resolve repository metadata
Weird thing is this happens once every 6-7 hours and almost never happens in my local environment to even figure out and debug the issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.