spring

How to turn Spring @Autowired required property to false for test?

I've been using the @Required annotation up to now to ensure DI of my beans in a Spring configured application. To enable the annotation, you need to declare a RequiredAnnotationBeanPostProcessor bean in your configuration. In your test configuration you just don't declare it, so that if some beans are not needed you don't have to have...

How to go about creating a first startup wizard with Wicket? (Database table creation etc.)

Hello. I'm working on a Java Web Application with Wicket, Spring and Hibernate. The web application is not particularily large (I have one DAO and one service), but I'd like to offer the users that deploy the application a startup wizard much like the ones found in Wordpress. When the webpage is accessed for the first time (no database...

hibernate - spring/bean mapping set

I'm pretty much a newb with spring-hibernate and I have been trying to make it work. I have a data model like this: patient prescription ---------- -------------- patient_id* prescription_id* first_name patient_id* last_name date ... I'm using spring beans with hibernate ...

Spring: separate datasource for read-only transactions

Thanks for reading this. I have 2 MySQL databases - master for writes, slave for reads. The perfect scenario I imagine is that my app uses connection to master for readOnly=false transactions, slave for readOnly=true transactions. In order to implement this I need to provide a valid connection depending on the type of current transacti...

bean validation- hibernate error

I am getting following exception when trying to run my command line application: java.lang.ExceptionInInitializerError at org.hibernate.validator.engine.ConfigurationImpl.<clinit>(ConfigurationImpl.java:52) at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:43) at jav...

simpleJDBCTemplate not replacing quoted parameter

Hi, I am using simpleJDBCTemplate to insert a value to a postgre database. String sql "insert into testTable values(:bla, :blah, functionThatTakesAText(':blu'))" BeanPropertySqlParameterSource namedParameters = new BeanPropertySqlParameterSource(lighting); simpleJdbcTemplate.update(sql, namedParameters); Now, the blu parameter is actu...

can we use spring expressions (spel) in other annotations?

I want to be able to do this: @Controller @RequestMapping("/#{handlerMappingPaths.security}/*") public class SecurityController { etc //for instance, to resuse the value as a base for the folder resolution @Value("#{handlerMappingPaths.security}/") public String RESOURCE_FOLDER; @RequestMapping(value="/signin-again", me...

application_start Event to pre-load objects in spring mvc?

Does spring (spring mvc) have an event that gets fired once, on application startup, where I can hook in and load some objects? ...

advice on freemarker templating, want to create a master template

I want to create a master template that every other view page will inherit. So the master template will have: HEADER --CONTENT-- FOOTER the header will optionally show (if the user is logged in), the username and other user object properties. the --CONTENT-- is a placeholder that other 'inheriting' view pages will inject their conte...

Is Spring Webflow suitable for async. flows?

I've got my first impression of Spring WebFlow 2.1 from studying the reference app and reading the manual. Before going further, I would like to ask for the impression of this community. Actually, I plan my site to consist of only one single web page. Everything (login/logout, adding elements etc.) else is supposed to be updated via asy...

Spring DAO, Portlet, concurrency

Hi there, I'm facing a strange problem: I've using spring to manage my dao layer in my portlet app. Now something weird happens, if two users with different languages accessing the same table nearly parallel. Example: User A (language 4) access table X, a few seconds after this User B (language 5) access table X. Now: User A gets langu...

@autowired @qualifier pointing to a service in a jar file application

I am using another application's service,since everything is already made and done. My application is to use the interface class inside the application jar. but something seem to be wrong when this code is called. BeanFactory factory = new ClassPathXmlApplicationContext( "/Context-Controller.xml"); even if my Context-Controller.xml h...

Web enabling Java console application's JMX beans

I have built a Java console-based application and exposed key methods via Spring/JMX declarations. Using JConsole, I can invoke these methods but more ideally, I would like to build a management-style web application to provide browser-based access to these methods. Thanks. Ashwin ...

Java : How to accomodate special characters in the filename while uploading and downloading the file ?

Background: I have a file which I upload, during this process the link of the file is stored in the database and not the actual file, acutal file is stored in the File System, currently am storing it in my local machine. Goal: My goal is to upload a file and download a file properly which has special characters in it - #,$,%,@ etc. ...

Spring XML files outside WEB-INF

I'm working in a multi-module maven2 project using Spring and GWT. Let's say I have two subprojects: service and presentation. "service" contains the actual implementations of the services and "presentation" is in charge of wrapping them for GWT. I have successfully loaded the Spring XML files that are in the WEB-INF directory (the same...

How to bind a list of object to SpringMvc Controller?

I'm using the following action on a SpringMvc application: @RequestMapping(value = "/test", method = RequestMethod.GET) public ModelAndView test( @ModelAttribute List<Group> groups ) { //return whatever } My Group class has an 'id' and a 'name' property. Default getter/setter. How should i call this action in order to have this ...

Spring El Expression

I'm switching from faces-config to Spring and wanted to know how you can pass a property from one bean to another: e.g. <bean id="myBean" class="Bean1"> </bean> <bean id="myBean2" class="Bean2"> <constructor-arg ref="#{myBean1.value}"/> </bean> ...

Spring @Required annotation not working as expected.

I'm trying to test out Spring Annotations to see how they work with some simple examples derived from the Spring 3.0 Source (in this case the "@Required" annotation specifically). To start, I came up with a basic "Hello World" type example that doesn't use any annotations. This works as expected (i.e. prints "Hello Spring 3.0~!"). I t...

Using Junit 4's Timeout @Rule with Spring's AbstractTransactionalJUnit4SpringContextTests

When i use Junit's org.junit.rules.Timeout with spring's base class AbstractTransactionalJUnit4SpringContextTests, i get this exception: org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress The log ou...

If I have a handler interceptor that loads a user object, adds it to request attri, do I cast to get object?

I plan to create a Handler interceptor that will fire before the controller gets called (or I'll do this pre-action firing). I will then check the user's cookie, and load the user object based on the sessionid in the cookie. I will then add the user object to the request attributes. Now if I want to retrieve the user object in my cont...