bahri noredine
bahri noredine

Reputation: 751

error inject EJB in JSF project

hi everyone im new in java EE and i want to developpe an application with EJB and JSF and when i want to inject my JAR in web dynamique project i have this error and i dont understood anything please anyone can help me

17:54:06,324 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."PGestion.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."PGestion.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "PGestion.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0406: No EJB found with interface of type 'com.bestofgeeks.gestion.dao.Implement.GestionDAOBean' for binding com.bestofgeeks.gestion.services.ImplService.ImplServiceProduct/product
    at org.jboss.as.ejb3.deployment.processors.EjbInjectionSource.getResourceValue(EjbInjectionSource.java:90)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:211)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:182)
    at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:186)
    at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:143)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
    ... 5 more

17:54:06,341 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.8.Final
17:54:06,696 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0002: Started client-mappings cache from ejb container
17:54:06,777 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "PGestion.war")]) - failure description: {
    "WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"PGestion.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"PGestion.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0406: No EJB found with interface of type 'com.bestofgeeks.gestion.dao.Implement.GestionDAOBean' for binding com.bestofgeeks.gestion.services.ImplService.ImplServiceProduct/product"},
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"PGestion.war\".beanmanager"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.deployment.unit.\"PGestion.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"PGestion.war\".beanmanager]",
        "jboss.deployment.unit.\"PGestion.war\".batch.artifact.factory is missing [jboss.deployment.unit.\"PGestion.war\".beanmanager]"
    ]
}

This is the interface DAO:

package com.bestofgeeks.gestion.dao; 

import java.util.List; 
import javax.ejb.Local; 
import com.bestofgeeks.gestion.entity.products; 

@Local 
public interface IGestion { 
  public void delete(products p); 
  public products persiste(products p); 
  public List<products> selectAll(); 
} 

interface DAO

package com.bestofgeeks.gestion.dao;

import java.util.List;

import javax.ejb.Local;

import com.bestofgeeks.gestion.entity.products;

@Local
public interface IGestion   {

    public void delete(products p);
    public products persiste(products p);
    public List<products> selectAll();

}

implement DAO

package com.bestofgeeks.gestion.dao.Implement;


import java.util.List;

import javax.ejb.Stateless;
import javax.management.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.bestofgeeks.gestion.dao.IGestion;
import com.bestofgeeks.gestion.entity.products;
@Stateless
public class GestionDAOBean implements IGestion{
    @PersistenceContext(unitName = "Gestion_PU") 
    EntityManager entityManager;

    @Override
    public void delete(products p) {
        // TODO Auto-generated method stub
        entityManager.remove(p);

    }

    @Override
    public products persiste(products p){
        // TODO Auto-generated method stub
        entityManager.persist(p);
        return p;

        }

    @Override
    public List<products> selectAll() {
        // TODO Auto-generated method stub
         Query query = (Query) entityManager.createQuery("SELECT o from products o");
            return ((javax.persistence.Query) query).getResultList();
    }



}

and this is package service of my project this service have interface Iservice and a package of implement class name ImplServiceProduct for Iservice this is the code

    package com.bestofgeeks.gestion.services;

import java.util.List;

import javax.ejb.Local;

import com.bestofgeeks.gestion.entity.products;

@Local
public interface Iservices {
    public List<products> selectAll();
    public void delete(products p);
    public products persiste(products p);
}

for implement service

    package com.bestofgeeks.gestion.services.ImplService;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import com.bestofgeeks.gestion.dao.Implement.GestionDAOBean;
import com.bestofgeeks.gestion.entity.products;
import com.bestofgeeks.gestion.services.Iservices;

@Stateless
public class ImplServiceProduct implements Iservices{
    @EJB
    GestionDAOBean product;


    @Override
    public List<products> selectAll() {

        return product.selectAll();
    }

    @Override
    public void delete(products p) {
        // TODO Auto-generated method stub
        product.delete(p);

    }

    @Override
    public products persiste(products p) {
        // TODO Auto-generated method stub
        return product.persiste(p);
    }


}

for the entity

    package com.bestofgeeks.gestion.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table
public class products {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    @Column
    private String nameproduct;
    @Column
    private String reference;
    @Column
    private Date dateposte;
    public products(String nameproduct, String reference, Date dateposte) {
        super();
        this.nameproduct = nameproduct;
        this.reference = reference;
        this.dateposte = dateposte;
    }
    public products() {
        super();
        // TODO Auto-generated constructor stub
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getNameproduct() {
        return nameproduct;
    }
    public void setNameproduct(String nameproduct) {
        this.nameproduct = nameproduct;
    }
    public String getRefence() {
        return reference;
    }
    public void setRefences(String reference) {
        this.reference = reference;
    }
    public Date getDateposte() {
        return dateposte;
    }
    public void setDateposte(Date dateposte) {
        this.dateposte = dateposte;
    }


}

and for my jsf project i create a controller this is the code

    package com.bestofgeeks.gestion.controllers;

import javax.annotation.ManagedBean;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;


import com.bestofgeeks.gestion.services.Iservices;

@RequestScoped @ManagedBean
public class myProduct {
@EJB
    public String name = "noredine";

    Iservices service;







}

Upvotes: 0

Views: 451

Answers (1)

Simon Martinelli
Simon Martinelli

Reputation: 36103

You must inject the local interface not the bean:

@EJB
IGestion product;

As @kukeltje says in the comment:

Read the error: (emphasis mine) "No EJB found with interface of type 'com.bestofgeeks.gestion.dao.Implement.GestionDAOBean" and what it references is a impl, not

an interface!

Upvotes: 2

Related Questions