Calling EJB Remote brings result with 'null' values

1

I'm doing a JEE application and I have this interface which is called from a REST project (PruebaREST)

package co.com.prueba.funcionalities.local;

import co.com.prueba.entities.Categoria;
import java.util.List;
import javax.ejb.Remote;

@Remote
public interface AdminCategoriaServiceRemote {

  List<Categoria> findAll();

}

This is the implementation which is in the EJB project (Test-ejb)

@Stateless
public class AdminCategoriaService implements AdminCategoriaServiceRemote {

  @EJB
  CategoriaFacadeRemote categoriaFacade;

  @Override
  public List<Categoria> findAll() {
      try {
          List<Categoria> categorias = new ArrayList<>();
          categorias = this.categoriaFacade.findAll();

          return categorias;

      } catch (Exception e) {
          System.out.println("Error al implementar AdminUsuariosServicesRemote");
      }

      return null;
  }
}

From these methods I make the call to the interface through the lookup

@Stateless
@Path("categoriaService")
public class CategoriaService implements Serializable {

  private static final long serialVersionUID = 1L;

  private AdminCategoriaServiceRemote adminCategoriaService;

  @GET
  @Path("/findAll")
  @Produces(MediaType.APPLICATION_JSON)
  public List<Categoria> findAll() {
    initContextAdminProductoServices();
    try {
        List<Categoria> categoria = adminCategoriaService.findAll();
        return categoria;
    } catch (Exception e) {
        System.out.println("Error adminCategoriaService.findAll() " + e);
    }

    return null;
  }

  /**
   * Método usado para realizar la inicialización del contexto manual
   */
  private void initContextAdminProductoServices() {
    try {
      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
      props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
      // glassfish default port value will be 3700,
      props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
      InitialContext ctx = new InitialContext(props);
      adminCategoriaService = (AdminCategoriaServiceRemote) ctx.lookup("java:global/Prueba/Prueba-ejb/AdminCategoriaService!co.com.prueba.funcionalities.local.AdminCategoriaServiceRemote");;

    } catch (NamingException ne) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
      throw new RuntimeException(ne);
    }
  }
}

My question is, if I already have the necessary jar's in the client project (gf-client.jar; appserv-rt.jar) and if the call to the interface is successful, why do I return the values with their fields? 'null'?

    
asked by Jeremy Jy 22.11.2017 в 22:06
source

0 answers