spring-3

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

做~自己de王妃 提交于 2019-11-29 16:09:20
问题 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www

How can I authenticate a system user for scheduled processes in Spring?

流过昼夜 提交于 2019-11-29 13:37:30
we have a Quartz/Spring Batch job, that for audit logging purposes we'd like to have it "authenticated" as a system user. Some of our methods rely on fetching the SecurityContext to do this. The ways of running this job are trusted (or authenticated). We don't want to actually use a password or other token (since the process is basically always spawned by quartz). I tried this private void authenticate() { UserDetails admin = userDetailsService.loadUserByUsername( "admin" ); RunAsUserToken token = new RunAsUserToken( UUID.randomUUID().toString(), admin, admin.getAuthorities(), null , null );

Spring 3 NamespaceHandler issues with Maven Shade plugin

南楼画角 提交于 2019-11-29 13:35:17
Spring 3.1.1.RELEASE with Apache Maven 3.0.3 and Maven Shade plugin 1.6. Using the mvn shade plugin to package the artifact in an uber-jar, including its dependencies: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.MyApplication</mainClass> </transformer> </transformers> </configuration> <

Which maven2 artifacts are necessary to build a WS with CXF and Spring?

我与影子孤独终老i 提交于 2019-11-29 12:25:48
I'm trying to build a WS with Spring 3.0 and CXF. I'm following the steps of this article http://www.ibm.com/developerworks/library/ws-pojo-springcxf/ But in that article, the authors assume that you have cxf installed. I'd like to embed CXF in my .war. Thanks in advance. Daniel Kulp Normally, just depend on cxf-rt-frontend-jaxws and cxf-rt-transport-http. Pretty much the rest of the stuff needed would be pulled in transitively from those. (might not even need cxf-rt-transport-http) That would cover 90% of the usecases. <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend

Integrating JSR-356 WebSocket @ServerEndpoint with Spring 3 beans

北战南征 提交于 2019-11-29 06:56:00
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() { return instance; } public WebSocketSupportBean() { instance = this; } and just getting it in

Spring: Attaching @Qualifer to Java-configured beans

和自甴很熟 提交于 2019-11-29 03:27:23
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 plain old names? If you're using annotations (not Java based configuration), you can use the following to add a qualifier (see the Spring documentation ): @Component @Qualifier("myQualifier") public class MyBean { //code } And to wire in the bean, use the following (again, see the Spring documentation ): public class MyClass { @Autowired @Qualifier("myQualifier") private MyBean myBean; //more

Uploading multiple files using Spring MVC 3.0.2 after HiddenHttpMethodFilter has been enabled

帅比萌擦擦* 提交于 2019-11-29 02:19:19
Important : This question is completely useless for any Spring version higher than 3.0.4 as the issue discussed in this thread had been fixed in that version a long ago and is no longer reproducible in subsequent versions of Spring. I'm using Spring version 3.0.2. I need to upload multiple files using the multiple="multiple" attribute of a file browser such as, <input type="file" id="myFile" name="myFile" multiple="multiple"/> (and not using multiple file browsers something like the one stated by this answer , it indeed works I tried). Although no versions of Internet Explorer supports this

Autowiring a service into a validator

孤街醉人 提交于 2019-11-28 23:40:09
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 !usernameService.exists(s); } } I call the validator from my controller like this: @RequestMapping public void

Best Practise of injecting applicationContext in Spring3

社会主义新天地 提交于 2019-11-28 21:57:14
As in the title above, I am confused about pros cons between injecting applicationContext by directly @Autowired annnotation or implementing ApplicationContextAware interface in a singleton spring bean. Which one do you prefer in which cases and why? Thanks. Actually, both are bad. Both of them tie your application to the Spring framework, thus inverting the whole inversion-of-control concept. In an ideal world, your application should not be aware of being managed by an ApplicationContext at all. Once you have chosen to violate this principle, it doesn't really matter how you do it.

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

血红的双手。 提交于 2019-11-28 18:47:20
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"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema