Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem mapping entities on android project #27

Open
beirigo opened this issue Aug 31, 2011 · 20 comments
Open

problem mapping entities on android project #27

beirigo opened this issue Aug 31, 2011 · 20 comments
Assignees
Labels

Comments

@beirigo
Copy link

beirigo commented Aug 31, 2011

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
Copy link
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
Copy link
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?

@beirigo
Copy link
Author

beirigo commented 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)

@ahmetb
Copy link
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
Copy link

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

@ahmetb
Copy link
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.

@beirigo
Copy link
Author

beirigo commented Aug 31, 2011

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

@ahmetb
Copy link
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
Copy link

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
Copy link
Owner

ahmetb commented Aug 31, 2011

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

@0ffffffffh
Copy link
Collaborator

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

@almozavr
Copy link

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
Copy link
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
Copy link

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

@ahmetb
Copy link
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
Copy link
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.

@Antpachon
Copy link

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

@ragunathjawahar
Copy link

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
Copy link
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
Copy link

@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
Labels
Projects
None yet
Development

No branches or pull requests

7 participants