Questions tagged [spring-3]

Version 3.x of the Spring Framework, use [tag:spring] for general Spring related questions.

Filter by
Sorted by
Tagged with
724 votes
15 answers
354k views

Difference between <context:annotation-config> and <context:component-scan>

I'm learning Spring 3 and I don't seem to grasp the functionality behind <context:annotation-config> and <context:component-scan>. From what I've read they seem to handle different ...
user938214097's user avatar
352 votes
3 answers
468k views

Understanding Spring @Autowired usage

I am reading the spring 3.0.x reference documentation to understand Spring Autowired annotation: 3.9.2 @Autowired and @Inject I am not able to understand the below examples. Do we need to do ...
NewQueries's user avatar
  • 4,881
224 votes
6 answers
401k views

When use ResponseEntity<T> and @RestController for Spring RESTful applications

I am working with Spring Framework 4.0.7, together with MVC and Rest I can work in peace with: @Controller ResponseEntity<T> For example: @Controller @RequestMapping("/person") @Profile("...
Manuel Jordan's user avatar
157 votes
3 answers
159k views

What's the difference between <mvc:annotation-driven /> and <context:annotation-config /> in servlet?

I am migrating from Spring 2.5 to Spring 3. They have introduced <mvc:annotation-driven /> which does some black magic. This is expected to be declared in servlet configuration file only. In ...
glaz666's user avatar
  • 8,707
123 votes
7 answers
113k views

How to get a method's annotation value from a ProceedingJoinPoint?

I have below annotation. MyAnnotation.java @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnnotation { } SomeAspect.java public class SomeAspect{ @Around("...
user755806's user avatar
  • 6,733
67 votes
2 answers
90k views

How to register Spring @Configuration annotated class instead of applicationContext.xml file in web.xml?

I am using jsf and spring together in web application. I have configured datasource and session factory in one configuration class which uses annotations like @Configuration, @ComponentScan etc. I don'...
Mital Pritmani's user avatar
59 votes
5 answers
143k views

How to set 'Content-Disposition' and 'Filename' when using FileSystemResource to force a file download file?

What is the most appropriate, and standard, way to set the Content-Disposition=attachment and filename=xyz.zip using Spring 3 FileSystemResource? The action looks like : @ResponseBody @...
Hassan Jamil's user avatar
  • 1,270
57 votes
6 answers
43k views

Add attributes to the model of all controllers in Spring 3

Every single view in my Spring 3 app has a set of attributes they can rely on. So the first line of every controller is something like: ControllerHelper.addDefaultModel(model, personManager, request)...
at.'s user avatar
  • 51.9k
56 votes
2 answers
46k views

When use AbstractAnnotationConfigDispatcherServletInitializer and WebApplicationInitializer?

I am working with Spring 4.0.7 I did a research about configure Spring MVC through JavaConfig. Practically until yesterday I have seen two configurations using these two options extends ...
Manuel Jordan's user avatar
56 votes
12 answers
72k views

Encoded slash (%2F) with Spring RequestMapping path param gives HTTP 400

This is not a duplicate referenced question, because it is Spring specific. Whoever added that (3 years after the fact!) didn't bother to read the question or comment thread to see what the real ...
Jim's user avatar
  • 3,556
54 votes
2 answers
33k views

Benefits of JavaConfig over XML configurations in Spring?

Earlier the configurations used to be in hard coded in the code, later it was externalized to .property files (for sake of avoiding hard coded values, avoiding changing code for the sake of changing ...
yathirigan's user avatar
  • 5,809
42 votes
7 answers
52k views

EJB 3.1 or Spring 3.. When to choose which one?

EJB achieved many improvements in 3.x versions, Spring is also commonly used and version 3 is a good alternative. There are many articles on web, but no exact comparison about ejb3x versus spring3x.. ...
asyard's user avatar
  • 1,743
41 votes
3 answers
167k views

Multiple scenarios @RequestMapping produces JSON/XML together with Accept or ResponseEntity

I am working with Spring 4.0.7 About Spring MVC, for research purposes, I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, ...
Manuel Jordan's user avatar
36 votes
6 answers
71k views

Can @PathVariable return null if it's not found?

Is it possible to make the @PathVariable to return null if the path variable is not in the url? Otherwise I need to make two handlers. One for /simple and another for /simple/{game}, but both do the ...
Rihards's user avatar
  • 10.3k
33 votes
4 answers
57k views

org.hibernate.HibernateException: No Session found for current thread

I'm getting the above exception with Spring3 and Hibernte4 The following is my bean xml file <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"...
Can't Tell's user avatar
  • 13.1k
33 votes
7 answers
53k views

@EnableTransactionManagement annotation with 2 transaction managers

I am using @Configuration annotation for configuration of spring instead of xml file. I am configuring 2 datasources with different session factory and different transaction managers. I am stuck with ...
Mital Pritmani's user avatar
30 votes
10 answers
31k views

A component named 'XXX' is already defined in this module in JBoss 7.1.1

I did not create the spring bean name with TimerServiceDispatcher in my application. But, the JBoss throw exception because of TimerServiceDispatcher is already defined in this module. I don't know ...
Zaw Than oo's user avatar
  • 9,839
28 votes
1 answer
33k views

Can Spring MVC's REST framework accept query strings rather than PathVariables?

In all the tutorials and articles I have read regarding Spring 3's RESTful additions to Spring MVC, I have only ever seen one way for the use to pass in query data, via a @PathVariable, like so: @...
Ken Bellows's user avatar
  • 6,811
27 votes
7 answers
38k views

Spring's @Scheduled error : Only one AsyncAnnotationBeanPostProcessor may exist within the context

I am trying Spring 3's @Scheduled annotation . Here is my configuration (app.xml) : <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:...
smallufo's user avatar
  • 11.7k
26 votes
4 answers
66k views

Spring 3 @ImportResource with multiple files

I'm trying to find the syntax for importing multiple spring xml context files using Spring 3 @ImportResource annotation. I have tried using comma to separate the filenames as illustrated below but ...
Kes115's user avatar
  • 2,130
25 votes
3 answers
36k views

spring-security - where can I find the list of ALL security filters registered when I use the <http> element?

There are a default set of filters registered when we use the <http> element in our xml file. This mentions the ordering of filters (whichever we choose to apply), and just above that, it ...
Daud's user avatar
  • 7,707
25 votes
3 answers
83k views

No AuthenticationProvider found for UsernamePasswordAuthenticationToken

my web.xml config is <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</...
Tito's user avatar
  • 8,974
23 votes
3 answers
45k views

no declaration can be found for element 'mvc:annotation-driven'

I have the requirement of returning JSON/XML data from my controller.From what i found,I needed @ResponseBody in my method and for that I need <mvc:annotation-driven> enabled. I have tried all ...
user2164016's user avatar
23 votes
3 answers
20k views

Reference an Annotated Spring Component in an XML Bean Definition

I am using an external library that requires that I configure it using an XML Bean definition; in the Bean definition I need to provide an external class with a Bean from my project. I am using spring ...
Rylander's user avatar
  • 19.9k
22 votes
1 answer
18k views

@Autowired by constructor looks for beans by type. How to inject a bean by name to a constructor using autowired annotation

@Autowired by constructor looks for beans by type. How to inject a bean by name to a constructor using autowired annotation? I have 2 beans of same type but I need to inject it to constructor of ...
user2972319's user avatar
22 votes
4 answers
13k views

Why unit testing with Spring 3.1 WebMvcConfig fails?

From Spring 3.1, we can use JavaConfig more easily thanks to @Enable* annotations. So I made a WebConfig to set WebMvc configuration, and tried to test it. But if I extends WebMvcConfigurerAdapter ...
Sanghyun Lee's user avatar
  • 22.3k
21 votes
4 answers
32k views

eventlisteners using hibernate 4.0 with spring 3.1.0.release?

These jars are both new released and have the latest solutions for Java EE applications. But I have a problem on specifiying hibernate listeners in hibernate.cfg.xml. Before spring 3.1.0, ...
asyard's user avatar
  • 1,743
21 votes
1 answer
28k views

Login/logout in REST with Spring 3

We are developing RESTful webservices with Spring 3 and we need to have the functionality of login/logout, something like /webservices/login/<username>/<password>/ and /webservices/logout. ...
FKhan's user avatar
  • 213
21 votes
2 answers
28k views

No persistence exception translators found in bean factory. Cannot perform exception translation

I'm getting following exception after migrating to Spring Framework 3.1.0 RC1 with Hibernate 4.0.0 CR7 2011-12-08/11:48:38.425/EST [Thread-17] ERROR Context initialization failed org....
MatBanik's user avatar
  • 26.7k
21 votes
3 answers
31k views

Downloading Spring Jars without using Maven

How do you download Spring Framework jars if you can't stand Maven or any of the other build management tools. From what I can tell it seems you have to spend many frustrating hours on Google to find ...
resigned's user avatar
  • 1,054
20 votes
7 answers
82k views

BeanFactory not initialized or already closed - call 'refresh' before accessing beans

I'm trying to add spring security to a regular JSF application. After repeated tries and I'm failing with the following error on tomcat bring-up. Here is the entire stack trace. Any help is ...
LambeauLeap's user avatar
20 votes
1 answer
19k views

Need understanding of spring.handlers and spring.schemas

I have some questions derived from a problem that I have already solved through this other question. However, I am still wondering about the root cause. My questions are as follows: What is the ...
Viriato's user avatar
  • 3,001
20 votes
1 answer
36k views

How to generate WADL for Spring REST Service

Hi I am working with Spring 3.5.0.Release. I want to generate a WADL for my spring rest service. Is their any functionality in Spring by which i can easily generate the WADL.
Utsav's user avatar
  • 1,593
19 votes
2 answers
53k views

Spring MVC: How to remove session attribute?

Example of using @SessionAttributes below. How to clear user session attribute after wizard finished ? In my example after returning to /wizard0 session attribute still exists. I've tried status....
marioosh's user avatar
  • 28k
18 votes
14 answers
28k views

No Session found for current thread (Spring 3.1.X and Hibernate 4)

I'm trying to set up my project using Spring 3.1 and Hibernate 4. I've been following some tutorials online. I'm getting a strange error that according to the spring forums should have been fixed ...
It Grunt's user avatar
  • 3,328
17 votes
9 answers
24k views

Spring conversion service - from List<A> to List<B>

I have registered a custom conversion service in a Spring 3 application. It works well for POJOs but it does not work on Lists. For example, I convert from String to Role and it works fine, but not ...
JohnDoDo's user avatar
  • 4,810
17 votes
3 answers
62k views

JDBCTemplate queryForMap for retrieving multiple rows [duplicate]

Can I use queryForMap if there are multiple rows returned by the query. For a single row, the below code works fine. public Map<String, Object> retrieveMultipleRowsColumns(String deptName){ ...
user182944's user avatar
  • 7,997
17 votes
2 answers
21k views

Elegant way to get Locale in Spring Controller [duplicate]

I'm looking for a cleaner way (in Spring 3.2) to get the current locale than explicitly calling LocaleContextHolder.getLocale() at the start of each Controller method. It has to be compatible with ...
yetimoner's user avatar
  • 787
17 votes
2 answers
13k views

Is there any way to override a bean discovered by component scan?

I have a java configuration class providing fooBean directly and barBean by component scan. @Configuration @ComponentScan(basePackages = { "com.blah" }) public class Config { @Bean public ...
mmoossen's user avatar
  • 1,257
16 votes
5 answers
36k views

difference between @Component and @Configuration in Spring 3

I came across two annotations provided by Spring 3 (@Component and @Configuration) I am a bit confused between these. Here is what I read about @Component Put this “context:component” in the bean ...
Anand's user avatar
  • 21k
16 votes
1 answer
21k views

List of Spring Runtime Exceptions

Does anyone know where I can find a list of Spring's (3.0.x) runtime exceptions? I'm talking about exceptions like DataRetrievalFailureException; there's a whole set of these runtime exceptions that ...
Vivin Paliath's user avatar
16 votes
3 answers
12k views

Upgrading to springframework.scheduling.concurrent?

As of Spring 3.0 the ScheduledTimerTask is deprecated and I can't understand how to upgrade to org.springframework.scheduling.concurrent. <bean id="timerFactoryBean" class="org.springframework....
Rihards's user avatar
  • 10.3k
16 votes
7 answers
36k views

Spring 3 Security: AccessDeniedHandler is not being invoked

I have a spring 3 application with the configurations given below. When any user tries to access a page and he/she isn't logged in, I get an Access is Denied exception with an ugly stack trace. How do ...
Ritesh M Nayak's user avatar
16 votes
5 answers
7k views

Best practices when using Spring 3 annotations

I'm looking for some best practices when using Spring 3 annotations. I'm currently moving to Spring 3 and from what I've read so far I see a lot of accent placed on using annotations and moving away ...
ElenaT's user avatar
  • 2,620
16 votes
3 answers
68k views

RestTemplate post for entity

My post method gets called but my Profile is empty. What is wrong with this approach? Must I use @Requestbody to use the RestTemplate? Profile profile = new Profile(); profile.setEmail(email); ...
pethel's user avatar
  • 5,467
16 votes
1 answer
15k views

Resolve Spring @Value expression in JUnit tests

Here's a snippet of a Spring bean: @Component public class Bean { @Value("${bean.timeout:60}") private Integer timeout; // ... } Now I want to test this bean with a JUnit test. I'm ...
Harold L. Brown's user avatar
16 votes
1 answer
44k views

"The matching wildcard is strict, but no declaration can be found for element 'http'" Error

I am trying to configure NTLM authentication, but receive error: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'. I read a lot of topics ...
DmitryB's user avatar
  • 1,169
15 votes
2 answers
42k views

Spring: Attaching @Qualifer to Java-configured beans

In spring, you can XML-configure a bean to have a qualifier. I can't seem to find how I can attach a qualifier if configuring beans through Java annotations. What's up with that? Do I have to use just ...
Aleksandr Dubinsky's user avatar
15 votes
6 answers
27k views

How to use property from property file specified in PropertyPlaceholderConfigurer in JSP

In my application context I have defined properties file: <context:property-placeholder location="classpath:application.properties" /> I want to get value of the property defined in that file ...
glaz666's user avatar
  • 8,707
15 votes
2 answers
49k views

Spring MVC 3 : Ambiguous mapping found

I am playing with spring MVC 3.1 and testing different features. I wanted to verify following statement taken from @RequestMapping#value doc If you have a single default method (without explicit path ...
Amit Patel's user avatar
  • 15.9k

1
2 3 4 5
16