Hi All,

I'm fairly new to GWT and attempting to use GWT with JPA 2.0 , but
have come across various problems.  I'm using the setup below:
* Entity classes with annotations in a JAR on the GWT app classpath
* JPA controllers (largely generated classes that perform the actual
JPA actions, such as persisting objects to the database) in the same
JAR as the entity classes.
* GWT RPC calls (the server side accesses the JPA controllers)

I'm using Eclipse as my IDE with the GWT plugin.

A couple of questions:
* Can the development mode server (Jetty I believe) support JPA? (all
the relevant libraries are on the GWT project's classpath, so there
are no compile errors)  Or do I need to use an external server, and if
so what type would be appropriate?
* How do I structure the files, e.g. where do I put persistence.xml?
Do I keep it with the entity classes from the other project or do I
need it to be with the GWT project?


The following things are working fine so far:
* RPC calls
* Creating an instance of an entity class
* Creating an instance of the JPA controllers

However, the application throws a NullPointerException when the JPA
controller attempts to get an entity manager with which to persist the
entity.

Below are the first few lines of the exception.

java.lang.NullPointerException
        at
com.axle8.entity.jpaController.MarketerUserJpaController.getEntityManager(MarketerUserJpaController.java:
31)
        at
com.axle8.entity.jpaController.MarketerUserJpaController.create(MarketerUserJpaController.java:
37)
        at
com.axle8.web.server.SignUpServiceImpl.signUpMarketer(SignUpServiceImpl.java:
99)

I do NOT get the "No entity manager for persistence unit XYZ".

Below is the code where the exception occurs.  Line 31 (where the
exception occurs) is the following line:
return emf.createEntityManager();


------------------------------------------------------------------------------------------------------------------------

    public MarketerUserJpaController() {
        emf = Persistence.createEntityManagerFactory("Axle8EntityPU");
    }
    private EntityManagerFactory emf = null;

    public EntityManager getEntityManager() {
        return emf.createEntityManager();
    }

    public void create(MarketerUser marketerUser) {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            em.persist(marketerUser);
            //System.out.println(marketerUser.getUserId());
            em.getTransaction().commit();
        } finally {
            if (em != null) {
                em.close();
            }
        }
    }

------------------------------------------------------------------------------------------------------------------------

The entity classes and JPA controllers have been tested successfully
on a J2EE server (Glassfish).

I'm thinking I need to deploy the whole thing to such a server.

Any assistance would be greatly appreciated! Please let me know
whether any further information would help

Regards,

Jin

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to