0

I have an issue in programming an EJB application. I search a solution but I still have the same problem with glassfish :

cannot Deploy EducationPortal
deploy is failing=Error occurred during deployment: Exception while deploying the app [EducationPortal] : 
Warning : Unable to determine local  business vs. remote business designation for  EJB 3.0 ref Local ejb-ref     
name=com.portal.education.servlet.ModuleController/moduleServiceLocal,Local 3.x
interface =com.portal.education.service.Module.ModuleServiceLocal,ejb-
link=ModuleServiceImpl,lookup=,mappedName=,jndi-name=,refType=Session. 
Please see server.log for more details.

i have to refer to several EJB in the same servlet in order to use some methods what should i do to get the correct result

@EJB (beanName = "ModuleServiceImpl") 

private ModuleServiceLocal moduleServiceLocal;
@EJB(beanName = "TeacherServiceImpl") 
private TeacherServiceLocal teacherServiceLocal;
@EJB(beanName = "LevelServiceImpl") 
private LevelServiceLocal levelServiceLocal;
@EJB(beanName = "SubjectServiceImpl") 
private SubjectServiceLocal subjectServiceLocal;

interface ModuleServiceLocal

import java.util.List;

import javax.ejb.Local;

import com.issatso.portal.education.domain.*;
import com.issatso.portal.education.domain.Module.Id;

@Local
 public interface ModuleServiceLocal {



    Module find(Id idModule);
    List<Module> findAll();

    void delete(Id idModule);

    Module save(Module object);

}

class ModuleServiceImpl

import java.util.List;

import javax.ejb.Singleton;
import javax.inject.Inject;

import com.issatso.portal.education.dao.module.ModuleDao;
import com.issatso.portal.education.domain.Module.Id;
import com.issatso.portal.education.domain.Module;

@Singleton
  public class ModuleServiceImpl   implements ModuleServiceLocal  {


    @Inject
    private ModuleDao dao;

    public Module find(Id idModule) {
        return (Module) this.dao.find(idModule);
    }

    public List<Module> findAll() {
        return this.dao.findAll();
    }

    public void delete(Id idModule) {
        this.dao.delete(idModule);

    }

    public Module save(Module object) {
        String action = (object.getIdModule()!= null) ? "UPDATED" : "CREATED";
        Module Module = (com.issatso.portal.education.domain.Module) this.dao.save(object);
        return Module;
    }


    }
  • Possible duplicate (or similar to) [https://stackoverflow.com/questions/7089670/ejb reference in deployment descriptor without annotations](https://stackoverflow.com/questions/7089670/ejb-reference-in-deployment-descriptor-without-annotations) though I know its not deployment descriptor related as these are annotations. – JGlass Jan 22 '18 at 18:53
  • isn't the same problem because it well work when i refer to just one ejb –  Jan 22 '18 at 18:57
  • 1
    Please add the code of your `ModuleServiceLocal` and `ModuleServiceImpl`. – unwichtich Jan 22 '18 at 19:21
  • @ unwichtich i add it –  Jan 22 '18 at 19:33

1 Answers1

1

You can use @Inject in your servlet to inject the beans. And you do not need to define the beanName. Just do:

@Inject
private ModuleServiceLocal moduleServiceLocal;
@Inject
private TeacherServiceLocal teacherServiceLocal;
[...]

You are implementing the interface ModuleServiceLocal in your bean ModuleServiceImpl so CDI is able to find the class by that.

Georg Leber
  • 3,470
  • 5
  • 40
  • 63