Questions tagged [applicationcontext]

The Spring `ApplicationContext` class

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

869 questions
8
votes
1 answer

Spring contexts hierarchy

I'm going to create several Spring contexts with one parent context. Here is how I'm going to create parent context: new ClassPathXmlApplicationContext(new String[] {"ApplicationContext/application.xml"}) And each parent context I want to create in…
alsid
  • 490
  • 6
  • 14
8
votes
4 answers

Read an environment variable from applicationContext.xml

I need read an environment variable defined in my web.xml Path Repositorio NFS PATH_ENV java.lang.String
Geme
  • 111
  • 1
  • 1
  • 3
8
votes
2 answers

Spring ApplicationContext.getBean(Class c) not working for proxy classes

I need to look up beans via their class type. When the beans have been wrapped by a Proxy (some methods are @Transactional) - the ApplicatoinContext fails to find them. I find that if I look them up via an interface, it works but in this case I'm…
Alex Worden
  • 3,374
  • 6
  • 34
  • 34
8
votes
2 answers

Spring shutdown event that fires immediately before ApplicationContext is destroyed?

I am looking for an interceptor or a trigger to know that, all the context beans are destroyed and the applicationcontext instance is about to destroy itself. So I can do one process at the end of the application lifetime. There is this event type…
Neron
  • 1,500
  • 7
  • 30
  • 52
7
votes
2 answers

Component Scan not finding @Component's in a JAR in Tomcat webapp

I just filed a bug in the Spring bugsystem ( https://jira.springsource.org/browse/SPR-8551 ), but I am still unsure if I am missing something I tracked down a problem with to this statement. Given the two following classes…
AdrianRM
  • 2,622
  • 2
  • 25
  • 42
7
votes
2 answers

Is there a way to store java variable/object in application context without xml or properties file

I want to store a particular variable (String or Object) in application context in spring boot application. But I don't want to use an xml or properties file for storing it. There will be a function which will store the data in application context.…
anu l
  • 111
  • 1
  • 2
  • 7
7
votes
1 answer

How can I get my logger in a Python Flask app to use unique IDs per page view for logging?

I have a Flask app with a logging system that I wrote based on the standard Python logger. I want to have a unique ID for each page view, so I can track the entire process and check for logged errors and premature ending. The first thing I tried…
JAL
  • 21,295
  • 1
  • 48
  • 66
7
votes
3 answers

Spring: Properly setup @ComponentScan

I have following set up for my Spring Application Context. @Configuration public class RmiContext { @Bean public RmiProxyFactoryBean service() { RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean(); …
TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125
7
votes
2 answers

Spring bean instantiation ordering

I have run into an issue where Bean instantiation sequencing matters. Currently Bean3 from below is running a DB based cache put operation, and Bean 1 queries against the newly created cache using Proxy Bean2. Priority is for Bean3 and Bean 2 to be…
AKSM
  • 327
  • 7
  • 20
7
votes
3 answers

ApplicationContextInitializer in a non-web Spring Context?

I've created an ApplicationContextInitializer implementation to load properties from a custome source (ZooKeeper) and add them to the ApplicationContext's property sources list. All the documentation I can find relates to Spring web-apps, but I want…
DeejUK
  • 12,891
  • 19
  • 89
  • 169
7
votes
2 answers

Spring 3.1 bean visibility using bean definition profiles

I have been experimenting with using Spring 3.1's bean definition profiles and nested beans. I had hoped that I could define different beans depending on the active profile. Consider the following heavily over simplified example such that my…
Mark McLaren
  • 11,470
  • 2
  • 48
  • 79
7
votes
5 answers

How can I configure Spring to save as much memory as possible?

We're deploying an application on a semi-embedded device that has memory constraints. Looking to save whatever we can we are analysing heap dumps of the app and attacking the biggest consumers. We use Spring 2.5 together with Spring DM 1.1 and we…
Boris Terzic
  • 10,858
  • 8
  • 45
  • 59
6
votes
3 answers

Spring transactional context doesn't persist data

I know that my problem is a common problem, but I've checked a lot of questions here, checked Spring documentation and I really don't know what I am doing wrong. My problem: I've got a Spring WebFlow project using JPA (implementation: OpenJPA +…
Arek Woźniak
  • 695
  • 3
  • 12
  • 25
6
votes
1 answer

Android: Change language android N, application instance not updated

I follow Android N change language programmatically to changed language of my app in android N and above. However, I still have the problem with the application context instance. In my Application class: private static Application…
6
votes
1 answer

Is it possible to cache Spring's Application Context between classes?

I'm trying to improve the performance of the Spring integration tests of a project I'm working on. We're using Spring + Gradle + JUnit. With this configuration inside the build.gradle file: test { useJUnit() setForkEvery(0) …