Jakarta ee 请参阅几个JavaBeans企业版
我在编写EJB应用程序时遇到了一个问题。我正在寻找解决方案,但glassfish仍然存在同样的问题:Jakarta ee 请参阅几个JavaBeans企业版,jakarta-ee,glassfish,ejb,Jakarta Ee,Glassfish,Ejb,我在编写EJB应用程序时遇到了一个问题。我正在寻找解决方案,但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 busin
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.
为了使用一些方法,我必须在同一个servlet中引用几个EJB
我应该怎么做才能得到正确的结果
@EJB (beanName = "ModuleServiceImpl")
private ModuleServiceLocal moduleServiceLocal;
@EJB(beanName = "TeacherServiceImpl")
private TeacherServiceLocal teacherServiceLocal;
@EJB(beanName = "LevelServiceImpl")
private LevelServiceLocal levelServiceLocal;
@EJB(beanName = "SubjectServiceImpl")
private SubjectServiceLocal subjectServiceLocal;
接口模块服务本地
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);
}
类模块服务impl
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;
}
}
您可以在servlet中使用@Inject来注入bean。您不需要定义beanName。只要做:
@Inject
private ModuleServiceLocal moduleServiceLocal;
@Inject
private TeacherServiceLocal teacherServiceLocal;
[...]
您正在bean ModuleService Impl中实现接口ModuleService Local,因此CDI能够通过它找到类。可能重复或类似,尽管我知道它与部署描述符无关,因为这些都是注释。这不是同样的问题,因为当我只引用一个EJB时,它工作得很好请添加您的ModuleServiceLocal和ModuleServiceImpl。@我添加了它