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

Question: PropertiesManager #75

Closed
Coinhunter opened this issue Apr 10, 2014 · 24 comments
Closed

Question: PropertiesManager #75

Coinhunter opened this issue Apr 10, 2014 · 24 comments

Comments

@Coinhunter
Copy link

First, I'd like to say that this is likely more of a problem with gradle than it is owner, but since this is an issue that's likely to crop up for many projects wishing to utilize this lib I thought I'd post it anyway, and perhaps someone else will do some additional digging. So... I'm having problems using owner in a project because it seems not all of the beans get transitively added to the apk that I am building. The setup is of a multi-module type in android studio, because the android and java plugins for gradle don't quite get along, and the owner code resides in a pure java library.

  java.lang.NoClassDefFoundError: java.beans.PropertyEditorManager
        at org.aeonbits.owner.Converters$4.tryConvert(Converters.java:147)
        at org.aeonbits.owner.Converters.doConvert(Converters.java:227)
        at org.aeonbits.owner.Converters.convert(Converters.java:222)
        at org.aeonbits.owner.PropertiesInvocationHandler.resolveProperty(PropertiesInvocationHandler.java:83)
        at org.aeonbits.owner.PropertiesInvocationHandler.invoke(PropertiesInvocationHandler.java:54)
        at $Proxy2.local_server_url(Native Method)
        at se.springworks.api.client.M2HClient.<init>(M2HClient.java:40)
        at se.springworks.apiexample.androidexampleapp.ExampleActivity.onCreate(ExampleActivity.java:18)
        at android.app.Activity.performCreate(Activity.java:5426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
        at android.app.ActivityThread.access$900(ActivityThread.java:161)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5356)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
        at dalvik.system.NativeStart.main(Native Method)

The module that contains owner directly is free from this issue. What are your recommendations?

Also created a Stack Overflow q for this type of problem:

http://stackoverflow.com/questions/22988376/missing-runtime-dependencies-with-owner-gradle-for-android

If you feel this is completely removed from what you're trying to do here, don't hesitate to close the issue. : )

@lviggiano
Copy link
Collaborator

From my understanding, this happens because Android is missing most of the classes in java.beans package in its runtime environment (see for example java.beans package on JDK5).

Afaik, at the moment this can't be solved unless I reimplement those classes inside OWNER itself, or I find some library working with android that does the same job.

Thanks for opening the question on stackoverflow, I'll monitor that answer and see if someone comes with a suggestion about this.

I can definitely fix OWNER to work on android: a solution to this issue should not be difficult to implement, if there is something already available or if I can find a quick way to port the few java.beans classes used inside OWNER itself and package in an optional dependency (like owner-android-support.jar)

@lviggiano
Copy link
Collaborator

I'll try to come out with a quick solution asap, and provide you a fixed jar so you can test it on android/gradle and tell me if this is fixed.

@Coinhunter
Copy link
Author

Oh I see, well that explains it. Yeah that would be awesome. 👍 : )

@lviggiano
Copy link
Collaborator

Would you be available to help me testing OWNER on android?

After fixing this issue, I can't exclude that some other issue can show up, since - afaik - nobody yet tried to use OWNER on android. So, if I can count on some help (also just for testing) from an android guy, I can for sure make OWNER android-compatible, I think.

@lviggiano lviggiano added the bug label Apr 10, 2014
@lviggiano lviggiano added this to the 1.0.6 milestone Apr 10, 2014
@lviggiano lviggiano self-assigned this Apr 10, 2014
@Coinhunter
Copy link
Author

First, I should let you know that I'm not an "Android-guy" per se. I've been involved in a couple of projects but it's not my forte.

In this case I'm using it in a pure java library that Android then depends on, so I'll only find issues that are proximate. This might mean that I would miss things that would be issues if used directly in an Android project. I will say this though, I like what I've seen so far and will probably attempt to use it again when I find myself in need of configuration (which is likely to be soon). So no promises, but I'll likely be able to tell you when it breaks, and we do test our code. : )

@lviggiano
Copy link
Collaborator

No worries. You have already been very helpful.

Now I'm planning to set up some environment to test android compatibility, and offer full fledged support for android. The problem is always time shortage to do all the things I would like to do.

But this issue should be easy to fix.

@Coinhunter
Copy link
Author

Will you let me know when there's a version out that solves this? : )

@lviggiano
Copy link
Collaborator

Of course!

Thank you.

@lviggiano
Copy link
Collaborator

Can you please try the following jar and see if it works on your android project?

owner-1.0.6-20140414.143515-4.jar

@Coinhunter
Copy link
Author

I will try it sometime during the day. : )

@Coinhunter
Copy link
Author

Alas! Does not seem to work. I tried running it with just the jar you attached and got this:

  java.lang.NoClassDefFoundError: se.springworks.api.client.ServerConfig
        at se.springworks.api.client.M2HClient.<init>(M2HClient.java:53)
        at se.springworks.apiexample.androidexampleapp.ExampleActivity.onCreate(ExampleActivity.java:22)
        at android.app.Activity.performCreate(Activity.java:5426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
        at android.app.ActivityThread.access$900(ActivityThread.java:161)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5356)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
        at dalvik.system.NativeStart.main(Native Method)

