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 with java.xml.bind.DatatypeConverter #18

Closed
rhyscoronado opened this issue Mar 11, 2015 · 22 comments
Closed

Problem with java.xml.bind.DatatypeConverter #18

rhyscoronado opened this issue Mar 11, 2015 · 22 comments

Comments

@rhyscoronado
Copy link

Hi, I'm having issue with using this on android, the following fatal exception occurs:

java.lang.NoClassDefFoundError: javax.xml.bind.DatatypeConverter
at io.jsonwebtoken.impl.Base64Codec.encode(Base64Codec.java:24)

and found out Android doesn't support javax.xml.bind.DatatypeConverter.

Any possible fix for this? Thanks.

@lhazlewood
Copy link
Contributor

Does Android have a Base64 encoder/decoder that can be plugged in?

@lhazlewood
Copy link
Contributor

In other words, DatatypeConverter is available out-of-the-box on standard JVMs. If Android JVMs do not have this, is there an alternative that you might recommend?

@rhyscoronado
Copy link
Author

Hey, thanks for the prompt reply, I'm not sure honestly, but android uses some kind of android.util.Base64, would you be able to plug that in as an alternate to the java class causing the error?

Thanks again,

@rhyscoronado
Copy link
Author

@abrodersen
Copy link

I'm seeing this problem as well. I think the Base64 class is what is needed. There probably needs to be either an interface or a run-time detection mechanism for switching to the Android implementation.

@abrodersen
Copy link

Also, here's a public domain implementation that you could include in the library.

@lhazlewood
Copy link
Contributor

Is this the only thing required to make it work on Android? Or will there be more work necessary?

@rhyscoronado
Copy link
Author

I believe that's all that's needed to make it work on Android

lhazlewood added a commit that referenced this issue Apr 4, 2015
…onments. This still needs to be tested in a real Android project.
@lhazlewood
Copy link
Contributor

I just added a quick fix for this in the android branch. Can someone please build and test this out on an Android project and let me know how it goes?

You should just be able to:

  1. git clone https://github.com/jwtk/jjwt.git
  2. git checkout android
  3. mvn clean install
  4. change your android project dependency to:
dependencies {
    compile 'io.jsonwebtoken:jjwt:0.5-SNAPSHOT'
}

(and don't forget to ensure that your local disk maven repo is enabled in your android build config):

repositories {
    mavenLocal()
    mavenCentral()
}

If someone can confirm this works on Android (both JWT building and parsing), I can cut a follow up 0.5 release that can be used on both standard JVMs and Android :)

@lhazlewood
Copy link
Contributor

@rhyscoronado @abrodersen ^^

@rhyscoronado
Copy link
Author

@lhazlewood awesome, thanks for this, will provide you feedback as soon as I'm able to test it.

@lhazlewood
Copy link
Contributor

@rhyscoronado sounds good - thanks!

@lhazlewood
Copy link
Contributor

Just curious - has anyone been able to try this fix out on Android yet?

@lhazlewood
Copy link
Contributor

@rhyscoronado @abrodersen ^^

@lhazlewood
Copy link
Contributor

@rhyscoronado or @abrodersen can you please confirm if this works or not? I want to release 0.5 and would like this in if it works. Thanks.

@rhyscoronado
Copy link
Author

hI @lhazlewood apologies for the late testing, I managed to generate from the device, but there are warning messages.

04-29 17:43:35.284 13254-13254/com.nelsoft.easyshop I/dalvikvm﹕ Could not find method javax.xml.bind.DatatypeConverter.parseBase64Binary, referenced from method io.jsonwebtoken.impl.Base64Codec.decode
04-29 17:43:35.284 13254-13254/com.nelsoft.easyshop W/dalvikvm﹕ VFY: unable to resolve static method 50228: Ljavax/xml/bind/DatatypeConverter;.parseBase64Binary (Ljava/lang/String;)[B
04-29 17:43:35.284 13254-13254/com.nelsoft.easyshop I/dalvikvm﹕ Could not find method javax.xml.bind.DatatypeConverter.printBase64Binary, referenced from method io.jsonwebtoken.impl.Base64Codec.encode
04-29 17:43:35.284 13254-13254/com.nelsoft.easyshop W/dalvikvm﹕ VFY: unable to resolve static method 50229: Ljavax/xml/bind/DatatypeConverter;.printBase64Binary ([B)Ljava/lang/String;
04-29 17:43:35.335 13254-13254/com.nelsoft.easyshop I/jwt:﹕ eyJhbGciOiJIUzUxMiJ9.eyJjbGllbnRfaWQiOiJtb2JpbGUiLCJkZXZpY2VUb2tlbiI6IiIsImFwaV90eXBlIjoiYW5kcm9pZCJ9.F9QiFjtDxqFm-TXM8hom8RBHWIKenY_E1lE5IaWxwbiUCsijjD7TqxYZMhM-lzS-q9HdC6oG9d_Vdk6dL5wHjA

I don't know if it's affecting something, but it's working now. Thanks! :)

@lhazlewood
Copy link
Contributor

Let me try to fix that - should be quick.

@lhazlewood
Copy link
Contributor

@rhyscoronado I just pushed a change to the android branch - can you please try again and let me know if the warnings are gone?

lhazlewood added a commit that referenced this issue Apr 29, 2015
…perty check. This is to ensure that, during tests, the stub android .jar isn't used since it is in the classpath.
@lhazlewood
Copy link
Contributor

Had to make one more change - if the CI build passes, we should test this latest one.

@lhazlewood
Copy link
Contributor

The CI build tested fine - @rhyscoronado if you can confirm this latest change, I can cut the release.

@lhazlewood
Copy link
Contributor

@rhyscoronado I'd like to release today if you can confirm if this works.

lhazlewood added a commit that referenced this issue May 9, 2015
…wn class. Created a factory that can return either depending on environment. Ensured all code other than the lang package is at 100% test coverage.
@lhazlewood
Copy link
Contributor

Since I've received no confirmation from the parties in this thread, I'm releasing the fix implemented in PR #29, now merged in master and I believe to work. Any other concerns can be raised in a new issue.

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

No branches or pull requests

3 participants