Pessoal,
Tentei implementar um exemplo simples para testar o lookup de uma aplicação stanalone com um EJB em um container remoto.
Segue abaixo a implementação do aplicativo cliente e do EJB (servidor Glassfish):
App Cliente:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clientappstandalone;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
*
* @author kurumin
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
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");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "12332");
InitialContext ic;
System.out.println("testeante");
ic = new InitialContext(props);
Object o = ic.lookup("Bean30#ejb.Bean30Remote");
System.out.println("testepos");
} catch (NamingException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
EJB’s:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ejb;
import javax.ejb.Stateless;
/**
*
* @author kurumin
*/
@Stateless (mappedName="Bean30")
public class Bean30Bean implements Bean30Remote, Bean30Remote2 {
public String getResult() {
return "This is EJB 3.0 Bean";
}
public String getResult2() {
return "This is EJB 3.0 Bean 2";
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ejb;
import javax.ejb.Remote;
/**
*
* @author kurumin
*/
@Remote
public interface Bean30Remote {
String getResult();
}
Este exemplo está apresentando o seguinte erro: