Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring data jpa: findBy property hangs on "Starting beans in phase 2147483647" in Junit test

I'm having a problem in my junit test while accessing my spring data jpa repository. I'm using the findByProperty functionality. But it hangs while accessing it.

My Entity:

@Entity
@Table(name = "TC_ORDER")
public class Order extends AbstractCatalog{

        @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ORDER_SID")
    private Long id;

}

My Abstractcatalog:

@MappedSuperclass
public abstract class AbstractCatalog {

   @Column(unique = true, nullable = false, name = "CODE",updatable=false)
    private String code;

    public void setCode(final String code) {
        this.code = code;
    }

public String getCode() {
        return this.code;
    }

}

Spring data jpa repository:

public interface OrderRepository extends AbstractCatalogRepository<Order> {
}

AbstractCatalogRepository:

@NoRepositoryBean
public interface AbstractCatalogRepository<T extends AbstractCatalog> extends
  CustomRepository<T, Serializable> {
     T findByCode(String code);
} 

The junit test:

@Inject
    private OrderRepository orderRepository;

    @Test
    public void orderCatalogisComplete() throws Exception {
        Assert.assertNotNull(orderRepository); // OK
        Assert.assertEquals(18,orderRepository.count()); //OK       
    }
    @Test
    public void searchForSL1InDb(){

        Order sl1 = orderRepository.findByCode("SL-1"); // HANGS HERE
         Assert.assertNotNull(sl1);
    }
}

This is the relevant resulting logging:

...preceding spring integration logging (also used in my project)...
13:49:19.828 INFO  o.s.i.m.IntegrationMBeanExporter start 357 - started org.springframework.integration.monitor.IntegrationMBeanExporter@1202f4d
13:49:19.828 INFO  o.s.c.s.DefaultLifecycleProcessor start 334 - Starting beans in phase 2147483647

And there it hangs..

like image 604
Mark Avatar asked Nov 11 '22 09:11

Mark


1 Answers

I've run into a similar issue, if you are logging elsewhere, check your other log location as there might be another message from a component that makes the build hang - in my case it was cobertura.

like image 181
TomaszZ. Avatar answered Jan 04 '23 03:01

TomaszZ.