javax. naming. NoInitialContextException
Bonsoir,
Je débute avec ejb3, j'ai créer une session bean
voila mon code
Code:
1 2 3 4 5 6
| import javax.ejb.Remote;
@Remote
public interface mybeanRemote {
public String hi(String a);
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| import javax.ejb.Stateless;
/**
* Session Bean implementation class mybean
*/
@Stateless
public class mybean implements mybeanRemote {
public mybean() {
// TODO Auto-generated constructor stub
}
public String hi(String a){return "hi "+a;}
} |
Après déploiement sous jboss5 j'ai créer une classe de test
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.st.mybeanRemote;
public class ClientPremierEJB3 {
public static void main(String[] args) {
try {
Context context = new InitialContext();
mybeanRemote beanRemote = (mybeanRemote)
context.lookup("mybean/remote");
System.out.println(beanRemote.hi(" Marou"));
} catch (NamingException e) {
e.printStackTrace();
}
}
} |
Le problème quand je lance l'application il m'indique
Code:
1 2 3 4 5 6
| javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at ClientPremierEJB3.main(ClientPremierEJB3.java:13) |
Merci d'avance