How do you create the contextKey? Is this a value you define yourself before
persisting the BizContext?

I'm no expert on this, but the
documentation<http://code.google.com/appengine/docs/java/datastore/jdo/creatinggettinganddeletingdata.html>
specifies
two use cases for keys as String:

    @PrimaryKey
    private String name;

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String encodedKey;


There is no @Persistant in the first case. Maybe this has something to do
with your issue?

Cheers,
-- 
Sébastien Tromp


2011/7/30 venkyvb <[email protected]>

> Hello:
> I have the following JDO entity class:
>
> *@PersistenceCapable(detachable = "false")*
> *public class BizContext implements Serializable{*
> *
> *
> * /***
> * * *
> * */*
> * private static final long serialVersionUID = -3573604788900579800L;*
> *
> *
> * @PrimaryKey*
> * @Persistent*
> * private String contextKey;*
> *
> *
> * @Persistent*
> * private String contextId;*
> *....*
> *.....*
>
> I have a logic where I am reading this entity based on the Id. The code
> snippet is as given below:
>
> *...*
> *
> *
> * if (contextKey != null) { *
> * result.setContext(pm.getObjectById(BizContext.class, contextKey));*
> * }*
> *
> *
> * return result;*
> *
> *
> However when I run this piece of code, I get the following exception:
>
> at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> Caused by: java.lang.IllegalArgumentException: name cannot be null or empty
> at
> com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:70)
> at
> com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:57)
> at
> org.datanucleus.store.appengine.EntityUtils.stringToInternalKey(EntityUtils.java:301)
> at
> org.datanucleus.store.appengine.EntityUtils.idToInternalKey(EntityUtils.java:136)
> at
> org.datanucleus.store.appengine.EntityUtils.idToInternalKey(EntityUtils.java:126)
> at
> org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager.getObjectById(DatastoreJDOPersistenceManager.java:63)
> at
> com.samuuhanet.main.server.service.ContextServiceImpl.getContextDetailsLocal(ContextServiceImpl.java:135)
> at
> com.samuuhanet.main.server.service.ContextServiceImpl.getContextDetails(ContextServiceImpl.java:36)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
> at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
> ... 34 more
>
> Any ideas as to what could be the cause of this exception ?
> Thanks a lot.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/72B1nSeM2CYJ.
> 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?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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?hl=en.

Reply via email to