I'm facing a problem when using a slightly changed "JPA Controller
Class" generated out of my entity class by NetBeans 6.8. In this JPA
Controller Class I'm using the EMF (Entity Manager Factory) as
described here:
http://code.google.com/appengine/docs/java/datastore/usingjpa.html#Getting_an_EntityManager_Instance
I'm using AppEngine-Java-SDK-1.3.0. Why do I get the "is not that of
an entity but needs to be for this operation" exception:
==============================================
public class MessageJpaController {
private EntityManagerFactory emf = null;
public MessageJpaController() {
emf = EMF.get();
}
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(Message message) {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
em.persist(message);
em.getTransaction().commit();
} catch (Exception ex) {
throw new PersistenceException(ex);
} finally {
if (em != null) {
em.close();
}
}
}
...
}
==============================================
@Entity
public class Message implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String message;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date dateTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Date getDateTime() {
return dateTime;
}
public void setDateTime(Date dateTime) {
this.dateTime = dateTime;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Message other = (Message) obj;
if (this.id != other.id && (this.id == null || !this.id.equals
(other.id))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 37 * hash + (this.id != null ? this.id.hashCode() : 0);
return hash;
}
}
==============================================
[java] java.lang.IllegalArgumentException: Type
("de.alteskind.appengine.jpa.Message") is not that of an entity but
needs to be for this operation
[java] at
org.datanucleus.jpa.EntityManagerImpl.assertEntity
(EntityManagerImpl.java:888)
[java] at org.datanucleus.jpa.EntityManagerImpl.persist
(EntityManagerImpl.java:385)
[java] at
de.alteskind.appengine.jpa.MessageJpaController.create
(MessageJpaController.java:28)
[java] at
de.alteskind.appengine.jsf.MessageView.createMessage(MessageView.java:
36)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0
(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:
597)
[java] at
com.google.appengine.tools.development.agent.runtime.Runtime.invoke
(Runtime.java:100)
[java] at com.sun.el.parser.AstValue.invoke(AstValue.java:
187)
[java] at com.sun.el.MethodExpressionImpl.invoke
(MethodExpressionImpl.java:297)
[java] at
com.sun.faces.facelets.el.TagMethodExpression.invoke
(TagMethodExpression.java:98)
[java] at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke
(MethodBindingMethodExpressionAdapter.java:88)
[java] at
com.sun.faces.application.ActionListenerImpl.processAction
(ActionListenerImpl.java:102)
[java] at javax.faces.component.UICommand.broadcast
(UICommand.java:315)
[java] at javax.faces.component.UIViewRoot.broadcastEvents
(UIViewRoot.java:775)
[java] at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:
1267)
[java] at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute
(InvokeApplicationPhase.java:82)
[java] at com.sun.faces.lifecycle.Phase.doPhase
(Phase.java:101)
[java] at com.sun.faces.lifecycle.LifecycleImpl.execute
(LifecycleImpl.java:118)
[java] at javax.faces.webapp.FacesServlet.service
(FacesServlet.java:312)
[java] at org.mortbay.jetty.servlet.ServletHolder.handle
(ServletHolder.java:487)
[java] at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1093)
[java] at
com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter
(ServeBlobFilter.java:51)
[java] at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1084)
[java] at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter
(TransactionCleanupFilter.java:43)
[java] at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1084)
[java] at
com.google.appengine.tools.development.StaticFileFilter.doFilter
(StaticFileFilter.java:121)
[java] at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1084)
[java] at org.mortbay.jetty.servlet.ServletHandler.handle
(ServletHandler.java:360)
[java] at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
[java] at org.mortbay.jetty.servlet.SessionHandler.handle
(SessionHandler.java:181)
[java] at org.mortbay.jetty.handler.ContextHandler.handle
(ContextHandler.java:712)
[java] at org.mortbay.jetty.webapp.WebAppContext.handle
(WebAppContext.java:405)
[java] at
com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle
(DevAppEngineWebAppContext.java:70)
[java] at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java:139)
[java] at
com.google.appengine.tools.development.JettyContainerService
$ApiProxyHandler.handle(JettyContainerService.java:352)
[java] at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java:139)
[java] at org.mortbay.jetty.Server.handle(Server.java:
313)
[java] at org.mortbay.jetty.HttpConnection.handleRequest
(HttpConnection.java:506)
[java] at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:844)
[java] at org.mortbay.jetty.HttpParser.parseNext
(HttpParser.java:644)
[java] at org.mortbay.jetty.HttpParser.parseAvailable
(HttpParser.java:211)
[java] at org.mortbay.jetty.HttpConnection.handle
(HttpConnection.java:381)
[java] at org.mortbay.io.nio.SelectChannelEndPoint.run
(SelectChannelEndPoint.java:396)
[java] at org.mortbay.thread.BoundedThreadPool
$PoolThread.run(BoundedThreadPool.java:442)
[java] Caused by:
org.datanucleus.exceptions.NoPersistenceInformationException: The
class "de.alteskind.appengine.jpa.Message" is required to be
persistable yet no Meta-Data/Annotations can be found for this class.
Please check that the Meta-Data/annotations is defined in a valid file
location.
[java] at
org.datanucleus.ObjectManagerImpl.assertClassPersistable
(ObjectManagerImpl.java:3894)
[java] at
org.datanucleus.jpa.EntityManagerImpl.assertEntity
(EntityManagerImpl.java:884)
[java] ... 45 more
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" 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-appengine-java?hl=en.