“error”:“Unsupported Media Type”,“exception”:“org.springframework.web.HttpMediaTypeNotSupportedException”

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



“error”:“Unsupported Media Type”,“exception”:“org.springframework.web.HttpMediaTypeNotSupportedException”



I am using spring boot 1.3.0. I want to create a rest endpoint which procduces content of type "application/hal+json".



I am getting an "Unsupported Media Type" exception. Is this mediatype in not supported in spring boot 1.3.0



Can anyone let me know in which spring boot version it is supported?



I am using Gradle.
@RequestMapping(value = Array("/grouping"), consumes = Array(MediaType.APPLICATION_JSON_VALUE), produces = Array(MediaType.APPLICATION_JSON_VALUE, "application/hal+json"), method = Array(RequestMethod.GET, RequestMethod.DELETE)) def processGroupingGetDelRequest(request: HttpServletRequest): ResponseEntity[Object] =



My Gradle file
dependencies
// This is the path to where fortify is installed on the Jenkins machine. To run local swap the lines.
fortify fileTree(dir: '/opt/HP_Fortify/HP_Fortify_SCA_and_Apps_4.21/Core/lib', include: '.jar')
//fortify fileTree(dir: 'C:/Program Files/HP_Fortify/HP_Fortify_SCA_and_Apps_4.21/Core/lib/', include: '
.jar')


compile group: 'org.springframework', name: 'spring-mock', version: '2.0.8'
compile group: 'org.scala-lang', name: 'scala-library', version: '2.11.7'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.3.3.RELEASE'

/* the following pulls in: spring-orm, hibernate-entity-manager, spring-data-jpa: */
compile('org.springframework.boot:spring-boot-starter-data-jpa:1.3.0.RELEASE')
exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'

compile('com.zaxxer:HikariCP:2.6.1')
exclude group: 'org.hibernate', module: 'hibernate-core'



/* the following pulls in: spring-jdbc, spring-tx, tomcat-jdbc: */
/* See: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html */
/* You need a dependency on spring-jdbc for an embedded database to be auto-configured. */
/* It�s pulled in transitively via spring-boot-starter-data-jpa. */
// compile group: 'org.springframework.boot', name:'spring-boot-starter-jdbc'

compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.3.0.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version: '1.3.0.RELEASE'
compile group: 'org.springframework', name: 'spring-jms', version: '4.2.3.RELEASE'

compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.8.6'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-scala_2.11', version: '2.8.6'


compile group: 'org.glassfish.jersey.core', name: 'jersey-common', version: '2.22.1'
compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.22.1'
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: '2.22.1'
compile group: 'org.glassfish.jersey.bundles.repackaged', name: 'jersey-guava', version: '2.22.1'

compile group: 'org.springframework.security', name: 'spring-security-ldap', version: '4.2.1.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-core', version: '4.2.1.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '4.2.1.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-web', version: '4.2.1.RELEASE'

compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version:'2.8.6'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-jaxb-annotations', version: '2.8.6'
compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-base', version:'2.8.6'
compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version:'2.8.6'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-paranamer', version: '2.8.6'

// compile group: 'org.hibernate', name: 'hibernate-jpamodelgen'

// https://mvnrepository.com/artifact/com.typesafe.play/play-json_2.11
compile group: 'com.typesafe.play', name: 'play-json_2.11', version: '2.3.10'

providedCompile group: 'com.h2database', name: 'h2', version: '1.4.196'
providedCompile group: 'org.apache.activemq', name: 'activemq-broker', version: '5.12.1'


providedRuntime group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '1.3.0.RELEASE'

//Note: Un-comment if in Development the tomcat dependencies are not resolved during the spring boot runs
//providedRuntime group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '8.5.11'

scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:1.1.1', 'org.scoverage:scalac-scoverage-runtime_2.11:1.1.1'

testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'org.scalatest', name: 'scalatest_2.11', version: '2+'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
testCompile group: 'org.springframework', name: 'spring-test', version:'4.2.3.RELEASE'


testRuntime 'org.pegdown:pegdown:1.1.0'





My Controller class



@RequestMapping(value = Array("/grouping"), consumes = Array(MediaType.APPLICATION_JSON_VALUE), produces = Array(MediaType.APPLICATION_JSON_VALUE, "application/hal+json"), method = Array(RequestMethod.GET, RequestMethod.DELETE))
def processGroupingGetDelRequest(request: HttpServletRequest): ResponseEntity[Object] =


val requestDetails = extractRequestInformation(request)

val response = Service.processGroupingRequest(requestDetails.uri, requestDetails.httpMethod, requestDetails.queryParameters, "")
new ResponseEntity[Object](response, HttpStatus.OK)







Please post your whole code also pom.xml
– Avijit Barua
Aug 8 at 14:47


pom.xml





Can you post your controller class please ?
– Avijit Barua
Aug 8 at 14:58









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard