• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Strange Spring Exception in web service

 
Bartender
Posts: 1672
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a (mostly) working Apache Tika implementation in a SpringBoot service.

From the third-party application, I pass the binary PDF file content first wrapped by a Base64Encode function, then wrapped again by a URLEncode function (just to be sure...) to the service (then decode both steps in the service to get the PDF binary file back after this transmission). Once I have the binary file re-constructed in the service, I then extract the text content and return it as the service's Response using the Tika library.

However, I found a "problem" PDF that gives me an odd Spring message. (Extracting the PDF in standalone Tika works fine.)

The error is a 400. Bad Request. "org.springframework.http.converter.HttpMessageNotReadableException".

I tried to set a break-point right in the first line of code in the controller but the 400 problem happens before that.

The Charles HTTP Proxy reports a "broken pipe".

Again, most files, including PDFs work fine, so I'm baffled what's going on with this one. This particular "problem" PDF does have lots of symbols, equations, and graphs, but it works standalone so I'm not sure what to try next.

I did upgrade SpringBoot to 1.5.15.RELEASE, but that made no difference.

Would appreciate any suggestions.

Thanks,

- mike
 
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you able to upgrade to Spring Boot 2.0.x? Maybe this will get you better/different results.
I think that, without too many modifications many Spring Boot 1.5 apps can be migrated to Spring Boot 2.0.

Are you aware that the Spring Boot 1.x now has an EOL of August 2019 as noted here https://spring.io/blog/2018/07/30/spring-boot-1-x-eol-aug-1st-2019?
 
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your problem happens after you encode it and send it to the endpoint?  That would mean the problem is happening when you are preparing it to be sent to the endpoint, or that the endpoint is lacking in some way.  I doubt that upgrading to spring 2 would change anything.
 
Al Hobbs
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If making a change to your spring is the solution, then it's probably adding a converter or looking into that area, because that's where the exception is.
 
Mike London
Bartender
Posts: 1672
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies!

As I mentioned, most of the PDFs work fine in Springboot. The Apache Tika framework is the "converter". The PDF binary data comes encoded as text so Spring shouldn't be coughing up a hairball on this Request.

Additionally, as I didn't mention initially, the exact same logic but using Spark Java REST framework works perfectly.

Thus, it's not the encoding.

I tried to upgrade to SpringBoot 2.0.4.RELEASE this morning, but my project would no longer build. I'll work on that and see if that helps.

This problem seems to be possibly related to the size of the request as the same thing happens with a huge text file (Spring only).

Thanks,

-- Mike
 
Mike London
Bartender
Posts: 1672
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PROBLEM SOLVED!

Turns out I had a redundant Content-Type as URL Encoded.

Since I was already URLEncoding the Base64Encoded file, this extra Request header made some files not extract correctly.

Working fine on SpringBoot 2.0.4 now also.

Thanks again to all.

- mike
 
Al Hobbs
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good job
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where was this URLEncoding redundant? Can you give an example?
I have a similar problem currently.
The problem exists when I try to do a parameterized GET

currently tried using 1.4.0 parent pom org.springframework.boot in a maven eclipse project using sts (eclipse 4.8) 3.9.5
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!