braintree / braintree_java

Braintree Java library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
158 stars 97 forks source link

Null Pointer Exception for existing user in sandbox #7

Closed ChristopherBiscardi closed 11 years ago

ChristopherBiscardi commented 11 years ago

I'm getting this error when trying to retrieve an existing user from the sandbox.

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.NullPointerException
    at com.braintreegateway.CreditCard.getPayroll(CreditCard.java:299)
    ...

with this Clojure code:

(def gateway (new BraintreeGateway Environment/SANDBOX
    "xxx"
    "xxx"
    "xxx"))
(defpage [:post "/btreeuser"] {:keys [userid securitytag]}
  (if
    (and
      (not
        (nil? userid))
      (= "xxx" securitytag))
    (try
      (let [user (from-java
        (.. gateway customer (find userid)))]
      (response/json {:success true
                                :user user}))
      (catch com.braintreegateway.exceptions.NotFoundException e
        (response/json {:success false
                                  :msg "Not Found"})))
   (response/json {:success false})))

I'm 99% sure I haven't changed any relevant code since the last time it worked. I'm using noir (defpage) if that matters and the exception catches successfully if the user doesn't exist. Using lib v2.18.0

ChristopherBiscardi commented 11 years ago

Wiped all systems data and the issue went away. Still not sure what was causing it though.