problem mapping entities on android project #27

Open
marcosbeirigo opened this Issue Aug 31, 2011 · 20 comments

Comments

Projects
None yet
7 participants
@marcosbeirigo

I don't know if this is the right place for this...
I'm trying to create a simple android project using orman but can't get my entities mapped.
I have all my entities under the "br.com.jera.shoplist.model" package and when i try to start the session i get this error:

org.orman.mapper.exception.AnnotatedClassNotFoundInPackageException: Could not find any entity marked class in "br.com.jera.shoplist.model"

Before anybody asks, all my entities have the @entity annotation.
I'm using this in my activty to start the session:

//database
Database db = new SQLiteAndroid(getApplicationContext(), "shoplist.db");
MappingSession.getConfiguration().setCreationPolicy(SchemaCreationPolicy.CREATE);
MappingSession.registerPackage("br.com.jera.shoplist.model");
MappingSession.registerDatabase(db);
MappingSession.start();

Any idea? am I missing something?

@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Aug 31, 2011

Owner

I'm not sure what's going on right now. There may be several problems regarding this issue, let's work on it:

  1. Your package name might not be exactly that one. Please make hundred percent sure.
  2. Your package might not be loaded since it might not be in your classpath.
  3. Our system might have bugs. Can you please download latest build from here and try again please.

If none of the above solves your problem, can you simplify your source code and send us your environment so that we can debug? If you want to debug it yourself, clone project to your computer and then include in your classpath and add breakpoints to PackageEntityInspector.java.

It is very unlikely that this problem is Android-specific, I think.

Owner

ahmetb commented Aug 31, 2011

I'm not sure what's going on right now. There may be several problems regarding this issue, let's work on it:

  1. Your package name might not be exactly that one. Please make hundred percent sure.
  2. Your package might not be loaded since it might not be in your classpath.
  3. Our system might have bugs. Can you please download latest build from here and try again please.

If none of the above solves your problem, can you simplify your source code and send us your environment so that we can debug? If you want to debug it yourself, clone project to your computer and then include in your classpath and add breakpoints to PackageEntityInspector.java.

It is very unlikely that this problem is Android-specific, I think.

@ghost ghost assigned 0ffffffffh Aug 31, 2011

@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Aug 31, 2011

Owner

I've created a new project now it couldn't find packages automatically or detect classes by specifying package name.

The whole thing is broken for some reason now. @0ffffffffh can you investigate please?

Owner

ahmetb commented Aug 31, 2011

I've created a new project now it couldn't find packages automatically or detect classes by specifying package name.

The whole thing is broken for some reason now. @0ffffffffh can you investigate please?

@marcosbeirigo

This comment has been minimized.

Show comment Hide comment
@marcosbeirigo

marcosbeirigo Aug 31, 2011

It seems broken, i built the jar from source but the problem persists.
I'd recomend creating tags for stable releases so one can use it if something goes wrong on master branch.
This might be useful:
I tried to use MappingSession.registerEntity(MyClass.class) and got the following error:


E/AndroidRuntime(25103): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(25103): java.lang.NoSuchMethodError: java.util.LinkedList.descendingIterator
E/AndroidRuntime(25103):    at org.orman.mapper.EntityDependencyGraph.getDestroySchedule(EntityDependencyGraph.java:186)
E/AndroidRuntime(25103):    at org.orman.mapper.MappingSession.constructSchema(MappingSession.java:432)
E/AndroidRuntime(25103):    at org.orman.mapper.MappingSession.startNoCheck(MappingSession.java:316)
E/AndroidRuntime(25103):    at org.orman.mapper.MappingSession.start(MappingSession.java:237)

It seems broken, i built the jar from source but the problem persists.
I'd recomend creating tags for stable releases so one can use it if something goes wrong on master branch.
This might be useful:
I tried to use MappingSession.registerEntity(MyClass.class) and got the following error:


E/AndroidRuntime(25103): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(25103): java.lang.NoSuchMethodError: java.util.LinkedList.descendingIterator
E/AndroidRuntime(25103):    at org.orman.mapper.EntityDependencyGraph.getDestroySchedule(EntityDependencyGraph.java:186)
E/AndroidRuntime(25103):    at org.orman.mapper.MappingSession.constructSchema(MappingSession.java:432)
E/AndroidRuntime(25103):    at org.orman.mapper.MappingSession.startNoCheck(MappingSession.java:316)
E/AndroidRuntime(25103):    at org.orman.mapper.MappingSession.start(MappingSession.java:237)
@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Aug 31, 2011

