Glassfish error while deploying ear web applicatio

2019-07-15 06:34发布

Continuation of Glassfish error while deploying ear web application

Im trying to solve this error when i deploy the EAR project with a glassfish server. It's already solved for one of the class and now i get the same error in another. I can't apply the same solution because in this new class there are multiple @EJB calls(i don't really know if that's the issue anyway).

The error:

Exception while deploying the app [ociumfinal-ear] : Cannot resolve reference [Local ejb-ref name=net.ocium.ociumapp.modelo.ModeloApp/eventoEjb,Local 3.x interface =com.eventos.EventoFacadeLocal,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session] because there are [2] ejbs in the application with interface com.eventos.EventoFacadeLocal. 

Class ModeloApp:

public class ModeloApp {

private List<Evento> listEventEjb;
private List<GranEvento> listGranEvenEjb;
private List<Promocion> listPromocionEjb;
private EventBus eventBus;
private static String CHANNEL = "/app/";

@EJB
private EventoFacadeLocal eventoEjb;
@EJB
private GranEventoFacadeLocal granEventoEjb;
@EJB
private PromocionFacadeLocal promocionEjb;
@EJB
private QuedadaFacadeLocal quedadaEjb;
@EJB
private UsuarioFacadeLocal usuarioEjb;
@EJB
private PersonaFacadeLocal personaEjb;
@EJB
private ImagenFacadeLocal imagenEjb;
@EJB
private ProvinciaFacadeLocal provinciaEjb;
@EJB
private PoblacionFacadeLocal poblacionEjb;
@EJB
private BbddFacadeLocal bbddEjb;
@EJB
private EventoUsuarioFacadeLocal eventoUsuarioEjb;
@EJB
private EventoMensajeFacadeLocal eventoMensajeEjb;
@EJB
private QuedadaUsuarioFacadeLocal quedadaUsuarioEjb;
@EJB
private ConversacionFacadeLocal conversacionEjb;
@EJB
private RoomFacadeLocal roomEjb;
@EJB
private PropuestaQuedadaFacadeLocal propuestaQuedadaEjb;


@Inject
private ServletContext ctx;

public ModeloApp() {

}

public String dameListQuedadas() {

    return null;
}

public String dameListEvenHoy(String city) {
    String resultado = "Prueba correcta"; 
    city = (String)fromString(city);
    try {
        Context ctx = new InitialContext();///ocium-web-1.0-SNAPSHOT/
        eventoEjb = (EventoFacadeLocal) ctx.lookup("java:global/ocium-web/EventoFacade!com.eventos.EventoFacadeLocal");
        listEventEjb = new ArrayList<>();
        listEventEjb = eventoEjb.findByFechaHoyProvincia(dameProvinciaDesdeCity(city));
        resultado = "Contexto creado correcta size es:" + listEventEjb.size();
    } catch (NamingException ex) {
        Logger.getLogger(ModeloApp.class.getName()).log(Level.SEVERE, null, ex);
        System.out.println("kkkkk" + ex.getMessage());
    }
    ListEvenHoy listado = new ListEvenHoy();
    listado.setListadoEventos(listEventEjb);
    resultado = toString(listado);
    return resultado;
}

Interface EventoFacade.java(first lines, it's really big):

@Stateless
public class EventoFacade extends AbstractFacade<Evento> implements 
EventoFacadeLocal {

@PersistenceContext(unitName = "com.eventos_ocium-ejb_ejbPU")
private EntityManager em;

@Override
protected EntityManager getEntityManager() {
    return em;
}

public EventoFacade() {
    super(Evento.class);
}

@Override
public List<Evento> findByFechaHoy() {
    Date dateToday = new Date();
    Calendar tomorrow = Calendar.getInstance();
    tomorrow.add(Calendar.DAY_OF_YEAR, +1);
    tomorrow.set(Calendar.HOUR_OF_DAY, 0);
    tomorrow.set(Calendar.MINUTE, 0);
    tomorrow.set(Calendar.SECOND, 1);
    Date dateTomorrow = tomorrow.getTime();
    TypedQuery<Evento> consultaEventos = em.createNamedQuery("Evento.findByFechaHoy", Evento.class);
    consultaEventos.setParameter("today", dateToday, TemporalType.TIMESTAMP);
    consultaEventos.setParameter("tomorrow", dateTomorrow, TemporalType.TIMESTAMP);
    List<Evento> lista = consultaEventos.getResultList();
    return lista;
}

@Override
public List<Evento> findByFechaHoyProvincia(Provincia provinciaId) {
    Date dateToday = new Date();
    Calendar tomorrow = Calendar.getInstance();
    tomorrow.add(Calendar.DAY_OF_YEAR, +1);
    tomorrow.set(Calendar.HOUR_OF_DAY, 0);
    tomorrow.set(Calendar.MINUTE, 0);
    tomorrow.set(Calendar.SECOND, 1);
    Date dateTomorrow = tomorrow.getTime();
    TypedQuery<Evento> consultaEventos = em.createNamedQuery("Evento.findByFechaHoyProvincia", Evento.class);
    consultaEventos.setParameter("today", dateToday, TemporalType.TIMESTAMP);
    consultaEventos.setParameter("tomorrow", dateTomorrow, TemporalType.TIMESTAMP);
    consultaEventos.setParameter("provinciaId", provinciaId);
    List<Evento> lista = consultaEventos.getResultList();
    return lista;
}

I've tried this:

@EJB(beanName="EventoFacade")
private EventoFacadeLocal eventoEjb;
@EJB(beanName="EventoFacade")
private GranEventoFacadeLocal granEventoEjb;
@EJB(beanName="EventoFacade")
private PromocionFacadeLocal promocionEjb;
@EJB(beanName="EventoFacade")
private QuedadaFacadeLocal quedadaEjb;
@EJB(beanName="EventoFacade")
private UsuarioFacadeLocal usuarioEjb;
@EJB(beanName="EventoFacade")
private PersonaFacadeLocal personaEjb;
@EJB(beanName="EventoFacade")
private ImagenFacadeLocal imagenEjb;
@EJB(beanName="EventoFacade")
private ProvinciaFacadeLocal provinciaEjb;
@EJB(beanName="EventoFacade")
private PoblacionFacadeLocal poblacionEjb;
@EJB(beanName="EventoFacade")
private BbddFacadeLocal bbddEjb;
@EJB(beanName="EventoFacade")
private EventoUsuarioFacadeLocal eventoUsuarioEjb;
@EJB(beanName="EventoFacade")
private EventoMensajeFacadeLocal eventoMensajeEjb;
@EJB(beanName="EventoFacade")
private QuedadaUsuarioFacadeLocal quedadaUsuarioEjb;
@EJB(beanName="EventoFacade")
private ConversacionFacadeLocal conversacionEjb;
@EJB(beanName="EventoFacade")
private RoomFacadeLocal roomEjb;
@EJB(beanName="EventoFacade")
private PropuestaQuedadaFacadeLocal propuestaQuedadaEjb;

Then i get this error:

Exception while deploying the app [ociumfinal-ear] : Warning : Unable to determine local  business vs. remote business designation for  EJB 3.0 ref Local ejb-ref name=net.ocium.ociumapp.modelo.ModeloApp/granEventoEjb,Local 3.x interface =com.eventos.GranEventoFacadeLocal,ejb-link=EventoFacade,lookup=,mappedName=,jndi-name=,refType=Session

Glassfish-ejb-jar.xml:

<glassfish-ejb-jar>
<security-role-mapping>
<role-name>ADMINISTRATIVO</role-name>
<group-name>ADMINISTRATIVO</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>COMERCIAL</role-name>
<group-name>COMERCIAL</group-name>
<group-name>GERENCIA</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>CLIENTE</role-name>
<group-name>CLIENTE</group-name>
<group-name>GERENCIA</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>USUARIO</role-name>
<group-name>USUARIO</group-name>
<group-name>CLIENTE</group-name>
<group-name>COMERCIAL</group-name>
<group-name>ADMINISTRATIVO</group-name>
<group-name>COLABORADOR</group-name>
<group-name>GERENCIA</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>COLABORADOR</role-name>
<group-name>COLABORADOR</group-name>
<group-name>GERENCIA</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>GERENCIA</role-name>
<group-name>GERENCIA</group-name>
</security-role-mapping>
<enterprise-beans>
<ejb>
  <ejb-name>AcreedorFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/AcreedorFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>AnuncioFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/AnuncioFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>ClienteFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/ClienteFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>ContactoFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/ContactoFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>ContactoUsuarioFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/ContactoUsuarioFacadeLocal</jndi- 
name>
</ejb>
<ejb>
  <ejb-name>EmpleadoFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/EmpleadoFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>EventoFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/EventoFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>EventoMensajeFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/EventoMensajeFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>EventoUsuarioFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/EventoUsuarioFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>GranEventoFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/GranEventoFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>GrupoFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/Grupo</jndi-name>
</ejb>
<ejb>
  <ejb-name>ImagenFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/ImagenFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>NegocioFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/NegocioFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>PersonaFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/PersonaFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>PoblacionFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/PoblacionFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>PromocionFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/PromocionFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>VideoFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/VideoFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>UsuarioGrupoFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/UsuarioGrupoFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>UsuarioFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/UsuarioFacade</jndi-name>
  <ejb-ref>
    <ejb-ref-name>ejb_ref1</ejb-ref-name>
  </ejb-ref>
</ejb>
<ejb>
  <ejb-name>QuedadaUsuarioFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/QuedadaUsuarioFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>QuedadaFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/QuedadaFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>PropuestaQuedadaFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/PropuestaQuedadaFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>ProveedorFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/ProveedorFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>ProvinciaFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/ProvinciaFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>SeccionFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/SeccionFacade</jndi-name>
</ejb>
<ejb>
  <ejb-name>ConversacionFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/ConversacionFacadeLocal</jndi-name>
</ejb>
<ejb>
  <ejb-name>RoomFacade</ejb-name>
  <jndi-name>java:global/ocium-ejb/RoomFacadeLocal</jndi-name>
</ejb>
</enterprise-beans>
 </glassfish-ejb-jar>

Any help is appreciated

1条回答
该账号已被封号
2楼-- · 2019-07-15 07:20

a qualifier annotation will solve this.

https://docs.oracle.com/javaee/6/tutorial/doc/gjbck.html

basically create an annotation that differentiates the instance you want injected and annotate the implementation with the matching qualifier. the linked tutorial should get you going.

查看更多
登录 后发表回答