Here is a piece of code I wrote to implement itunes_verification.
http://gist.github.com/raw/622038/b32accd30e86f7c714f2cffefd19857f558c8d97/gistfile1.rb
ItunesVerification.verify_apple_receipt("wefwfrw")
But, its always throwing {"exception"=>"java.lang.NullPointerException", "status"=>21002} from the itunes server.
#<HTTParty::Response:0x46d59a8 #parsed_response={"exception"=>"java.lang.NullPointerException", "status"=>21002}, #response=#<Net::HTTPOK 200 Apple WebObjects readbody=true>, #headers={"x-webobjects-loadaverage"=>["0"], "x-apple-application-site"=>["SB"], "expires"=>["Thu, 14 Oct 2010 04:24:12 GMT"], "connection"=>["keep-alive"], "edge-control"=>["no-store", "max-age=0"], "pod"=>["100"], "date"=>["Thu, 14 Oct 2010 04:24:12 GMT"], "x-apple-max-age"=>["0"], "x-apple-application-instance"=>["1000407"], "x-apple-woa-inbound-url"=>["/WebObjects/MZFinance.woa/wa/verifyReceipt?output=json&receipt-data=d2Vmd2U%3D%0A"], "content-length"=>["62"], "set-cookie"=>["Pod=100; version=\"1\"; expires=Sun, 14-Nov-2010 05:24:12 GMT; path=/; domain=.apple.com", "mzf_in=1000407; version=\"1\"; path=/WebObjects; domain=.apple.com"], "x-apple-lokamai-no-cache"=>["true"], "cache-control"=>["no-transform", "private", "no-cache", "no-store", "must-revalidate", "max-age=0"], "pragma"=>["no-cache"]}>
Also, the string I pass is encoded to Base64.
I have tried other options like changing the key from "body" to "query".
This is very urgent and any help will be greatly appreciated.
Thanks
There already is a similar problem posted, check it out here, perhaps the suggestions there can help you.
Related
I have such model for saving:
#Table("EXPERIMENTS")
data class Experiment(
#Id val id: Long,
val userId: Long,
val time: String,
#JsonProperty
val data: Any
)
such saving processor:
#PostMapping("/experiment")
fun saveUserExperiment(#RequestBody experiment: Experiment) = service.saveExperiment(experiment)
such service:
#Service
class ExperimentService(val db: ExperimentRepository) {
fun saveExperiment(experiment: Experiment) = db.save(experiment)
...
}
and I save it via postman in such way:
POST /experiment HTTP/1.1
Content-Type: application/json
User-Agent: PostmanRuntime/7.29.2
Accept: */*
Postman-Token: 1c2aaf40-8933-4988-b92a-6694539c3aba
Host: localhost:8080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 105
{
"userId":1,
"time": "2018-10-18 05:30:57.907",
"data": {"red":123,"blue":123,"green":123}
}
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Date: Sat, 30 Jul 2022 15:57:55 GMT
Keep-Alive: timeout=60
Connection: keep-alive
{"id":7,"userId":1,"time":"2018-10-18 05:30:57.907","data":{"red":123,"blue":123,"green":123}}
during saving I receive such error:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/Users/_t/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.3.2/152489ed8223a6ad19065a3cd1ee6b9e20c0b82f/spring-core-5.3.2.jar) to field java.util.LinkedHashMap.head
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
and also after fetching the list of models I receive such error:
Parameter specified as non-null is null: method com.example.demo.models.Experiment.<init>, parameter data
list I receive in such way:
#Query("select * from experiments")
fun getExperiments(): List<Experiment>
my database has such table:
experiments: table
+ columns
id: int NN auto_increment = 1
user_id: mediumtext NN
time: timestamp default CURRENT_TIMESTAMP
data: json
+ keys
#1: PK (id) (underlying index PRIMARY)
I'm not sure whether it is ok that I receive 200OK response from the api but json field is null even if I have it filled.
There are two different things going on here. First, the minor one:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/Users/_t/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.3.2/152489ed8223a6ad19065a3cd1ee6b9e20c0b82f/spring-core-5.3.2.jar) to field java.util.LinkedHashMap.head
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
As the prefix shows, this is a warning, not an error: it's not stopping your program from working (though, as it says, a later Java release might).
They cause is an incompatibility between the version of Spring you're using and the Java Module System that was introduced in Java 9, and is discussed in this question. One simple workaround might be to run it on Java 8.
The actual error is this one:
Parameter specified as non-null is null: method com.example.demo.models.Experiment.<init>, parameter data
That's about nullability. As you probably know, Kotlin distinguishes between references that could be null, and those that can't.
You've defined your JSON property as: val data: Any, and the Any type is non-nullable: Kotlin won't allow it to hold a null value. (To allow a null, you'd specify it as Any?, with a question mark.)
However, the Spring framework is based on Java, which doesn't make that distinction: all its references can potentially be null. And so there are some unfortunate corner cases which throw up unexpected nulls like this.
For some reason, your DB query is returning a null value for that field; when it tries to construct an instance of your Experiment class to hold the returned data, the Kotlin runtime spots the null and gives the error above. (It's not spotted at compile-time, unfortunately, because Spring works much of its magic at run-time.)
So there are two potential approaches to fixing it:
Prevent Spring returning null for that field. I don't think it's possible to guarantee this in all circumstances, as it might depend on what data can be in your database, as well as how the query is performed. (It's probably worth looking at your data and the query to understand why it's coming back as null, though.)
Specify the field as nullable (Any?), and handle the null case yourself. That would make your code very slightly less clean, but a lot safer and more robust.
I was working with a ruby script to push stats into a time series kairos db and encountered the 'Datetime' class in ruby.
My question is does DateTime.now differ from DateTime.now()?
And if it does, can I get an example of their outputs?
There is no difference between DateTime.now and DateTime.now(). Parentheses are optional in method calls in Ruby.
You can check some documentation about calling methods in Ruby here.
Example of both calls returning the exactly same result:
(local dev):0> DateTime.now
=> Thu, 14 May 2020 16:52:11 +0100
(local dev):0> DateTime.now()
=> Thu, 14 May 2020 16:52:15 +0100
No differences. They are the same method call. In Ruby, you can call any method with or without parentheses. And there's no "public fields" in Ruby, only public methods, so the only thing you can "dot" is methods.
I write an app with google app engine. It is a simple blog system. If I delete a piece of blog, the page didn't refresh as I wish. It still present the blog that has been deleted.But if I refresh the page after that, it will present in the correct way. I though it was the problem of cache. I have been working on it for serveral days. Could anyone teach me how to fix it? Thanks very much.
class BlogFront(BlogHandler):
def get(self):
val = self.request.get("newPost")
#get all the pages
posts = Post.all().order('-created')
#stop the cache in the browser
self.response.headers["Pragma"]="no-cache"
self.response.headers["Cache-Control"]="no-cache, no-store, must-revalidate, pre-check=0, post-check=0"
self.response.headers["Expires"]="Thu, 01 Dec 1994 16:00:00"
self.render('front.html', posts = posts)
def post(self):
#press the delete button
operatorRequest = self.request.get('Delete')
articleId = operatorRequest.split('|')[0]
operator = operatorRequest.split('|')[1]
key = db.Key.from_path('Post', int(articleId), parent=blog_key())
post = db.get(key)
db.delete(post.key())
self.redirect("/")
I assume redirect to / is handled by BlogFront handler. Seems you're hitting datastore eventual consistency.
Google App Engine Datastore: Dealing with eventual consistency
GAE: How long to wait for eventual consistency?
I have this js code where I am using the Mapstraction library to show GMap and use it's geocoder service via mapstraction as well.
I have recently started getting error 610 whenever I try to issue the geocode service call. The http code is 200 ok however the json returned is as follows:
_xdc_._8gxa9q7ci && _xdc_._8gxa9q7ci( {
"Status": {
"code": 610,
"request": "geocode"
}
})
Chromium's inspector shows the request string as follows:
output:json
oe:utf-8
q:nehru place, , delhi,110048, in
mapclient:jsapi
hl:en
callback:_xdc_._8gxa9q7ci
The issue remains even with a newly generated api key! The map loads just fine with the new key as well as the old key!
So if anyone has run into a similar issue with mapstraction then do let me know the workarounds if any.
Another thing that I have noticed is that my old key is 86 characters long whereas my new key is only 39 characters long. Any insights in this direction would be greatly appreciated. I have spent an entire day trying to get it to work again.
Update: I have noticed that with a key length of 86 characters, the request string has key: MYKEY param as well. Whereas with the 39 character long key, it's not there!
Mapstraction seems to require a 86 character api key to work properly with GMap API v2.
The 36 character API key is for v3 I guess.
If I goto the API console, the 86 character keys generated for my domains isn't shown there. However, the link to generate the 86 character api key is a bit hard to get.
Once generated, my calls to GMap's Geocoder via Mapstraction are working fine now.
Here's the link to generate the v2 API key
http://code.google.com/apis/maps/signup.html
Remember to scroll to the bottom of the page to fill in the correct url.
As for Mapstraction, I think the latest version should be able to use the new 36 character API key!
I am currently using #DateTimeFormat in a domain object as follows:
#DateTimeFormat(pattern = "MM/dd/yyyy")
private Date startDate = new Date();
In a Spring MVC Controller, I am posting today's date: 10/19/2011 using the jQuery UI Date picker, and I confirm that this is being sent as an HTTP Post parameter using firebug as follows:
startDate=10%2F19%2F2011
Unfortunately, once it gets to Spring on the server, it stores the date as 10/18/2011 - there is an off-by-one day error.
There is nothing in my code that even remotely touches the date - there is no calculations or anything going on with regards to this date.
Is there something about #DateTimeFormat that I should be aware of?
Could something in Hibernate be responsible for changing the date too?
I'm also looking at the my database for this application. I am storing another date, called creationDate which is an actual timestamp and differs from user input. In most cases, the dates are the same but the client wanted the ability to set it differently so that is what startDate is for.
Start Date Creation Date (actual timestamp, not user input)
2011-04-17 19:00:00 2011-04-17 21:32:27
2011-04-18 19:00:00 2011-04-18 21:14:01
2011-04-20 19:00:00 2011-04-20 23:06:47
2011-04-26 19:00:00 2011-04-26 23:24:34
2011-04-28 19:00:00 2011-04-28 20:07:06
2011-05-01 19:00:00 2011-05-02 13:35:37
2011-06-21 19:00:00 2011-06-22 15:06:36
2011-07-28 19:00:00 2011-07-29 15:32:35
2011-09-03 19:00:00 2011-09-04 13:11:45
2011-10-11 19:00:00 2011-10-12 11:45:14
2011-10-11 19:00:00 2011-10-12 11:49:55
2011-10-18 19:00:00 2011-10-19 02:20:43
At first it seems like it was a bug started in May, but then I realized that the date is correct if it was over 19:00:00, and it's off-by-one if it's under 19:00:00.
I hate Java :(
The problem seems to occur when Spring creates a date given 10/19/2011 - it seems to translate that user input and formats it to 2011-10-18 19:00:00.
What is the simplest solution?
Thanks
It seems very likely to me that this is actually a matter of time zones. A Date object represents an instant in time - I suspect if you look at the exact value that you've got (e.g. in UTC, to keep things clear) you'll get a better idea of what's going on. Chances are that where you're seeing "10/18/2011" you're interpreting it in a different time zone.
If Spring supports converting to Joda Time types I'd suggest using that instead - then you can use LocalDate which really does mean a date instead of an instant in time.
I've found that starting your JVM with your local timezone specified in the arguments solves this issue. For me it was just adding this line to the run configuration:
-Duser.timezone="Asia/Dhaka"