spring

TestNG and Spring 3

Hi guys, What is the best practice way to do unit testing with Spring? I assume the combination TestNG & jmockit with Spring 3 isn't bad, so that's what I'm doing right now, but if I'm off course selecting the tools for my fresh Spring project, please tell me right away. :-) Anyways, I've created an entity that I want to test, but I'm n...

Spring Entity to use Service, possible design flaw, but still....

Hi guys, The legacy database I'm "springwrapping" has Id's that are Strings and that give away some information. For instance, a UserId looks like "DK-6715-00001", meaning a user in Denmark, postal code 6715. This is so wrapped into the enterprise applications that it needs to be kept and my entities verify this in their setter methods....

Handling transactions spanning across database servers

I have a scenario where the unit of work is defined as: Update table T1 in database server S1 Update table T2 in database server S2 And I want the above unit of work to happen either completely or none at all (as the case with any database transaction). How can I do this? I searched extensively and found this post close to what I am e...

Proper way to autowire a Hibernate Session in a Spring Transaction JUnit test

This question is similar to a previous one. I am trying to @Autowire a Hibernate Session in one of my Spring-JUnit-Transactional tests but I am getting this exception: java.lang.IllegalStateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional ... Here is my JUnit class: @RunWi...

Struts - Uploading Files

I'm having a problem uploading a file using spring webflow 1.0 and struts 1.3. The jsp is something like this: <html:form action="/flowAction" method="post" enctype="multipart/form-data"> <!-- snip --> <html:file property="file" name="attachDocumentsForm" size="50"/> <!-- snip --> </html:form> The Form is something like t...

how to add filterclass into applicationContext?

I have a filterclass that i normally will put in web.xml. may i know how to specify it inside spring applicationcontext so that i able to use spring features in my fitlerclass? ...

Reading InBox With Grails/Groovy?

DO I need to inject the JavaMail Objects into the application context and access my inbox the old fashion way or is there some "magic" in grails to handle it for me? ...

Start the H2 database in server mode via Spring

I'm trying to start the H2 database in server mode (I want it to run in a different process) via Spring. Currently I'm using java Runnable.exec to start the h2 database (using the command: "java -cp h2.jar org.h2.tools.Server") I know that there is a way to do it via Spring. I tried to add the following to the spring configuration, but ...

Apache Camel Spring configuration problem - Unable to locate Spring NamespaceHandler for XML schema namespace [http://camel.apache.org/schema/spring]

I've posted an excerpt from my spring.xml file and the stack trace I'm getting. <?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:lang="http://www.springframework.org/schema/lang" xmlns:util="http://www.springframework.org...

Spring JSR303 validation doesn't work like described in Spring Documentation

I tried implementing validation for my web application like described in section 5.7.4.3 of the Spring 3.0 documentation: <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="webBindingInitializer"> <bean class="org.springframework.web.bind.support.ConfigurableWebBindin...

Injecting Log4J loggers with Spring

Hi, I have a spring 2.5 webapp with the following web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>Spring ...

Reproduce com.mysql.jdbc.exceptions.jdbc4.CommunicationsException with a setup of Spring, hibernate and C3P0

I got this error from the production code: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was36940 seconds ago.The last packet sent successfully to the server was 36940 seconds ago, which is longer than the server configured value of 'wait_timeout'. You sho...

how do I configure autowire in spring

how do I configure autowire in spring ...

Problem managing session with multiple data sources

I am working on a project where we each service refers four separate data-source. Until now, we have been using ProxyFactoryBean to refer to the Dao target and the Transaction Intereceptor - something like this.. <bean id="readOnlyUserProxy" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target" ref="read...

java inserting date into database

hi, can someone please tell me the elegant way of inserting a java date instance into database? presently, i am using IBATIS with Spring MVC . i have defined a java.util.date property in the command bean and property editor in the controller for Date conversion, however i am unable to insert java.util.date property in DB . should i c...

Spring DI, Domain Model & best practices

Is it a good idea to not inject Domain Models in Spring. It saves some XML, and what is the use of injecting domain model anyway. For services and DAO, I want to decouple so I use DI, but Domain Model usually flows all the way from Web to DAO - sort of a vertical layer running through the horizontals. What do you think? Good or bad? Ar...

Spring / JTA / JPA unit test : Rollback not working.

I am trying to test an entity EJB3 with Spring. The EJB itself does not uses Spring and I would like to keep duplications of the production JPA configuration minimal (ie not duplicating persistence.xml for exemple). My unit tests seems to work but even though my unit tests should be transactionnal, data is persisted between the various...

Import Spring config file based on property in .properties file

In my Spring xml configuration I'm trying to get something like this to work: <beans> <import resource="${file.to.import}" /> <!-- Other bean definitions --> </beans> I want to decide which file to import based on a property in a properties file. I know that I can use a System property, but I can't add a property to the JVM a...

using quartz in a web app with spring

Hello good fellas! I've created a small console application to see how quartz work and it was easy to create an applicationcontext object inside the main method to get the cron run. OK now I'm in a real project managed by maven and which is using cron jobs defined in some of the modules. Each of the module has his own spring config file...

scope of a controller and a validator

We are developing an application using Spring MVC. There is a page which displays list of user, a check box next to it, and a submit button at the bottom of the page. A logged in user can select those check boxes and submit, currently a controller checks whether the selected user list is empty or not and acts accordingly. Should we just...