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

Certificate not found #1

Open
dlorch opened this issue Jul 3, 2012 · 1 comment
Open

Certificate not found #1

dlorch opened this issue Jul 3, 2012 · 1 comment

Comments

@dlorch
Copy link

dlorch commented Jul 3, 2012

Error

    Ambiguous method overloading for method com.notnoop.apns.ApnsServiceBuilder#withCert. Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between: [class java.io.InputStream, class java.lang.String] [class java.lang.String, class java.lang.String]

    Around line 24 of ApnsFactoryBean.groovy
    21:    Object getObject() {
    22:        def apnsService = APNS.newService()
    23:        if(certificateResourcePath){
    24:            apnsService = apnsService.withCert(this.getClass().getResourceAsStream(certificateResourcePath), password)
    25:        } else if(pathToCertificate){
    26:            apnsService = apnsService.withCert(pathToCertificate, password)
    27:        } else {

Solution

Adding getClassLoader() to the following line in org/epseelon/grails/apns/ApnsFactoryBean.groovy solved the problem for me:

    if(certificateResourcePath){
        apnsService = apnsService.withCert(this.getClass().getClassLoader().getResourceAsStream(certificateResourcePath), password)
    } else if(pathToCertificate){
    ...

My Configuration

File apns-dev.p12 in src/java, the following lines in Config

 environments {
     development {
         apns {
                         certificateResourcePath = "apns-dev.p12"
                         password = "secret"
             environment = "sandbox"
         }
     }
     test {
         apns {
                         pathToCertificate = "apns-dev.p12"
                         password = "secret"
             environment = "sandbox"
         }
     }

     production {
         apns {
                         pathToCertificate = "apns-dev.p12"
                         password = "secret"
             environment = "production"
         }
     }
 }

My Setup

$ grails --version
Grails version: 2.0.4

$ java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

@robinpercy
Copy link
Contributor

Another workaround for this is just to preface your paths with a /. Eg, pathToCertificate = "/apns-dev.p12"

robinpercy added a commit to robinpercy/grails-apns that referenced this issue Aug 22, 2012
Updated README to avoid Issue sarbogast#1 (Certificate not found)
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

2 participants