Problemas ao tentar fazer o lookup Glassfish[RESOLVIDO]

1 resposta
F

Ola pessoal sou iniciante no desenvolvimento enterprise portanto se eu falar besteira me perdoem.
La vai o problema: Quando eu tento fazer o lookup na minha aplicação aparece essa exception no glassfish
---
javax.naming.NameNotFoundException: IngredienteBeanLocal not found
---
eu tenho um modulo EJB e um WAR e eu faço o deploy com um arquivo EAR, fiz um servlet pra testar a onde ele consulta os ingredientes mas aparece a exception descrita acima.

aqui segue o codigo do servlet

public class Lista extends HttpServlet {
  
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        try {
            Properties props = new Properties();
            props.setProperty("java.naming.factory.initial", 
                             "com.sun.enterprise.naming.SerialInitContextFactory");
            props.setProperty("java.naming.factory.url.pkgs", 
                             "com.sun.enterprise.naming");
            props.setProperty("java.naming.factory.state",
                             "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
            InitialContext c = new InitialContext(props);
            IngredienteLocal local = (IngredienteLocal) c.lookup("IngredienteBeanLocal");
            Iterator it = local.listarIngrediente().iterator();
            out.println("<html><body>");           
            out.println("<h1>Ingrediente<h1><br/>");
            while(it.hasNext()){
                Ingrediente ing = (Ingrediente) it.next();
                out.println("<b>"+ing.getIngCodigo()+"<b><br/>");
                out.println("<b>"+ing.getIngNome()+"<b><br/>");
            }
            out.println("</body></html>");
        } catch (Exception ex) {
            Logger.getLogger(Lista.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            out.close();
        }
    }

aqui segue o sun-ejb-jar

<sun-ejb-jar>
  <enterprise-beans>
    <ejb>
      <ejb-name>IngredienteBean</ejb-name>
    </ejb>
  </enterprise-beans>
</sun-ejb-jar>

eu adicionei o nome JNDI atraves da anotação @Stateless(mappedName="IngredienteBeanLocal")
como diz no tutorial do glassfish.

galera preciso resolver isso urgente !!!

1 Resposta

D

Cara, como foi que você resolveu esse problema?

Descreve aí a sua solução que estou com esse problema também.

Valeu!!!

Criado 7 de novembro de 2007
Ultima resposta 4 de mar. de 2008
Respostas 1
Participantes 2