webtier@glassfish.java.net

Persistence IllegalArgumentException in EntityManager

From: <webtier_at_javadesktop.org>
Date: Fri, 05 Feb 2010 11:28:18 PST

i m trying to retrieve a table using persistence framework

the code i have written is in simple java class file in webapplication

the code in the java class

    EntityManager em = null;
        EntityManagerFactory emf = null;
    
    public List fname (String id) {
        String fname = null;
        List persons = null;
        try {
            emf = Persistence.createEntityManagerFactory("WebApplicationSecurityPU");
            em = emf.createEntityManager();
            persons = em.createQuery("select r from Roleuser r").getResultList();
            int i=0;
            for (i=0;i<persons.size(); i++)
                System.out.println("Testing n "+ i + persons.get(i));
            
        } catch(Exception e) {
            System.out.println( e);
        }
        finally {
            if(em != null) {
                em.close();
            }
        }
        return persons;
    }

But on running this i m getting a IllegalArgumentException
the full exception being

    java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager


I think the entity classes are not initialized or they have not connected with the database
Thats why the IllegalArgumentException

Please any help

Thanks
Pradyut
[Message sent by forum member 'pradyut' (pradyut100_at_yahoo.com)]

http://forums.java.net/jive/thread.jspa?messageID=385054