bonjour
je suis en train de développer une application web avec ejb3, eclipse WTP et jboss 4.2. mais je n'arrive pas à appeler mon bean à partir d'une servlet
voici mon interface :
@Remote
public interface GestionProjetRemote {
public void addProjet(String code, String cout,String duree,String libelle);
public void addP(Projet pj);
public String hello();
}
et le bean :
@Stateless (name="GestionProjet")
@PersistenceContext (name="firstJPA")
public class GestionProjet implements GestionProjetRemote {
private EntityManager em;
private Projet prj;
public GestionProjet() {
}
public void addProjet(String code, String cout, String duree, String libelle) {
prj = new Projet();
prj.setCode(code);
prj.setCout(cout);
prj.setDuree(duree);
prj.setLibelle(libelle);
em.persist(prj);
}
public void addP(Projet pj){
em.persist(pj);
}
public String hello(){
return ("coucou");
}
et voici le code de la servlet , je récuperer les données à partir d'une jsp pour les insérer dans une base Mysql:
String d1 = request.getParameter("projetCode");
String d2 =request.getParameter("cout");
String d3 =request.getParameter("duree");
String d4 =request.getParameter("noteLancement");
Hashtable ht=new Hashtable();
ht.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
ht.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
ht.put("java.naming.provider.url", "localhost:1099");
try {
InitialContext context = new InitialContext(ht);
GestionProjetRemote gp = (GestionProjetRemote) context.lookup("GestionProjet/remote");
gp.addProjet(d1, d2, d3, d4);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
le bean se déploi sans problème mais l'application web ne marche pas
merci pour votre aide
Partager