spring

Configuring servlet for using spring

Hello How to configure my web application in Eclipse (based on Servlets and deployed to Tomcat) to use Spring framework. I need only IoC container (Beans only and ApplicationContext), not Spring MVC. How to configure web.xml for this? Regards ...

Dependency Injection with Spring/Junit/JPA

I'm trying to create JUnit tests for my JPA DAO classes, using Spring 2.5.6 and JUnit 4.8.1. My test case looks like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:config/jpaDaoTestsConfig.xml"} ) public class MenuItem_Junit4_JPATest extends BaseJPATestCase { private ApplicationContext c...

Extending spring based app

I have a spring-based Web Service. I now want to build a sort of plugin for it that extends it with beans. What I have now in web.xml is: <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/*-configuration.xml</param-value> </context-param> My core app has main-configuration.xml which decla...

Spring MVC Web PetClinic Tutorial?

Is there a tutorial that goes along with the PetClinic application? I have been trying to find one, but google is not helping me today. Specifically, I dont understand things like: @Autowired - what does that even mean? @RequestMapping(method = RequestMethod.GET) public String setupForm(@RequestParam("petId") int petId, ModelMap model...

Spring-hibernate mapping problem

I have a spring-hibernate application which is failing to map an object properly: basically I have 2 domain objects, a Post and a User. The semantics are that every Post has 1 corresponding User. The Post domain object looks roughly as follows: class Post { private int pId; private String attribute; ... private User user; ...

Multiple Spring @RequestMapping annotations

Is it possible to use multiple @RequestMapping spring annotations in a method? Like: @RequestMapping("/") @RequestMapping("") @RequestMapping("/welcome") public String welcomeHandler(){ return("welcome"); } ...

Is there a way to specify a default property value in Spring XML?

We are using a PropertyPlaceholderConfigurer to use java properties in our Spring configuration (details here) eg: <foo name="port"> <value>${my.server.port}</value> </foo> We would like to add an additional property, but have a distributed system where existing instances could all use a default value. Is there a way to avoid upda...

JSR 303 Bean Validation + Javascript Client-Side Validation

What is the best way to perform client-side form validation using Javascript (with minimal code duplication) when using JSR 303 bean validation on the server side? I'm currently using Spring 3 and the Hibernate Validator. ...

Spring 3 replacement for isDisabledInThisEnvironment

I'm currently converting a test class which extended the Spring class AbstractTransactionalSpringContextTests to Spring 3. This abstract class is now deprecated and I should use AbstractJUnit38SpringContextTests. The test class had this method in it: @Override protected boolean isDisabledInThisEnvironment(String testMethodName) { /...

static factory method (Spring)

What is the advantage and use to Instantiate a bean in Spring Framework using a static factory method? ...

Are there reasons why the java/spring/hibernate stack aren't popular in the web 2.0 space?

I am really impressed with the java/spring/hibernate stack, and really want to dive in. Just curious, why are so many people using rails when java/spring/hibernate are tried and true? I guesss its because of the convention over configuration and time to launch? (spring has really gone the annotation route so less xml though). I reali...

How to use role-hierarchy in Spring Security 3 with Spring EL?

I want to use @PreAuthorize annotation on service methods with Spring Security. One of requirements is to use role-hierarchy. But by default it is not enabled. I found that in SecurityExpressionRoot class ("the base class for expression root objects") there is a property roleHierarchy. The class actually does use this property for metho...

Is it possible to use .properties files in web.xml in conjunction with contextConfigLocation parameter?

Here is part of my web.xml: <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:application-config.xml </param-value> </context-param> application-config.xml uses property placeholder: <context:property-placeholder location="classpath:properties/db.properties"/> ...

Java/Spring: Why won't Spring use the validator object I have configured?

I'm writing a web app with Java & Spring 2.5.6 and using annotations for bean validation. I can get the basic annotation validation working fine, and Spring will even call a custom Validator declared with @Validator on the target bean. But it always instantiates a brand new Validator object to do it. This is bad because the new valida...

Disable Spring WebApplicationContext refresh

How can I stop a Spring WebApplicationContext from automatically refreshing when the context file changes? ...

Spring freemarker bind - what is controller?

looking at the documentation for the spring macros for freemarker they talk about the 'command' object... i am confused as to what that is? at first i thought it is just the ModleMap set by the controller, but its obviously not. What is the "bind" actually used for? ...

Using spring:nestedPath tag

Hello All, I have this code, I know I'm missing something but don't know what. It would be great if you help me out. I'm new to Spring MVC. I'm trying out a simple Login application in Spring MVC. This is my web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="ht...

Programatically bridge a QueueChannel to a MessageChannel in Spring

I'm attempting to wire a queue to the front of a MessageChannel, and I need to do so programatically so it can be done at run time in response to an osgi:listener being triggered. So far I've got: public void addService(MessageChannel mc, Map<String,Object> properties) { //Create the queue and the QueueChannel BlockingQueue<Mes...

Is it possible from Spring to inject the result of calling a method on a ref bean?

Hi, Is it possible from Spring to inject the result of calling a method on a ref bean? I'm trying to refactor some cut/pasted code from two separate projects into a common class. In one of the projects, the code lives in a class I'll call "MyClient" that is being instantiated from Spring. It is injected with another spring-instantiate...

SessionFactory in Hibernate

Hi, I am using hibernate-2.1 and "net.sf.hibernate.SessionFactory" class in my spring project. Now I am switched to Spring 2.5.6.A, where they are using hibernate3 and I am not able to find out the "net.sf.hibernate" package in that. But I found SessionFactory class in the package "org.springframework.orm.toplink". Is both the class ...