jpa connection error

19 views
Skip to first unread message

jacob

unread,
Jul 20, 2011, 10:22:17 PM7/20/11
to Lift

I got this message

Exception occured while processing /authors/list
Message: java.lang.NullPointerException
org.scala_libs.jpa.LocalEMF.openEM(LocalEM.scala:97)
net.liftweb.jpa.RequestVarEM$emVar$$anonfun$$init$
$1.apply(RequestVarEM.scala:46)
net.liftweb.jpa.RequestVarEM$emVar$$anonfun$$init$
$1.apply(RequestVarEM.scala:46)
net.liftweb.util.AnyVar.calcDefaultValue(AnyVar.scala:92)
net.liftweb.util.AnyVarTrait$$anonfun$is$1.apply(AnyVar.scala:139)
net.liftweb.http.TransientRequestVar.doSync(Vars.scala:494)
net.liftweb.util.AnyVarTrait$class.is(AnyVar.scala:136)
net.liftweb.util.AnyVar.is(AnyVar.scala:89)
net.liftweb.jpa.RequestVarEM$class.em(RequestVarEM.scala:53)
ain.board.model.Model$.em(Model.scala:24)
org.scala_libs.jpa.ScalaEntityManager
$class.createNamedQuery(ScalaEntityManager.scala:216)
ain.board.model.Model$.createNamedQuery(Model.scala:24)
ain.board.snippet.AuthorOps.list(Author.scala:35)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
java.lang.reflect.Method.invoke(Method.java:597)
.........................

The code is lift jpa example code.

Where can I see the source code of LocalEM.scala:97?

Any thought or suggestion will be warmly welcomed

please give me some clue.

Thank you!

Derek Chen-Becker

unread,
Jul 20, 2011, 11:28:03 PM7/20/11
to lif...@googlegroups.com
https://github.com/dchenbecker/scalajpa/blob/master/src/main/scala/org/scala_libs/jpa/LocalEM.scala

That line of code is where an EM gets created from an EMF, so I'm guessing that somehow the EMF didn't get created. Are there no other exceptions earlier in the log?

Derek


--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.


jacob

unread,
Jul 21, 2011, 1:12:12 AM7/21/11
to Lift
I try to connect google datanucleus using google app engine but used
the jpa example source code.

this is my persistence.xml

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">

<persistence-unit name="transactions-optional">

<provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</
provider>
<properties>
<property name="datanucleus.NontransactionalRead"
value="true"/>
<property name="datanucleus.NontransactionalWrite"
value="true"/>
<property name="datanucleus.ConnectionURL"
value="appengine"/>
</properties>
</persistence-unit>

<persistence-unit name="eventual-reads-short-deadlines">

<provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</
provider>
<properties>
<property name="datanucleus.NontransactionalRead"
value="true"/>
<property name="datanucleus.NontransactionalWrite"
value="true"/>
<property name="datanucleus.ConnectionURL"
value="appengine"/>

<property
name="datanucleus.appengine.datastoreReadConsistency"
value="EVENTUAL" />
<property name="javax.persistence.query.timeout"
value="5000" />
<property name="datanucleus.datastoreWriteTimeout"
value="10000" />
</properties>
</persistence-unit>
</persistence>

and the path is /src/main/resources/META-INF/persistence.xml

and I can see correctly located path "webapp/WEB-INF/classes/META-INF/
persistence.xml", when I execute dev_appserver.

I can't see any exception in the console. this exception is the only
exception which can be seen in the web browser.

ain.board.model.Model$.em(Model.scala:24)

My Model.scala code is

package ain.board.model {

import javax.persistence.Persistence

import _root_.org.scala_libs.jpa.LocalEMF
import _root_.net.liftweb.jpa.RequestVarEM

object Model extends LocalEMF("transactions-optional") with
RequestVarEM

}

I believe emf didn't created properly in this code

// The underlying entitymanager factory
private val emf = properties match {
case None => Persistence.createEntityManagerFactory(unitName)
case Some(props) =>
Persistence.createEntityManagerFactory(unitName, unmap(props))
}

However how can I trace form here?

Looking forward to seeing further discussion.

Thank you!

On 7월21일, 오후1시28분, Derek Chen-Becker <dchenbec...@gmail.com> wrote:
> https://github.com/dchenbecker/scalajpa/blob/master/src/main/scala/or...

Derek Chen-Becker

unread,
Jul 29, 2011, 10:45:29 AM7/29/11
to lif...@googlegroups.com
I would try running in your code:

Persistence.createEntityManagerFactory("transactions-optional")

and see what you get back (null, or an actual instance).

Derek
Reply all
Reply to author
Forward
0 new messages