Ok, capito tutto!
Mi stai aiutando tantissimo, e ti ringrazio per questo.
Sono alle prime armi con gli EJB e non ho trovato nulla in italiano che potesse aiutarmi per quello che devo fare. L'inglese non lo mastico molto bene!!!
Purtropo la mia applicazione mi da ancora errori:
L'errore sta forse nella formulazione delle query??codice:HTTP Status 500 - -------------------------------------------------------------------------------- type Exception report message descriptionThe server encountered an internal error () that prevented it from fulfilling this request. exception javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: An exception occured while creating a query in EntityManager note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_01 logs. -------------------------------------------------------------------------------- Sun Java System Application Server 9.1_01
Ecco il metodo registraUtente, all'interno ci sono le uniche due query dell'applicazione:
Per le query sto usando 'The Java EE 5Tutorial' che ho trovato sul sito della sun:codice:package my.streetsoccer; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.Query; import javax.ejb.EJBException; import javax.persistence.PersistenceContext; @Stateless public class StreetSoccerBean implements StreetSoccerRemote { @PersistenceContext private EntityManager em; public boolean registraUtente(String nome, String cognome, String email, String username, String password) { try { Query q = em.createQuery("SELECT u.username " + "FROM utente u " + "WHERE u.username = :username") .setParameter("username", username); List lista = q.getResultList(); if(lista.size()>0) { return false; } else { q = em.createQuery("SELECT MAX (u.id) " + "FROM utente u"); lista = q.getResultList(); String s = (String)lista.get(0); int idutente = Integer.parseInt(s); Utente utente = new Utente(idutente, nome, cognome, email, username, password); em.persist(utente); return true; } } catch (Exception e) { throw new EJBException(e.getMessage()); } } }
http://java.sun.com/javaee/5/docs/tu...EETutorial.pdf
Anche questo è in inglese, quindi non sono sicuro della correttezza delle query!

Rispondi quotando