[appengine-java] Creating a key for retrieval, but the key id is zero (IllegalArgumentException)

2010-02-16 Thread Clint

I'm not sure what I'm doing wrong here.

I'm persisting an object with a key created using a unique string, in
this case the user id.  However, to make things more URI friendly, I'm
using the Key.getId() of these objects to serve as a unique id (uid).

The first entity I save has key.getId() == 0.  When I later attempt to
recover this entity, using a Key created by KeyFactory:

// Key ID for the object being retrieved is 0.
AuthorDO.uidToKey("0");

public static Key uidToKey(String uid) {
long keyId = Long.parseLong(uid);
return KeyFactory.createKey(AuthorDO.class.getSimpleName(),
keyId);
}

I get an illegal argument exception:

java.lang.IllegalArgumentException: id cannot be zero
at
com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:
44
at
com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:
31)
at com.sageek.quotebook.data.dao.jdo.AuthorDO.uidToKey(AuthorDO.java:
214)

The id is 0, according to the key that was created by the datastore.
Where is this error coming from?  What am I doing wrong?

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Compile and execute at runtime

2009-09-12 Thread Clint

I'm having a similar issue when using the Janino compiler in Drools,
(after I patched Drools' use of unauthorized class loader behavior,
that is).  I'd like to understand better how to patch Janino?

On Aug 31, 11:08 am, Toby Reyelts  wrote:
> Thanks for filing the issue. As it stands right now, you won't be able to
> load any classes from javax.tools, regardless of whether your intent is or
> is not to write to the file system. If you want to implement the javax.tools
> API, you'll need to use a different package (e.g. my.javax.tools.*). Another
> possibility is that you can patch janino's
> ReflectionIClass.getDeclaredIClasses2 to work without reflection. You should
> be able to get access to the declared classes just by looking at the class
> files corresponding to a class.
>
> On Sat, Aug 29, 2009 at 9:17 AM, Albert Attard wrote:
>
> > Hey Toby:
>
> > Hope you had a nice weekend.
>
> > Just did: issue 
> > 2042
> > What other option do I have? Is it possible to include a library (a jar
> > file) similar to janino which makes use of the *javax.tools* but does not
> > write to the file system? All persistence happens to the datastore similar
> > to the: gaevfs . I was thinking of
> > writing a small API using the *javax.tools* and expose an interface. Then
> > will use this interface to compile and execute code at runtime.
>
> > Possible?
> > Albert Attard
>
> > Stephen 
> > Leacock - 
> > "I detest life-insurance agents: they always argue that I shall some day
> > die, which is not so."
>
> > 2009/8/29 Toby Reyelts 
>
> > Hey Albert,
>
> >> I've tracked this down to an oversight on our part. Mind filing an issue?
>
> >> On Fri, Aug 28, 2009 at 3:06 AM, Albert Attard 
> >> wrote:
>
> >>> Hey Toby:
> >>> Thanks for your input.
>
> >>> Following is the stack trace for the other problem I was talking about.
> >>> Locally Janino compiles this without any issues, but it's throwing the
> >>> following exception when executed on the app-engine.
>
> >>> JaninoJavaAssessorHelper compile: THROW
> >>> java.security.AccessControlException: access denied 
> >>> (java.lang.RuntimePermission accessDeclaredMembers)
> >>>    at java.security.AccessControlContext.checkPermission(Unknown Source)
> >>>    at java.security.AccessController.checkPermission(Unknown Source)
> >>>    at java.lang.SecurityManager.checkPermission(Unknown Source)
> >>>    at java.lang.SecurityManager.checkMemberAccess(Unknown Source)
> >>>    at java.lang.Class.checkMemberAccess(Unknown Source)
> >>>    at java.lang.Class.getDeclaredClasses(Unknown Source)
> >>>    at 
> >>> org.codehaus.janino.ReflectionIClass.getDeclaredIClasses2(ReflectionIClass.java:101)
> >>>    at org.codehaus.janino.IClass.getDeclaredIClasses(IClass.java:252)
> >>>    at org.codehaus.janino.IClass.findMemberType(IClass.java:617)
> >>>    at org.codehaus.janino.IClass.findMemberType(IClass.java:634)
> >>>    at org.codehaus.janino.IClass.findMemberType(IClass.java:604)
> >>>    at 
> >>> org.codehaus.janino.UnitCompiler.findMemberType(UnitCompiler.java:8011)
> >>>    at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:4022)
> >>>    at org.codehaus.janino.UnitCompiler.access$102(UnitCompiler.java:3990)
> >>>    at 
> >>> org.codehaus.janino.UnitCompiler$16.visitReferenceType(UnitCompiler.java:3936)
> >>>    at org.codehaus.janino.Java$ReferenceType.accept(Java.java:1868)
> >>>    at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:3969)
> >>>    at org.codehaus.janino.UnitCompiler.access$136(UnitCompiler.java:3927)
> >>>    at 
> >>> org.codehaus.janino.UnitCompiler$31.getParameterTypes(UnitCompiler.java:6674)
> >>>    at org.codehaus.janino.IClass$IMethod.getDescriptor(IClass.java:762)
> >>>    at org.codehaus.janino.IClass.getIMethods(IClass.java:180)
> >>>    at org.codehaus.janino.IClass.getIMethods(IClass.java:169)
> >>>    at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:328)
> >>>    at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:313)
> >>>    at 
> >>> org.codehaus.janino.UnitCompiler$3.visitPackageMemberClassDeclaration(UnitCompiler.java:286)
> >>>    at 
> >>> org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:701)
> >>>    at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:292)
> >>>    at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:270)
> >>>    at 
> >>> org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:423)
> >>>    at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:231)
> >>>    at org.codehaus.janino.Cookable.cook(Cookable.java:72)
> >>>    at org.codehaus.janino.Cookable.cook(Cookable.java:64)
> >>>    at org.codehaus.janino.Cookable.cook(Cookable.java:114)
> >>>    at 
> >>> com.albertattard.askme.server.utils.JaninoJavaAssessorHelper.compile(JaninoJavaAssess

[appengine-java] Incompatible object argument for function call ?

2009-09-12 Thread Clint

I'm getting an exception using the MVEL2 library, but only in
production... any ideas how to resolve this?  I'd love to set --
noverify, but that's not really an option, right?

Nested in javax.servlet.ServletException: init:
java.lang.VerifyError: (class: org/mvel2/optimizers/dynamic/
DynamicClassLoader, method: defineClassX signature: (Ljava/lang/String;
[BII)Ljava/lang/Class;) Incompatible object argument for function call
at org.mvel2.optimizers.dynamic.DynamicOptimizer._init
(DynamicOptimizer.java:46)
at org.mvel2.optimizers.dynamic.DynamicOptimizer.init
(DynamicOptimizer.java:42)
at org.mvel2.optimizers.OptimizerFactory.setDefaultOptimizer
(OptimizerFactory.java:106)
at org.mvel2.optimizers.OptimizerFactory.
(OptimizerFactory.java:64)

--~--~-~--~~~---~--~~
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 google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---