Caros,
estou aprendendo EJB e gostaria de buscar variaveis de Context
mas está me dando erro o que estou fazendo de errado …
Da erro no metodo setSessionContext
quem puder me ajudar agradeceria …
abs
Exception in thread "main" java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: Could not instantiate bean
at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:365)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:136)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:637)
at org.jboss.ejb.Container.invoke(Container.java:981)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class CalculadoraBean implements SessionBean {
SessionContext sessionContext;
public CalculadoraBean() {
System.out.println("Está CalculadoraBean()...");
}
@Override
public void ejbActivate() throws EJBException, RemoteException {
System.out.println("Está ejbActivate()...");
}
@Override
public void ejbPassivate() throws EJBException, RemoteException {
System.out.println("Exibe ejbPassivate()...");
}
@Override
public void ejbRemove() throws EJBException, RemoteException {
System.out.println("Exibe ejbRemove()...");
}
@Override
public void setSessionContext(SessionContext arg0) throws EJBException,
RemoteException {
sessionContext = arg0;
System.out.println("Exibe setSessionContext ...");
Properties properties = sessionContext.getEnvironment();
String valor1 =properties.getProperty("INITIAL_CONTEXT_FACTORY");
String valor2 =properties.getProperty("PROVIDER_URL");
System.out.println("Exibe setSessionContext (1)..."+valor1);
System.out.println("Exibe setSessionContext (2)..."+valor2);
}
public void ejbCreate() throws CreateException{
System.out.println("ejbCreate()..");
}
public Integer soma(Integer v1, Integer v2 ){
return v1+v2;
}
}