When I added in the gradle repository as a dependency aswell this happend:

  java.lang.NoClassDefFoundError: java.beans.PropertyEditorManager
        at org.aeonbits.owner.Converters$4.tryConvert(Converters.java:147)
        at org.aeonbits.owner.Converters.doConvert(Converters.java:227)
        at org.aeonbits.owner.Converters.convert(Converters.java:222)
        at org.aeonbits.owner.PropertiesInvocationHandler.resolveProperty(PropertiesInvocationHandler.java:83)
        at org.aeonbits.owner.PropertiesInvocationHandler.invoke(PropertiesInvocationHandler.java:54)
        at $Proxy2.local_server_url(Native Method)
        at se.springworks.api.client.M2HClient.<init>(M2HClient.java:54)
        at se.springworks.apiexample.androidexampleapp.ExampleActivity.onCreate(ExampleActivity.java:22)
        at android.app.Activity.performCreate(Activity.java:5426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
        at android.app.ActivityThread.access$900(ActivityThread.java:161)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5356)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
        at dalvik.system.NativeStart.main(Native Method)

So it seems.. well. Not quite there yet! :D Unless I am doing something wrong on my end.

@lviggiano
Copy link
Collaborator

@Coinhunter from the above Stacktrace, I think you are still picking the old jar:
Converters.java:147 does not contains executable code with the latest jar.

@Coinhunter
Copy link
Author

:O Strange. I will check again. Note that the second error message was generated while using both your new .jar file and the gradle dependency from mavenCentral, since only including the jar causes the first crash in the above post. ServerConfig (the one it can't find - extends Config ofc.)

@Coinhunter
Copy link
Author

It looks like I'm using the right jar. For the first error atleast. The second is probably using the old one, as you said.

@lviggiano
Copy link
Collaborator

For my understanding, the first error is saying that the JVM doesn't find se.springworks.api.client.ServerConfig. There may be something wrong in how your classpath is built.

@Coinhunter
Copy link
Author

Well, it's possible but I doubt it. It finds my other classes from the same package and submodule just fine, so I believe that the problem lies with attempting to reach the extension of that class. The reason I think this is that I have an alternate constructor for my API client with arguments instead of the owner cfg.userId() or similar and using that one works fine.

  cfg = ConfigFactory.create(ServerConfig.class);

Is where things go wrong a.t.m. so perhaps this isn't getting sent along for some reason, but I can't fathom why that would be. What is your setup? Are you using gradle to build?

EDIT: Actually, I will make sure I'm not wasting your time by asking someone around here to rubber-duck me just to make sure I'm not insane.

@Coinhunter
Copy link
Author

Okay. The problem I am having has to do with gradle not adding all of the transitive dependencies. More specifically the problem is that it doesn't seem to bundle the compiled classes from dependencies of other submodules.

I created an Android project and tried to use owner in that and so far it works fine for default values but it doesn't pick up the properties from ServerConfig.properties. Looking into it.

EDIT: Here's a repo-link to my example without working .properties file: https://github.com/Coinhunter/OwnerAndroidExample

@Coinhunter
Copy link
Author

Actually, this is also pretty good info:

I/dalvikvm﹕ Failed resolving Lse/springworks/api/client/ServerConfig; interface 1557 'Lorg/aeonbits/owner/Config;'
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp W/dalvikvm﹕ Link of class 'Lse/springworks/api/client/ServerConfig;' failed
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp I/dalvikvm﹕ Failed resolving Lse/springworks/api/client/ServerConfig; interface 1557 'Lorg/aeonbits/owner/Config;'
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp W/dalvikvm﹕ Link of class 'Lse/springworks/api/client/ServerConfig;' failed
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp E/dalvikvm﹕ Could not find class 'se.springworks.api.client.ServerConfig', referenced from method se.springworks.api.client.M2HClient.<init>
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp W/dalvikvm﹕ VFY: unable to resolve const-class 1729 (Lse/springworks/api/client/ServerConfig;) in Lse/springworks/api/client/M2HClient;
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp D/dalvikvm﹕ VFY: replacing opcode 0x1c at 0x000c
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp I/dalvikvm﹕ Failed resolving Lse/springworks/api/client/ServerConfig; interface 1557 'Lorg/aeonbits/owner/Config;'
04-15 14:39:19.785  12079-12079/se.springworks.apiexample.androidexampleapp W/dalvikvm﹕ Link of class 'Lse/springworks/api/client/ServerConfig;' failed

EDIT: http://stackoverflow.com/questions/23084678/gradle-submodule-has-unresolvable-dependencies

@lviggiano
Copy link
Collaborator

Unfortunately I know very little about android development and nothing about gradle.

My plan is to create an android test project to run all the existing junit tests using the android-sdk instead of the jdk.

Can't help you with gradle.

@lviggiano
Copy link
Collaborator

Do you have any news about this? Did you manage to make it work, or is the issue still open?

@Coinhunter
Copy link
Author

Should still be open. Havn't solved it yet. Not working on it actively a.t.m. :O

@lviggiano
Copy link
Collaborator

👍

@vbauer
Copy link

vbauer commented Sep 15, 2014

👍

@lviggiano
Copy link
Collaborator

@vbauer do you have any news or information about this issue?

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

No branches or pull requests

3 participants