applicationcontext

Is spring application context reloading via ConfigurableApplicationContext refresh() considered bad-practice

故事扮演 提交于 2019-12-06 11:33:06
We have a Spring application that is hosted on a shared tomcat instance . Sometimes we have to reload the spring application context but don't want to restart the Tomcat server, because other application's are hosted there as well. Is refreshing springs application context via ((ConfigurableApplicationContext)applicationContext).refresh(); considered bad practice ? What alternatives do I have? A few issues that might arise - Firstly, refresh() should destroy all beans currently living in the context (singletons etc) and recreate them, so any bootstrapping that might happen will happen again

How to pass local filename to ClassPathXmlApplicationContext?

限于喜欢 提交于 2019-12-06 05:36:57
问题 By "local filename" I mean that resource file is located in the same directory as class file. In the case below this is JUnitRunner.class file. Java's getResource() file can handle this if path does not start with / ' I can't figure out, how to do the same ClassPathXmlApplicationContext constructor? package springtests; import java.io.File; import java.net.URISyntaxException; import java.net.URL; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org

Configure drools with spring. xsd errors

烈酒焚心 提交于 2019-12-06 04:47:43
I'm trying to create spring roo application with Drools. But I faced with errors in applicationContext.xml. Error: Multiple annotations found at this line: - Unable to locate Spring NamespaceHandler for element 'drools:execution-node' of schema namespace 'http://drools.org/schema/ drools-spring' - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'drools:execution-node'. this is a piece of applicationContext.xml: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http

applicationContext.xml is not getting loaded when I have kept the spring-servlet.xml in Web application

老子叫甜甜 提交于 2019-12-06 04:06:20
I am Working on a web application in eclipse. A spring MVC web applicatication to be precised. I have created servlet xml and mapped it in web.xml. Everything is working fine till here & Servlet loads the HTML page But now I want to add a JPA layer. So I have created applicationContext.xml in WEB-INF and put all JPA related spring configurations in that file. But when I start my web application, JPA related stuff is not getting loaded. What I believe is, applicationContext.xml itself is not getting loaded. Any Idea or any other configuration I am missing here? The applicationContext.xml file

ApplicationContextaware works

白昼怎懂夜的黑 提交于 2019-12-06 02:57:08
I need to know how applicatoncontextaware works. I have applicationContext.xml which has some import resource(another applicationContext). I need to use the applicationContext.xml in my java class to use the spring beans in it. I came to know the applicationcontextaware class which is used to get the spring beans inside java class.Applicationaware has the set and getapplicationcontext() methods. getapplicationcontext() is defined as static. How do the applicationcontextware loads the applicationContext.xml? whether do i need to give the location of applicationContext.xml so that

Object Sharing Between Activities in Android

天大地大妈咪最大 提交于 2019-12-06 01:42:52
问题 Hi I have a question about passing an object throughout the app. Say I want to have a big custom object throughout the app. This object will be used by multiple activities and services. What I did at first is this. First, I created an Application class and define a singleton object. public class FooApplication extends Application { public static SharedObj obj; ... } Second, in an activity I set a value of this object public class FooActivity extends Activity { OnCreate() { FooApplication.obj

JUnit custom runner with Spring application context

别等时光非礼了梦想. 提交于 2019-12-05 19:47:24
问题 I am fairly new to Spring and am working with a suite of JUnit 4.7 integration tests for a web application. I have a number of working test cases of the form: import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/META-INF/spring/testContext.xml" }) public class myTest { @Test public

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

被刻印的时光 ゝ 提交于 2019-12-05 13:54:18
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 AccountRepository accountRepository(){ return new JdbcAccountRepository(); } @Bean public TransferService transferService1() { TransferServiceImpl service = new TransferServiceImpl(); service.setAccountRepository(accountRepository()); return service; } @Bean public TransferService transferService2() { return new TransferServiceImpl( new

Class Loading Application Context Spring

那年仲夏 提交于 2019-12-05 12:34:11
I have a Spring web project and I need load some classes after application context has been initialized because those classes will eventually used in future. Thus, I try to preload them before use to improve performance. How to do it ? Please help. Thanks. To load a class into JVM it is enough simply to call Class.forName('com.foo.bar.MyClassToPreLoad') method. You can do it e.g. in your own implementation of javax.servlet.ServletContextListener and then register it in web.xml <listener> <listener-class>com.foo.bar.MyClassPreloadingContextListener</listener-class> </listener> Or you can do it

Spring transactional context doesn't persist data

醉酒当歌 提交于 2019-12-05 11:27:45
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 + MySQL database). I use Spring ORM to inject EntityManager (by @PersistenceContext annotation) to my simple RegisterDAO. I have configured GlassFishs (which I am using) connection pools for using MySQL and everything works - I can work with my database, but when I am persisting something - nothing happens (data are not persist to database). I know that