Owner

It looks like there's a problem with Android SDK in this issue, it is different than entity search process (it creates dependency graph to create entities in correct order, that's when the error occurs).

http://developer.android.com/reference/java/util/LinkedList.html#descendingIterator() says that this method is implemented. That's totally weird.

Owner

ahmetb commented Aug 31, 2011

It looks like there's a problem with Android SDK in this issue, it is different than entity search process (it creates dependency graph to create entities in correct order, that's when the error occurs).

http://developer.android.com/reference/java/util/LinkedList.html#descendingIterator() says that this method is implemented. That's totally weird.

@ghost ghost assigned ahmetb and 0ffffffffh Aug 31, 2011

@JakeWharton

This comment has been minimized.

Show comment Hide comment
@JakeWharton

JakeWharton Aug 31, 2011

Since API 9 only, however. What version are you running it on?

Since API 9 only, however. What version are you running it on?

@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Aug 31, 2011

Owner

@JakeWharton oops I missed that part (under jetlag) and just focused to LinkedList exists since API 1. We shouldn't rely on that and create our own iterator.

@marcosbeirigo, thanks for noticing this bug.

Owner

ahmetb commented Aug 31, 2011

@JakeWharton oops I missed that part (under jetlag) and just focused to LinkedList exists since API 1. We shouldn't rely on that and create our own iterator.

@marcosbeirigo, thanks for noticing this bug.

@marcosbeirigo

This comment has been minimized.

Show comment Hide comment
@marcosbeirigo

marcosbeirigo Aug 31, 2011

What's the MinSDK version to run orman on android? Couldn't find it on the wiki...

What's the MinSDK version to run orman on android? Couldn't find it on the wiki...

@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Aug 31, 2011

Owner

Since it is written in pure Java SE, we didn't even checked for what's min version actually. That exception was really a surprise for me. It should throw compilation error before you create APK since the method does not exist, but apparently it doesn't.

I'm fixing it right now. It should work on API≥3.

Owner

ahmetb commented Aug 31, 2011

Since it is written in pure Java SE, we didn't even checked for what's min version actually. That exception was really a surprise for me. It should throw compilation error before you create APK since the method does not exist, but apparently it doesn't.

I'm fixing it right now. It should work on API≥3.

@JakeWharton

This comment has been minimized.

Show comment Hide comment
@JakeWharton

JakeWharton Aug 31, 2011

It will only produce an error if you compile against the lowest API level you support. Most apps compile against higher API levels even though they support older ones.

It will only produce an error if you compile against the lowest API level you support. Most apps compile against higher API levels even though they support older ones.

@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Aug 31, 2011

Owner

I didn't know that. NoSuchMethodError exception is fixed with 239de3a. You can now clone and rake.

Owner

ahmetb commented Aug 31, 2011

I didn't know that. NoSuchMethodError exception is fixed with 239de3a. You can now clone and rake.

@0ffffffffh

This comment has been minimized.

Show comment Hide comment
@0ffffffffh

0ffffffffh Sep 1, 2011

Collaborator

@marcosbeirigo, i will investigate this issue. thanks for bug report.

Collaborator

0ffffffffh commented Sep 1, 2011

@marcosbeirigo, i will investigate this issue. thanks for bug report.

@almozavr

This comment has been minimized.

Show comment Hide comment
@almozavr

almozavr Sep 15, 2011

Have another problem with mapping on Android:
Occurs: when trying to register db
Error: ERROR/AndroidRuntime(14805): Caused by: org.orman.mapper.exception.AnnotatedClassNotFoundInPackageException: Could not find any entity marked class in 'dalvik'

When I map entities by hand everything works fine:
MappingSession.registerEntity(Sample.class);

I'm using last library built from git clone rep, built by rake.

Have another problem with mapping on Android:
Occurs: when trying to register db
Error: ERROR/AndroidRuntime(14805): Caused by: org.orman.mapper.exception.AnnotatedClassNotFoundInPackageException: Could not find any entity marked class in 'dalvik'

