Questions tagged [applicationcontext]

The Spring `ApplicationContext` class

The Spring ApplicationContext class is the central interface to provide configuration to any Spring application.

869 questions
6
votes
0 answers

Can string concatenation be used for application yml value that includes SpEL?

I'm trying to define a spring data source url like so: spring: datasource: url: "jdbc:${vcap.services.compose-for-mysql.credentials.uri}?useSSL=true&requireSSL=true&verifyServerCertificate=true" username:…
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
6
votes
2 answers

How to fix test failing with "No ModelAndView found"?

This class is in the top of my tests hierarchy: @TestPropertySource("/test.properties") @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest public abstract class ApplicationAbstractTest { } And few more test…
6
votes
0 answers

Spring hierarchical context

I have following problem: I'm trying to implement Spring in existing ear application (using Jboss as App Server and Hibernate as ORM). The ear application consists of war(basically few simple servlets), har(hibernate archive which has only the data…
Stefan
  • 335
  • 1
  • 3
  • 6
6
votes
3 answers

How to get bean with class and qualifier programmatically?

It is possible to @Autowired bean with class and @Qualifier in Spring. How to do the same thing programmatically? I.e. search context for bean giving it's class and it's qualifier? I see a plenty of getBean() methods, neither of them explicitly…
Dims
  • 47,675
  • 117
  • 331
  • 600
6
votes
2 answers

java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present

When running my webapp, I get the stacktrace listed below every other try. Note that there doesn't seem to be multiple ContextLoader definitions im web.xml as far as I can tell. Moreover, the app runs just fine the second/fourth/etc. time. This…
MJB
  • 171
  • 1
  • 1
  • 8
6
votes
1 answer

How to use path relative to user home in PropertySource

Spring expressions doesn't work inside the PropertySource annotation. @PropertySource({ "classpath:application.properties", "#{systemProperties['user.home']}/.app.properties" }) @Configuration public class Config { @Bean public static…
Daniil Iaitskov
  • 5,525
  • 8
  • 39
  • 49
6
votes
2 answers

How to import a spring application context into another application context?

I have two spring application contexts. One is local to my application and the other is from one of the maven dependencies. Now, my applicationContext.xml file look like this. and I…
JavaTechnical
  • 8,846
  • 8
  • 61
  • 97
6
votes
1 answer

Load spring context using multiple threads

I have a large application context consisting of many context files, using autowiring and package scans, starting up web services, establishing connections to databases and and external legacy system etc. I have been thinking on how to improve…
anydoby
  • 408
  • 4
  • 9
6
votes
2 answers

Parsing applicationContext.xml renders a `java.lang.NoSuchMethodError`. Could this be caused by dependency issues?

I am invoking a test method (Junit) with an annotated application context (@ContextConfiguration(locations={"classpath:applicationContext.xml"})). The test fails with the following stacktrace: 11:20:39.793 [main] ERROR…
atripes
  • 1,683
  • 4
  • 20
  • 23
6
votes
2 answers

Enabling UTF-8 character set in JSF2.0, Hibernate, MySQL

We are to enable UTF-8 character encoding to our web application designed using JSF2.0, Hibernate, MySQL. Following is the datasource defined in our application context file
NKS
  • 1,140
  • 4
  • 17
  • 35
5
votes
5 answers

java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext maven

I am new to spring and maven. I have a simple hello world project using Spring . The project builds successfully but i face the following error at runtime: Error: A JNI error has occurred, please check your installation and try again Exception in…
Adnan
  • 90
  • 1
  • 1
  • 5
5
votes
0 answers

Does import and component scan order matter in Spring multiple-context definition

If I have multiple Java-based configuration files for multiple bean context, like Security Context and Persistence Context in Spring, which I import to Root Context using @Import, does is matter in which order I do the import and in which…
5
votes
1 answer

ApplicationContext.getBean vs new keyword

I am using JSF + Spring+ Hibernate protected @Inject ChartOfAccount chartOfAccount; I basically want to populate chartOfAccount from the list for (DistributionEntry de : getDistributionEntries()) { …
Shahid Ghafoor
  • 2,991
  • 17
  • 68
  • 123
5
votes
1 answer

How to exactly work the Spring Inheritance-based Proxies configuration?

I am studying for the Spring Core certification and I am finding some doubts related to the proxying notion. So on the study material I find the following quiz: There is a Java configuration class that contains the following methods: @Bean public…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
5
votes
1 answer

How to initialize Application Context in Spring Framework 4

I have a project based on Spring Framework 4 and its subproject - Spring Data Solr. All examples I had a chance to see explain how to organize your project - from base entity ( pojo's ) classes till spring specific classes such as repositories and…
SergeZ
  • 298
  • 1
  • 5
  • 18