I have a Spring MVC application with a few REST interfaces exposed and is running on an Apache Tomcat instance.
I'm wondering if there are any ways to troubleshoot the data binding errors when trying to POST to an end point. So when I post some JSON I would like to find out why the data binding is failing (when Spring converts this to an object at the Controller). I might have to do some config changes to the apache server to increase the debugging level to show more info or increase the logging level in my application (log4j) to display any errors that Spring throws out. Wondering if anyone can help me find ways to debug databinding issues.
Here is the request/response log from the Chrome's dev console for the failed request. If I simplify the JSON structure, it does seem to bind but I'd like to find out which specific JSON attributes are causing the problem.
Request URL:http://localhost:8080/entryrive-service/user/6/entry/
Request Method:POST
Status Code:400 Bad Request
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:667
Content-Type:application/json;charset=UTF-8
Host:localhost:8080
Origin:http://localhost:8383
Referer:http://localhost:8383/entryrive-client/app/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Request Payloadview source
{id:null, title:Sprouts Farmers Market, entryDate:1388559600000, entryPayerId:[6], notes:test,…}
entryCreaterId: null
entryDate: 1388559600000
entryItemEntry: []
entryPayerId: [6]
entrySimpleEntry: {id:null, itemDescription:null, simpleUserIdAndLiableCost:[,…]}
entryTotal: "30"
groupId: 3
id: null
notes: "test"
title: "Sprouts Farmers Market"
userId: null
Response Headersview source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://localhost:8383
Connection:close
Content-Language:en
Content-Length:968
Content-Type:text/html;charset=utf-8
Date:Sun, 05 Jan 2014 19:50:05 GMT
Server:Apache-Coyote/1.1
Increasing the logging level of Spring framework did seem to show up what Spring has been upto
log4j.logger.org.springframework=ALL
Related
Background
I have created a PWA test project to find out how to get audio caching working with Workbox,
including scrub/seek using the range requests plugin.
I want the app to precache all audio and for this audio to be playable offline, including scrub/seek.
Pre-caching the audio can be done in one of two ways:
Using Workbox injectManifest.
By manually adding audio files to a cache using cache.add(URL)
But audio files cached with the first method (injectManifest) will not scrub/seek because the Workbox pre-cache does not
support range request headers. So you need to put a range request enabled router in front of the
pre-cache for audio files if you want to be able to scrub through/seek within a cached audio file.
Problem
Pre-cached audio with a range requests enabled router will play and scrub/seek fine in Chrome and Firefox when app is served
from localhost but fails to play in Chrome when served from Firebase.
I see the same error for all audio files that are pre-cached with a range requests router in front of them:
Router is responding to: /media/audio/auto-pre-cached.mp3
Using CacheOnly to respond to '/media/audio/auto-pre-cached.mp3'
No response found in the 'act-auto-pre-cache-wbv4.3.1-actv0.0.1' cache.
The FetchEvent for "https://daffinm-test.firebaseapp.com/media/audio/auto-pre-cached.mp3" resulted in a network error response: the promise was rejected.
CacheOnly.mjs:115 Uncaught (in promise) no-response: The strategy could not generate a response for 'https://daffinm-test.firebaseapp.com/media/audio/auto-pre-cached.mp3'.
at CacheOnly.makeRequest (https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-strategies.dev.js:343:15)
Chrome versions tried:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
The files are present in the Workbox caches. The only difference I can see between locahost and Firebase is in the cached response headers:
Localhost
cache-control: max-age=3600
content-length: 3770956
content-type: audio/mpeg; charset=utf-8
Date: Mon, 07 Oct 2019 09:37:03 GMT
etag: "12456134-3770956-"2019-09-29T20:05:00.314Z""
last-modified: Sun, 29 Sep 2019 20:05:00 GMT
server: ecstatic-2.2.2
Firebase
accept-ranges: bytes
cache-control: max-age=3600
content-encoding: gzip
content-length: 3686565
content-type: audio/mpeg
date: Mon, 07 Oct 2019 11:47:43 GMT
etag: 267d9ec42517198c01e2cad893f1b14662a2d91904bc517aeda244c30358457c
last-modified: Mon, 07 Oct 2019 03:48:25 PDT
status: 200
strict-transport-security: max-age=31556926; includeSubDomains; preload
vary: x-fh-requested-host, accept-encoding
x-cache: MISS
x-cache-hits: 0
x-served-by: cache-lhr7363-LHR
x-timer: S1570448862.315027,VS0,VE1472
Firefox works fine in both cases.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0
Code
You can find the code for the test app here including a full description of the test setup, expectations and results:
https://github.com/daffinm/audio-cache-test
And the app is currently deployed on Firebase here if you want to take a look:
https://daffinm-test.firebaseapp.com/
Question
Does anyone have any idea what's going on here and why the pre-cached audio with range request routers are failing to play in Chrome? Is this a Chrome bug and/or a Workbox mis-configuration and/or a Firebase configuration issue - or something completely different? (I have contacted Firebase support and they are being very helpful but are currently unable to enlighten me).
The presence of the Vary header in the Firebase responses sounds like the culprit. By default, the Cache Storage API will use the Vary header when determining whether or not there's a cache match. You can override this default behavior by passing in {ignoreVary: true} when querying the Cache Storage API. Workbox supports this as an option you can provide when creating your strategy, via the matchOptions parameter.
It looks like you're already passing in ignoreSearch: true, so you can just add ignoreVary: true alongside that.
I'm using postman and dreamfactory and I get the following error message, when I send a post request to create a record in a table. I'm using MySQL as my database. I believe it could be because I haven't set up my foreign key relationships properly. How can I go about setting this up?
Invalid schema detected - no type or db_type element.
Below is the request header
General
----
Remote Address:[::1]:8080
Request
URL:http://localhost:8080/api/v2/MySQL/_schema/kartadb.country/1
Request Method:POST
Status Code:500 Internal Server Error
Response Headers
view source
Access-Control-Allow-Origin:chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Cache-Control:no-cache
Connection:close
Content-Type:application/json
Date:Tue, 20 Oct 2015 08:17:33 GMT
Server:Apache
Transfer-Encoding:chunked
Vary:Origin
X-Frame-Options:SAMEORIGIN
X-Powered-By:PHP/5.5.29
Request Headers
----
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Authorization:Basic dGV3b2Ryb3Mud3JAZ21haWwuY29tOg==
Cache-Control:no-cache
Connection:keep-alive
Content-Length:92
Content-Type:text/plain;charset=UTF-8
Host:localhost:8080
Origin:chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Postman-Token:3f469a4f-f95a-eb1f-c5eb-8da94b110e47
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
X-DreamFactory-Api-Key:6498a8ad1beb9d84d63035c5d1120c007fad6de706734db9689f8996707e0f7d
X-DreamFactory-Session-Token:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjcsInVzZXJfaWQiOjcsImZvcmV2ZXIiOmZhbHNlLCJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA4MFwvYXBpXC92MlwvdXNlclwvc2Vzc2lvbiIsImlhdCI6IjE0NDUzMjY2OTQiLCJleHAiOiIxNDQ1MzMwMjk0IiwibmJmIjoiMTQ0NTMyNjY5NCIsImp0aSI6ImNlMDJiMWU1ZTRjZjc4MmZmYTYxZmYyZDM1MGNiODg2In0.F0UcNExumeAwLF-xM6SmgKktcPSprYrS7x95KFJmYI4
You mention creating a "record" in a table. The /_schema resource is for creating table schema, not records. Use the /_table resource for creating records.
I am using $http.get mthod to hit the mysql services to get the records of particulars table, even post and put is working fine. it fails on get method.
In request header we have like this
Provisional headers shown
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:accept, authorization
Access-Control-Request-Method:GET
Host:d.example.com
Origin:http://localhost
Referer:http://localhost/xxxx/
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
It shows "Provisional headers shown" error if this error happens it fails the api. can you give some suggestions where it goes wrong , actually i set all the headers in mysql services
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Accept: text/html,application/json,text/plain");
header("Content-Type: application/json");
I found a solutions ....
Actually am using two services one for mysql and other for micro service mongoDB
So the problem is passing authentication header for mysql , now i remove the header for mysql service calls and the problem solved.
using below code
$http.defaults.headers.common = {};
Which may help for others.
I am working on a JavaScript application, where I want to read data from an XML file and post them into a HTML file.
My code is producing the following error:
Request URL:http://myServer/dirs/dir/scripts/xml_data.xml
Request Method:POST
Status Code:405 Method Not Allowed
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en,en-US;q=0.8,da;q=0.6
Connection:keep-alive
Content-Length:13
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host:myServer
Origin:http://myServer
Referer:http://myServer/dirs/dir/inWork.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
node:xnode-24
Response Headersview source
Allow:GET, HEAD, OPTIONS, TRACE
Cache-Control:private
Content-Length:5309
Content-Type:text/html; charset=utf-8
Date:Thu, 12 Feb 2015 21:06:08 GMT
Server:Microsoft-IIS/8.0
X-Powered-By:ASP.NET
Based on this posting I created a new 'Handler Mapping' and I also adjusted the 'Handler Mapping' for 'StaticFile' to allow the methods: GET,HEAD,POST,DEBUG,PUT,DELETE.
The IIS server was restarted but still the error message appears and the only methods allowed are: GET, HEAD, OPTIONS, TRACE.
So, there is some configuration file or 'Handler Mapping' overriding my settings, or I simply did not consider.
Any suggestions on how to tell the IIS to accept my settings for this XMLHttpRequest?
I see quite a lot posts with regards to this topic but still can't find a solution for my case.
I want to leverage the caching of the images for our web site (hosted in IIS 7.5). I did configure the caching through "http response headers" menu in IIS management console and it works for images with "absolute" src like <img src="images/logo.png" alt="Logo"> but it doesn't work for images with JSON source e.g. <img alt="Image" src="http://myhost.com/site/Services/Service.svc/images/im0002/thumb" > that is set dynamically in the ajax callback.
Detailed request/response headers:
Request URL:http://myhost.com/site/Services/Service.svc/images/im0002/thumb
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:/
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:myhost
Referer:http://myhost/site/Default.aspx
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11
Response Headersview source
Content-Length:1392
Content-Type:image/jpeg
Date:Fri, 27 Jul 2012 07:37:25 GMT
Server:Microsoft-IIS/7.5
X-Powered-By:ASP.NET
Any information about how to fix that is highly appreciated.
Convert your image into Base64 or anything similar. It will be a string by then, no longer a url.