When I map entities by hand everything works fine:
MappingSession.registerEntity(Sample.class);

I'm using last library built from git clone rep, built by rake.

@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Sep 15, 2011

Owner

@0ffffffffh is working on it already. It is a dalvik vm classloading policy issue. He'll push his work when he's done with it. thanks for your patience.

Owner

ahmetb commented Sep 15, 2011

@0ffffffffh is working on it already. It is a dalvik vm classloading policy issue. He'll push his work when he's done with it. thanks for your patience.

@almozavr

This comment has been minimized.

Show comment Hide comment
@almozavr

almozavr Sep 15, 2011

Thanks for your work, guys! When it would be critical bugs free, it would be awesome framework for Android.

Thanks for your work, guys! When it would be critical bugs free, it would be awesome framework for Android.

@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Sep 27, 2011

Owner

Is there any update on merging the development branch with master that this bug is fixed @0ffffffffh? Thanks.

Owner

ahmetb commented Sep 27, 2011

Is there any update on merging the development branch with master that this bug is fixed @0ffffffffh? Thanks.

@0ffffffffh

This comment has been minimized.

Show comment Hide comment
@0ffffffffh

0ffffffffh Sep 30, 2011

Collaborator

yes. I will commit an update soon. Currently, I'm developing an eclipse plugin. Of course, that is related with this issue. (You can see at https://github.com/0ffffffffh/OrmanEclipseDevPlugin). Dalvik classloader issue is a stringent problem to resolve. I'm still working on it.

Collaborator

0ffffffffh commented Sep 30, 2011

yes. I will commit an update soon. Currently, I'm developing an eclipse plugin. Of course, that is related with this issue. (You can see at https://github.com/0ffffffffh/OrmanEclipseDevPlugin). Dalvik classloader issue is a stringent problem to resolve. I'm still working on it.

@Antpachon

This comment has been minimized.

Show comment Hide comment
@Antpachon

Antpachon Oct 11, 2011

Same issue @0ffffffffh here. Waiting for the update.

Same issue @0ffffffffh here. Waiting for the update.

@ragunathjawahar

This comment has been minimized.

Show comment Hide comment
@ragunathjawahar

ragunathjawahar Nov 25, 2011

I had the same issue, while registering packages and when searching automatically for entities. Registering the entities one by one seems to work.

Database db = new SQLiteAndroid(getApplicationContext(), "mydatabase.db");
MappingSession.getConfiguration().setCreationPolicy(SchemaCreationPolicy.CREATE_IF_NOT_EXISTS);
MappingSession.registerEntity(MyEntity.class); //Works
MappingSession.registerPackage("my.package.name"); //Doesn't work
MappingSession.registerDatabase(db);
MappingSession.start();

I had the same issue, while registering packages and when searching automatically for entities. Registering the entities one by one seems to work.

Database db = new SQLiteAndroid(getApplicationContext(), "mydatabase.db");
MappingSession.getConfiguration().setCreationPolicy(SchemaCreationPolicy.CREATE_IF_NOT_EXISTS);
MappingSession.registerEntity(MyEntity.class); //Works
MappingSession.registerPackage("my.package.name"); //Doesn't work
MappingSession.registerDatabase(db);
MappingSession.start();
@ahmetb

This comment has been minimized.

Show comment Hide comment
@ahmetb

ahmetb Nov 25, 2011

Owner

@ragunathjawahar we are aware of the issue. Unfortunately classloading mechanism is kind of different in Dalvik VM than JVM. Therefore we are having issues, @0ffffffffh is working on it. Until that time, try to use //Works line if it is not a big deal.

Owner

ahmetb commented Nov 25, 2011

@ragunathjawahar we are aware of the issue. Unfortunately classloading mechanism is kind of different in Dalvik VM than JVM. Therefore we are having issues, @0ffffffffh is working on it. Until that time, try to use //Works line if it is not a big deal.

@ragunathjawahar

This comment has been minimized.

Show comment Hide comment
@ragunathjawahar

ragunathjawahar Nov 25, 2011

@ahmetalpbalkan, anyways great job, I'll keep following orman closely.

@ahmetalpbalkan, anyways great job, I'll keep following orman closely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment