Questions tagged [spring-mvc]

14198 questions
1

votes
2

answer
2.4k

Views

AnnotationConfigRegistry not found in spring 4

I am having an strange behavior, using spring 4.1.1 I get this error. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project newvalia-view: Compilation failure [ERROR] /C:/Users/edu/IdeaProjects/newvalia/newvalia- view/src/main/java/co...
duardito
1

votes
1

answer
1k

Views

@SessionAttributes and @ResponseBody do not work together

I have created a very simple "test" controller that keeps a counter in session to print how many times a request handler is called. @Controller @SessionAttributes("counter") public class MyController { @ModelAttribute("counter") public Counter addCounter(){ System.out.println("Counter added to mode...
fdm
1

votes
1

answer
1.5k

Views

get response from spring oauth2 token request as xml

I am implementing a oauth2 rest server using spring 4 and spring oauth2. Response can be either xml or json as specifeid by the client request header. But am getting issues from oauth2 when ever I try to access the token it supports only JSON (application/json), its not supporting xml(application/xm...
Pranav
1

votes
1

answer
211

Views

Infinte loop when bad credentials are entered in spring security/form login

As much as I have been able to determine it gets into infinite loop only when following bean is enabled on my . If this bean is enabled WebSecurityConfigurerAdapter extended class. @Override @Bean(name = "MyAuthManager") public AuthenticationManager authenticationManagerBean() throws Exception { re...
user871199
1

votes
1

answer
2.1k

Views

Spring web flow how to add flash attribute when exiting from flow to external redirect

I'm new to Spring Web Flow (2.3.1) and this is what I'm trying to do: I have a JSP page which lists a paginated table of Books at the bottom of the page for the Author selected at the top of the page. I have a button/link at the top 'Add Book' (just below the Author drop-down) clicking which launche...
sv.
1

votes
2

answer
5.5k

Views

HTTP 405 Not Allowed - Spring Boot + Spring Security

I have a simple rest API which works with database. It worked properly until I added the security part. Now it gives HTTP 405 Not Allowed on the POST and DELETE requests. I have no idea why. The GET requests work properly. So here is the controller class: @Controller public class MarkerController {...
definera
1

votes
2

answer
6.1k

Views

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException… why?

I develop server using spring mvc and hibernate. So, I write my server program using Spring mvc and maven. However when I start my server program at tomcat server, Error occurs. That is things expected. so, I search using my error message. However I can't find answer. help me.... This is my servlet-...
Rect
1

votes
1

answer
1.9k

Views

Handling cross domain preflight AJAX OPTIONS requests with Spring MVC 4

This is probably a simple answer, but I can't seem to get it to work. In a cross-domain, preflight AJAX request, the client first makes an OPTIONS request just get a set of headers back to figure out what the remote server accepts. Right now, for every Spring controller POST interface that I create...
Bal
1

votes
1

answer
3.1k

Views

How to disable encoding using RestTemplate

I am using REST template to intentionally send a % in request uri, something like /items/a%b String responseEntity = restTemplate.exchange("/items/a%b", requestObj.getHttpMethod(), requestEntity, String.class); The restTemplate is converting the endoding of this uri and it is becoming /items/a%25b w...
tintin
1

votes
1

answer
4.2k

Views

Spring MockMvc test: Null pointer Exception

I'm following tutorials for integrating Spring docs into my project but i'm running into nullpointerexception when I run my test. The errors go away when I take out all the document bits. So when I remove restDocumentation variable, the document bit from the setup method and the test then it passes....
Qad
1

votes
2

answer
560

Views

How to remove extra field 'decoratedClass' in JSON response for Spring Data projections?

Hello I'm using Spring Data Projection to simplify original object 'Announcement'. I created interface with get-methods for field I need: public interface SimplifiedAnnouncement{ String getTitle(); Integer getPrice(); String getPlace(); } Then I just use it in Repository: public interface Announceme...
Kerins_Sataier
1

votes
1

answer
354

Views

spring mvc; contextConfigLocation load order

I'm reconfiguring a webapp. I want to move everything out of dispatcher servlet into ContextLoaderListener. (This is due to changes in security configuration beyond the scope of this question) Question 1, if I have multiple application context xml files, does it matter what order they are loaded? Fo...
Jake
0

votes
0

answer
7

Views

Remove Garbage characters from Request Body in Spring Boot?

I am making a server for a Chinese device whose firmware I cannot change by any means. It sends JSON data in request body to my server with headers-> content-type : [application/octet-stream]. Now getting the body in Spring boot has some garbage characters in the start and end of body. Body: � {...
Purujit Bansal
0

votes
0

answer
7

Views

can we create stand alone application for Spring boot web mvc using Electron tool?

I am trying to create a stand-alone application for spring boot. I have a code of spring boot mvc and I am trying to build a desktop application using Electron tool.
arpit_writes
1

votes
1

answer
329

Views

NoClassDefFoundError in the Spring Mvc form handler

I work with a small Spring Mvc project and I get an error in to the time of handling a POST request. The error message is provided below, HTTP Status 500 – Internal Server Error Type Exception Report Message An exception occurred processing JSP page [/WEB-INF/jsps/users/userform.jsp] at line [26]...
Arefe
1

votes
1

answer
1.3k

Views

spring boot - web mvc test does not find controller mapping

In this spring-boot project the following WebMvcTest fails because the GET /items mapping from the ItemController is not found @RunWith(SpringRunner.class) @WebMvcTest(ItemController.class) @AutoConfigureMockMvc public class Test_ItemController { @Autowired private MockMvc mvc; @MockBean private It...
tenticon
3

votes
1

answer
27

Views

Is the repo class thread safety for concurrent requests? - Spring boot

I'm using Spring boot with jetty embedded web server for one Web application. I want to be 100% sure that the repo class is thread safety. The repo class @Repository @Scope("prototype") public class RegistrationGroupRepositoryImpl implements RegistrationGroupRepository { private RegistrationGroup rg...
ROZZ
1

votes
3

answer
2.9k

Views

Should Service layer throw an exception?

I don't like throwing exceptions for some reason, maybe because of the performance hit I don't know, wondering if I should re-think this issue. Should my service layer (uses Dao's + business logic etc.) be throwing exceptions? public ModelAndView createProduct(@Valid ProductForm productForm, ..) { M...
loyalflow
-1

votes
0

answer
5

Views

How to insert foreign key in jsp form to store it in the datebase?

this is the error that is appeared, when i submit the form https://i.imgur.com/FxKw7Bl.jpg
22mando
1

votes
0

answer
7

Views

Does app server instance require restart, if we update DB

DB content/rows are updated. Does any appserver need a restart to reflect the rows in appserver instances.
Sreevenkatesh
0

votes
0

answer
6

Views

How to model relationship tables as entities in Hibernate

I'm new to using spring and hibernate. I want to design the database according to this Schema Student, Class and School are Entities. There exists relationships studies_in(between Student and Class - one to one, with student_id and class_id as foreign keys) and belongs_to(between Class and School -...
Harsha Sridhar
1

votes
2

answer
2.4k

Views

Spring Boot keycloak and basic authentication together in the same project

I have an issue with Spring Boot security. What I want is to have two different authentication for the same project at the same time in Spring Boot. The one is SSO (keycloak authentication) for all path except '/download/export/*' , the other one is Spring Boot basic authentication. Here is my conf...
gubak
1

votes
2

answer
7.3k

Views

Spring Boot 404 not found error

I am trying to run the spring boot application but getting the 404 not found error. Project structure: src/ +- main/ +- java/ | + com/ | + demo/ | SpringBootDemo.java | + controller/ | HomeController.java +- resources/ | application.yml src/ +- main/ +- webapp/ +- WEB-INF/ +- pages/ |...
Harshit Shrivastava
1

votes
1

answer
887

Views

How to get userinfo in springboot using keycloak?

I was able to get the username by using: @Autowired private HttpServletRequest request; Principal user = request.getUserPrincipal(); mqMessage.setUserName(user.getName()); But I want to get the firstName & lastName of the user logged in. How can i get the ff. userinfo using SpringBoot keycloak adapt...
LogronJ
1

votes
4

answer
7.1k

Views

Spring Boot Error: java.lang.NoClassDefFoundError: org/springframework/util/Assert

I am new to Spring Boot and following some video tutorials to get started. I created a Maven project, added a parent dependency of artifact id spring-boot-starter-parent, added dependency for spring-boot-starter-web and spring-boot-starter-test. This is the Application.java: @RestController @EnableA...
user182944
1

votes
1

answer
607

Views

Access a request scoped Bean in Service

I have a regular bean, which is either (a) @Scope("request") or (b) placed in a HttpServletRequest via Filter/ Interceptor. How to access this beans in a @Service which is kind of an application scoped singleton? The reason for this is, because I have a custom object RequestContext with some request...
kalamar
1

votes
2

answer
37

Views

Generate PDF Using Angularjs And RestController

I am created an rest API for generate the PDF file using itext API. Please help me out how to generate this and send to UI for download that PDF. Here I am Using Angularjs,SpringBoot and Mysql as DB. @RequestMapping(value = "/generateGeneralLedgerReportPdf", method = RequestMethod.GET) public void...
Trilochan Panda
0

votes
0

answer
5

Views

HTTP 404 ERROR-The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

I am new to spring_mvc and i am trying to build restful spi service using spring_mvc,hibernate and mysql.i have checked many sources but not able to know the error in my code.Please help me find the problem. i have shared the following files controller class: @Controller public class ViewController...
shridhar
1

votes
3

answer
13k

Views

Spring MVC default value not working

@RequestMapping(value = "/Fin_AddBankAccount", method = RequestMethod.POST) public @ResponseBody JsonResponse addCoaCategory( @RequestParam(value="code", required=true) long code, @RequestParam(value="startFrom", required=true) long startFrom, @RequestParam(value="name", required=true, defaultValue=...
Shahid Ghafoor
0

votes
0

answer
10

Views

Spring-mvc 5: How to load an externalized properties file using @PropertySource(“#{systemProperties[…]}”)

I’m working a rest api and the project structure is a maven multi modules project organized by layer (repository, service and so on) and my project will be hosted on wildfly 13. My working environment is windows 10 (64bits). I configured my repository module to load an externalized properties fil...
Manucci
1

votes
2

answer
6.8k

Views

Spring Validation: Requiring an exact length on an optional field

In Spring MVC, I'm attempting to use annotations to perform validation of form input. I have some fields that are optional, but when input is provided, it must meet certain criteria. For example, I have one field that can be left blank, but when it is filled in, the answer must be exactly five cha...
Marvo
0

votes
0

answer
4

Views

I want to design a cloudformation template for an existing application

Here I have three seperate dependant applications A,B ,C and D. MySQL db, A has two instances, B has 3 instances and C has 1 and D has 8. All these are connected to Terracota MAX server. Can you please help me in designing a cloudformation template.
Mohammed Fayis P
1

votes
1

answer
1.5k

Views

“Ambiguous mapping found” when one @Controller extends another @Controller

I have a ImportAction class which serves as a parent class for several type-specific import controllers, such as ImportClientsAction and ImportServicesAction. ImportAction is a Spring MVC annotated @Controller class and has @RequestMapping-annotated methods to pull up a menu of import options and en...
Martin Carney
1

votes
4

answer
8.8k

Views

nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl

public ModelAndView Details(@ModelAttribute("") @Validated App app, BindingResult result, @RequestParam(value="paramSessionAttr", required=false) String sessionAttr, @RequestParam("paramAction") @NotNull @NotEmpty String param_action){ ... } When I implement @NotNull @NotEmpty annotation validator i...
Txuver Jhi Wei
1

votes
4

answer
4.2k

Views

Spring @RestController

I have been trying to extend this Spring/Hibernate/JPA sample code on Github While I have got it working OK, I am trying to add a new @RestController to get a JSON listing of all shop objects. But my attempts have not been successful. The existing @Controller continues to work just fine, but by new...
NickJ
1

votes
1

answer
2.7k

Views

Spring Boot with Liferay

I'm playing with Spring Boot developing portlets to Liferay portal. I was able to create a portlet with a vanilla Spring setup (without Spring Boot), the project is available in https://github.com/tmoreira2020/spring-boot-liferay-portlet. When I add Spring Boot setup it stops to work. Basically what...
1

votes
3

answer
2.1k

Views

Where to put helper classes in spring mvc [closed]

I have a helper class that generates a pdf for my API request.I am new to spring (am using spring boot) ,I want to follow strict packaging structure . I am confused regarding :- 1.What package name should I use. eg:com.abx.myapp.helper? 2.What kind of naming convention should I follow for these help...
Abx
1

votes
3

answer
2.5k

Views

How to offer a file compressed as download via spring @RestController?

I have a servlet that offers a CSV file for download: @RestController @RequestMapping("/") public class FileController { @RequestMapping(value = "/export", method = RequestMethod.GET) public FileSystemResource getFile() { return new FileSystemResource("c:\file.csv"); } } This works just fine. Ques...
membersound
1

votes
1

answer
3.5k

Views

Spring ControllerAdvice and authentication/authorization exception handling

In my Spring Boot appliation I have a following web security config: @Configuration @EnableWebSecurity public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { @Override public void configure(HttpSecurity http) throws Exception { // @formatter:off http .headers().frameOptions(...
alexanoid
1

votes
1

answer
1.5k

Views

Spring, Java : Streaming file download for avoiding out of memory errors

I am working on a Spring-MVC application in which users are able to download files. The users can click on an attachment which triggers a download mechanism. Yesterday, when multiple downloads and two of which had approximately 2 GB files, it caused an out of memory error(log below). To avoid this...
We are Borg

View additional questions