Why SpringMVC Request method 'GET' not supported?

I trying @RequestMapping(value = "/test", method = RequestMethod.POST) but is error Code is @Controller public class HelloWordController { private Logger logger =...

@Autowired and @Service working from controller but not from a different package

I need help understanding the concept behind @Autowired and @Service. I have a DAO defined with @Service and controller with @Autowired and everything seems fine, however, I use the same...

Integration Testing POSTing an entire object to Spring MVC controller

Is there a way to pass an entire form object on mock request when integration testing a spring mvc web app? All I can find is to pass each field separately as a param like...

Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]

I am using spring3, hibernate4, and maven3 and my this code gives me this error: Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform] <?xml version="1.0"...

Could not instantiate bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]

I have the following code: package com.transcend.txn; public class JpaTxnMain { public static void main(String[] args) { JpaAccountDao.addAccount(); } } package...

Setting Precedence of Multiple @ControllerAdvice @ExceptionHandlers

I have multipler classes annotated with @ControllerAdvice, each with an @ExceptionHandler method in. One handles Exception with the intention that if no more specific handler is found, this should...

Spring MVC Multipart Request with JSON

I want to post a file with some JSON data using Spring MVC. So I've developed a rest service as @RequestMapping(value = "/servicegenerator/wsdl", method = RequestMethod.POST,consumes = {...

spring autowire not working No qualifying bean of type Injection of autowired dependencies failed;

This error appears whenever I try to run my code. I looked all over google for an answer for the past week but my class project is due soon and I need some assistance. I have @service and...

TransactionRequiredException Executing an update/delete query

Hi I am using hibernate JPA with spring and mongodb and i am running my application on Glassfish-4.0. My service class is : @Component public class Test { @PersistenceContext EntityManager...

Org.Hibernate.AnnotationException: No Identifier Specified For Entity I don't have a id in my table

I'm working with a table in a database and that table don't have a primary key or a proper column whith a unique value who can act as a primary key, I don't have permissions to alter that...

Spring RestTemplate Post getting 500 internal server error

Hi I'm new to Spring framework.I have written app which post object to RESTAPI using Resttemplate but i am getting this error 23:07:05.856 [main] DEBUG o.s.web.client.RestTemplate - Created POST...

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NumberFormatException: null

Im trying to do full text search with spring data mongodb with all attributes of my model. this the model: @Document public class Offre { @Id private String id; @TextIndexed private String...

Spring Security hasRole() not working

I'm facing a problem when using Spring Security && Thymeleaf, specifically when trying to use the hasRole expression. The 'admin' user has a role 'ADMIN' but hasRole('ADMIN') resolves to false...

How to change port number for tomcat server using maven

I am writing a Rest service using spring mvc framework and maven. I am using tomcat server for now. My pom for the project is <?xml version="1.0" encoding="UTF-8"?> <project...

How to configure Spring Security to allow Swagger URL to be accessed without authentication

My project has Spring Security. Main issue: Not able to access swagger URL at http://localhost:8080/api/v2/api-docs. It says Missing or invalid Authorization header. Screenshot of the browser...

java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation

I am getting following error on console when I run the server: Error creating bean with name org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMa pping#0': Invocation...

How to upload a file and JSON data in Postman?

I am using Spring MVC and this is my method: /** * Upload single file using Spring Controller. */ @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) public @ResponseBody...

Request header field is not allowed by Access-Control-Allow-Headers in preflight response

I am using angularjs2 in frontend & Java Spring as backend rest api & getting the error. XMLHttpRequest cannot load 'Some url'. Request header field appkey is not allowed by...

Hibernate is not creating tables with H2 in memory database

I'm trying to test an application which uses SpringMVC and Hibernate with MySQL. I tried using HSQLDB but since the syntax is not the same as MySQL the queries may not work, so I decided to go to...

Serialize model without relation

I have two models: @Entity class ModelA { ... @OneToMany(mappedBy = "modelA") @JsonManagedReference private List<ModelB> modelBs = new ArrayList<ModelB>(); ... } @Entity class ModelB { ...

Spring security configure access

I am configuring endpoint access in Spring Security. What I want to accomplish: Everyone has access to resources Everyone can login/register Only authenticated users can access logout and all...

Multiple ObjectMappers for different parts of API

Currently I have a @Bean configuration in my Spring Boot App like that: @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); ...

Spring Mvc Java Could not resolve view with name 'home' in servlet with name 'dispatcher'

I have problem with my first app. I try to solve this for several hours. Any idea?? HTTP Status 500 – Internal Server Error Type Exception Report Message Could not resolve view with name 'home'...

Read Error Message with HttpURLConnection send by Spring

I have a Spring-MVC controller using Json request parameters. If the validation of this parameter fails, I want to send a custom error message. Therefore, I added this ExceptionHandler to my...

Spring Boot Hello World Example Not working

I have downloaded spring boot example from https://start.spring.io/. I tried many times but i get same error again and again: Exception in thread "main" java.lang.NoClassDefFoundError:...

How to hide a JsonProperty in the DTO?

I am using a DTO for both the insertion of an object and for the search that returns the data. in particular, I was interested to understand if there is a way to hide some fields: private List...

Where can I find a minimal spring boot boilerplate web app with backend and frontend?

I want a barebone template project for a webapp implemented using spring boot (frontend + backend APIs - DB) I referred this VS Code's doc for working with Java. It worked fine but it is not a...

Spring Boot 2.5.x: Required request part 'file' is not present

I have a file uploading api which was working perfectly fine under the spring boot version 2.1.13. After upgrading the version to 2.5.2, it started to throw an exception. Looking at the...

Hello! Got an error with Junit platform v.5.8.1 java.lang.NoSuchMethodError: org.junit.platform.commons.util.AnnotationUtils.findAnnotation

I run into an issue with this code: @ExtendWith(MockitoExtension.class) class ApiRestControllerTest { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private MockMvc...

How to make a Spring Boot application quit on tomcat failure

We have a bunch of microservices based on Spring Boot 2.5.4 also including spring-kafka:2.7.6 and spring-boot-actuator:2.5.4. All the services use Tomcat as servlet container and graceful shutdown...