Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-1301

java.lang.IllegalStateException,message=Could not find EntityManager with default qualifier.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.8.0
    • None
    • Data-Module
    • None
    • Wildfly 10.1.0, Ubuntu 16.04

    Description

      Hello,

      I have the following data-module repository:

      @Repository
      public interface CustomerManagementRepository extends EntityRepository<Customer, BigInteger>
      {
        ...
      }
      

      This repository is called from a stateless session bean, as follows:

        @Inject
        private CustomerManagementRepository repo;
        
        public List<Customer> findByFirsName(String firstName)
        {
          return repo.findByFirsName(firstName);
        }
      

      The following CDI producer is provided as well:

      public class EntityManagerProducer
      {
        @PersistenceContext
        private EntityManager em;
      
        @Produces
        public EntityManager createEntityManager()
        {
          return em;
        }
      }
      

      When calling the staeless bean from a JAX-RS service, as follows:

        @EJB
        private CustomerManagementFacade facade;
      
        @POST
        @Consumes(MediaType.APPLICATION_JSON)
        public Response createCustomer(Customer customer)
        {
          Customer newCustomer = facade.saveAndFlushAndRefresh(customer);
          return Response.created(URI.create("/customers/" + newCustomer.getId())).build();
        }
      

      the following exception is raised:

      15:48:14,914 ERROR [org.jboss.as.ejb3.invocation] (default task-1) WFLYEJB0034: EJB Invocation failed on component CustomerManagementFacade for method public fr.simplex_software.customer_management.data.Customer fr.simplex_software.customer_management.facade.CustomerManagementFacade.saveAndFlushAndRefresh(fr.simplex_software.customer_management.data.Customer): javax.ejb.EJBException: org.apache.deltaspike.data.api.QueryInvocationException: Exception calling Repository: [Repository=class fr.simplex_software.customer_management.repository.CustomerManagementRepository$$DSPartialBeanProxy,method=saveAndFlushAndRefresh],exception=class java.lang.IllegalStateException,message=Could not find EntityManager with default qualifier.
      

      What seems to happen is that the CDI producer doesn't get called. Do I do anything wrong here ? Please don't send me links to the documentation 'cause I've read it before posting.

      Many thanks in advance,

      Nicolas

      P.S. I have the following in apache-deltaspike.properties:

      globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy=org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            nicolasduminil Nicolas Duminil
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: