NovatecConsulting / BeanTest

Bean Testing for Java EE Applications
http://blog.novatec-gmbh.de/unit-testing-jee-applications-cdi/
Apache License 2.0
25 stars 12 forks source link

NPE inside EntityManagerProducer #26

Closed bbq2100 closed 7 years ago

bbq2100 commented 9 years ago
java.lang.NullPointerException
    at info.novatec.beantest.producers.EntityManagerProducer.getEntityManager(EntityManagerProducer.java:79)
    ...

Currently, the producer method getEntityManager also prints logs regarding the persistenceContext and the defining bean instance.


        LOGGER.debug("PersistenceContext info:");
        //This could happen if the application injects the EntityManager via @Inject instead of @PersistenceContext
        if(ctx != null) {
            LOGGER.debug("Unit name: {}", ctx.unitName());
        }

        LOGGER.debug("Bean defining the injection point: {}", ip.getBean().getBeanClass());
        LOGGER.debug("Field to be injected: {}", ip.getMember());

Note that the retrieval of the bean class is not safe here ip.getBean().