0

i have a file locate in web-app in my grails project.. in the config file for some apns plugin in put the config as the following

    environments {
    development {
        apns {
            pathToCertificate = "web-app/apns-dev.p12"
            password = "password"
            environment = "sandbox"
        }
    }
    test {
        apns {
            pathToCertificate = "web-app/apns-dev.p12"
            password = "password"
            environment = "sandbox"
        }
    }

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

the reason i put the p12 of production without "web-app" is because i've noticed that the file located on production under the root directrly but it give me fileNotFoundException.. so how can i locate it?

Mohamed Emad Hegab
  • 2,665
  • 6
  • 39
  • 64

2 Answers2

1

The apns plugin page states

If you don't have access to your server's file system, you can also replace pathToCertificate by certificateResourcePath and set it to the path of your certificate, relative to src/java. So for example, if your certificate is in src/java/mycert.p12, you can set certificateResourcePath=mycert.p12.

This is probably your best bet, allowing you to use paths relative to src/java rather than absolute paths.

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
0

Here's a (slighty hacky) way to get the file's absolute path:

First, put the files on the classpath somewhere (e.g. a "resources" directory inside the conf directory). Then, change your pathToCertificate line to:

pathToCertificate = ApplicationHolder.application.parentContext.getResource("classpath:resources/apns-dev.p12").file.absolutePath

which should resolve to the absolute path for that file on your file system.

nickdos
  • 8,348
  • 5
  • 30
  • 47
  • well it gives me error on compile | Error Error packaging application: Error loading Config.groovy: No signature of method: groovy.util.ConfigObject.getResource() is applicable for argument types: (java.lang.String) values: [classpath:web-app/WEB-INF/apns-dev.p12] – Mohamed Emad Hegab Sep 21 '12 at 07:22