[Remote] IllegalStateException: impossible d'ajouter une ressource non-XA à une transaction JTS globale
bonjour
voila je suis débutant en java et j'ai un petit soucis avec mes ejbs.
lorsqu'ils tournent sur la même machine (corbaname:iiop:localhost:3700... ) tout fonctionne.
Seulement quand je met mes ejbs metiers sur un serveur distant et que je tente d'y accéder :
Internal Exception: java.sql.SQLException: Erreur lors de l'établissement d'une connexion. Raison : java.lang.IllegalStateException: impossible d''ajouter une ressource non-XA à une transaction JTS globale.
Error Code: 0
Call: SQLCall(INSERT INTO utilisateur (prenom, etat, login, ip, pseudo, port, timeOut, nom, mdp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?))
Query: InsertObjectQuery(Ecml.Projet.metier.Utilisateur[idUtilisateur=null])
gestionUtilisateur:
Code:
1 2 3 4 5 6
|
@Remote
public interface gestionUtilisateurs {
public int Inscription(String login,String mdp,String pseudo,String nom,String prenom);
...} |
gestionUtilisateurBean:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| @Stateless
public class gestionUtilisateursBeans implements gestionUtilisateurs {
@PersistenceContext
private EntityManager em;
private FileWriter logFile;
private DateFormat date;
private DateFormat heure;
public gestionUtilisateursBeans() {
logFile = null;
date = new SimpleDateFormat("dd-MM-yy-");
heure = new SimpleDateFormat("hh:mm:ss: ");
}
public int Inscription(String login, String mdp, String pseudo, String nom, String prenom) {
Query result = em.createNamedQuery("Inscription").setParameter("login", login);
if (result.getResultList().isEmpty() == true) { //si le login n'existe pas déjà, on créé
//si le login n'existe pas déjà, on créé
Utilisateur utilisateurAdd = new Utilisateur();
utilisateurAdd.setLogin(login);
utilisateurAdd.setMdp(mdp);
utilisateurAdd.setPseudo(pseudo);
utilisateurAdd.setNom(nom);
utilisateurAdd.setPrenom(prenom);
utilisateurAdd.setEtat(false);
utilisateurAdd.setIp("NULL");
utilisateurAdd.setPort(0);
em.persist(utilisateurAdd);
try {
logFile = new FileWriter("c:/" + date.format(new Date()) + "WSAnnuaire.log", true);
logFile.write(heure + "Ajout d'un nouveau contact( " + login + "," + pseudo + "," + nom + "," + prenom + ").\n");
logFile.close();
} catch (IOException ex) {
Logger.getLogger(gestionUtilisateursBeans.class.getName()).log(Level.SEVERE, null, ex);
}
return 0;
} else {
return 1;
}
} |
l'interface (qui est un webservice):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| @Stateless
@WebService
public class AnnuaireWebServices {
@EJB(name="gestionUtilisateurs")
private gestionUtilisateurs gestUseWS;
private static Map<String, Integer> listUsersKeys;
public AnnuaireWebServices()
{
if (listUsersKeys == null) {
listUsersKeys = new TreeMap<String, Integer>();
}
}
@WebMethod
public int WSInscription(@WebParam(name = "login") String login,@WebParam(name = "pass") String mdp,@WebParam(name = "pseudo") String pseudo,@WebParam(name = "nom") String nom,@WebParam(name = "prenom") String prenom)
{
int ret = -1;
try {
ret = gestUseWS.Inscription(login, mdp, pseudo, nom, prenom);
} catch (Exception exception) {
System.out.println("WSInscription :" + exception.toString());
}
return ret;
} |
voila si quelqu'un peut m'aider ...
edit:
voici le sun-ejb-jar.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>AnnuaireWebServices</ejb-name>
<ejb-ref>
<ejb-ref-name>gestionUtilisateurs</ejb-ref-name>
<jndi-name>corbaname:iiop:localhost:3700#Ecml.Projet.ejb.gestionUtilisateurs</jndi-name>
</ejb-ref>
</ejb>
</enterprise-beans>
</sun-ejb-jar> |