user1173656
user1173656

Reputation: 103

Error while making object persistent

I'm trying to write a Vaadin application on GAE platform with using JDO, and when I want to call this method:

public void createUser(String login, String password, String email) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    User user = new User(login, password, email);
    try {
        pm.makePersistent(user);
    } finally {
        pm.close();
    }

}

I get this error:

(...)Caused by: javax.jdo.JDOFatalUserException: A property named javax.jdo.PersistenceManagerFactoryClass must be specified, or a jar file with a META-INF/services/javax.jdo.PersistenceManagerFactory entry must be in the classpath, or a property named javax.jdo.option.PersistenceUnitName must be specified. NestedThrowables: javax.jdo.JDOUserException: You have either specified for this PMF to use a "persistence-unit" of "transactions-optional" (yet this doesnt exist!) or you called JDOHelper.getPersistenceManagerFactory with "transactions-optional" as the name of a properties file (and this doesnt exist in the CLASSPATH) at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:856) at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1092) at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:914) at myapp.PMF.(PMF.java:8) ... 43 more Caused by: javax.jdo.JDOUserException: You have either specified for this PMF to use a "persistence-unit" of "transactions-optional" (yet this doesnt exist!) or you called JDOHelper.getPersistenceManagerFactory with "transactions-optional" as the name of a properties file (and this doesnt exist in the CLASSPATH) (...)

I've searched the Google and found some solutions for this problem, but none works for my app (or I'm doing something incorrectly). For eg.this wouldn't work. Oh, and I have the jdoconfig.xml file in META-INF. If anyone had similar problem, and he'd like to share his wisdom I would be very appreciate.

EDIT: jdoconfig file:

<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
    <persistence-manager-factory name="transactions-optional">
        <property name="javax.jdo.PersistenceManagerFactoryClass"
            value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory" />
        <property name="javax.jdo.option.ConnectionURL" value="appengine" />
        <property name="javax.jdo.option.NontransactionalRead" value="true" />
        <property name="javax.jdo.option.NontransactionalWrite"
            value="true" />
        <property name="javax.jdo.option.RetainValues" value="true" />
        <property name="datanucleus.appengine.autoCreateDatastoreTxns"
            value="true" />
    </persistence-manager-factory>
</jdoconfig> 

Upvotes: 3

Views: 4960

Answers (1)

user1173656
user1173656

Reputation: 103

Got it!

jdoconfig.xml

file was in

\war\META-INF

directory that Eclipse had created. Should be in

\war\WEB-INF\classes\META-INF

Dumb mistake...

Upvotes: 6

Related Questions