spring-3

Spring3 's @Transactional @Scheduled not committed to DB?

北慕城南 提交于 2019-11-30 13:41:24
This is my 1st time trying Spring3's @Scheduled , but found I cannot commit to DB. This is my code : @Service public class ServiceImpl implements Service , Serializable { @Inject private Dao dao; @Override @Scheduled(cron="0 0 * * * ?") @Transactional(rollbackFor=Exception.class) public void hourly() { // get xxx from dao , modify it dao.update(xxx); } } I think it should work , I can see it starts-up hourly and load xxx from DB , but data is not committed to DB. There's been tx:annotation-driven in spring's xml : <bean id="entityManagerFactoryApp" class="org.springframework.orm.jpa

Change @ManagedResource objectName dynamically

帅比萌擦擦* 提交于 2019-11-30 13:29:15
I am creating prototype beans programatically/dynamically. I want those beans after initiation to be in the jmx console. How I can distinguish between them? I am using anotations in order to add my beans to the jmx and I have @ManagedResource(objectName="bean:name=MybBean") I need to inject the objectName dynamically. Any idea how could I do it? Here's my jmx configuration: <context:mbean-export server="mbeanServer" /> <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean" /> <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init=

In Spring 3.1 can <mvc:interceptors> be used in conjunction with @Configuration

跟風遠走 提交于 2019-11-30 10:00:33
I am migration from Spring 3.0.5 to 3.1 since I need to have custom RequestMappingHandlerMapping. I am facing problems in plug-in of extended RequestMappingHandlerMapping - I had existing servlet-conetxt.xml and I added WebConfig with @Configuration annotation. But, I always get error ambiguos mapping (since new annotation defined in ExtendedRequestMappingHandlerMapping is not takign in effect). I have various levels of interceptors defined in servlet-context.xml which I want to keep in XML configuration. I want to use . Is there a way to use conjunction of servlet-context.xml and at the same

Integrating JSR-356 WebSocket @ServerEndpoint with Spring 3 beans

孤人 提交于 2019-11-30 08:33:40
问题 I'm using Spring 3.2.5 without full new JSR-356 WebSockets support. I would like to have singleton-bean reference in my @ServerEndpoint WebSocket server, which is instantiated by servlet container itself, not in Spring context. What is the clean way to do it? My current solution: I made @Service singleton bean with instance in static field: @Service public class WebSocketSupportBean { private volatile static WebSocketSupportBean instance = null; public static WebSocketSupportBean getInstance(

Autowiring a service into a validator

不羁岁月 提交于 2019-11-30 06:57:20
问题 This example is a bit contrived; I've simplified it to remove extraneous details and to focus on the problem I am having. I have a validator that looks like this: @Component public class UniqueUsernameValidator implements ConstraintValidator<UniqueUsername, String> { @Autowired UsernameService usernameService; @Override public void initialize(UniqueUsername uniqueUsername) { } @Override public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) { return

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

岁酱吖の 提交于 2019-11-30 06:26:17
问题 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 sorts of RnD but am still stuck! :( Apparently my problem lies in my servlet.xml file (the schema isnt getting validated!) I am using Spring 3.1.1 & have explicitly put in spring-mvc-3.1.1.jar in my classpath. Here's my servlet-context file sample-servlet.xml: <?xml version="1.0" encoding="UTF-8"?>

How to programmatically log user in with Spring Security 3.1

試著忘記壹切 提交于 2019-11-30 03:12:35
问题 What's the proper way to programmatically log a web visitor in under a particular username in Spring and Spring Security 3.1? It seems the way I was doing it under 2.5 has changed a little. I'm sure there's a much better way of doing this now. Basically, when I create a new user, I need to also log them in at the same time. 回答1: Create an Authentication (usually a UsernamePasswordAuthenticationToken ) and then call SecurityContextHolder.getContext().setAuthentication(authentication) 回答2: This

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

浪子不回头ぞ 提交于 2019-11-30 01:22:34
问题 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 appreciated. EDIT: upon further tests, I notice the following stack trace, before the second set of SEVERE exception about BeanFactory not initialized or already closed SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderList ener

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

試著忘記壹切 提交于 2019-11-29 19:58:04
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.. Do you have any ideas about them, in real world examples which one is better at which conditions? For example, we want to separate db and server, which means our application will be on a server, our database will be in another server.. EJB remoting vs Cluster4Spring etc ? Doing everyting @Annotation is always good? configuration never needed? For your use case where the application runs on one

Bean's property is not setting from util:list object

扶醉桌前 提交于 2019-11-29 18:12:30
I have declared following list using spring util namespace in my spring configuration file: <util:list id="childList"> <ref bean="child1"/> <ref bean="child2"/> <ref bean="child3"/> </util:list> where all reference bean are marked with @Componant annotation and their respective beans are creating. But whenever I am trying to Autowired any beans property like: @Component public class ListTest{ @Autowired @Qualifier("childList") private List<IParent> list; public List<IParent> getList() { return list; } } Gives exception as: org.springframework.beans.factory.BeanCreationException: Error creating