spring

Making sure a Spring Bean is properly initialised

What is the most concise way of making sure that a Spring bean has all properties set and the init method called? I'll favour answers which use setter injection and XML configuration, since that's what I'm using right now. I'm trying to evade the case where I either forget to configure a setter or call the init-method. In future ...

SpringJUnit4ClassRunner tests -- work from ant, not from IDE

I have some tests that load up some Spring context files. When I run the tests from my ant target they work as expected. When I run them from IntelliJ I get a NotWritablePropertyException. I initially figured different classpaths, but the only differences are for IntelliJ's test runner. Caused by: org.springframework.beans.NotWritablePr...

Hibernate Save strange behaviour

I have a user object that has a one-to-many relationship with String types. I believe they are simple mappings. The types table hold the associated user_id and variable type names, with a primary key 'id' that is basically a counter. <class name="Users" table="users"> <id column="id" name="id" /> ... <set name="types" table=...

Spring roo Vs (Wicket and Spring)

Spring roo is new framework and I found it very interesting. I have been working on web application for last 3-4 years and Always found JSPs are hard to maintain across teams if everyone is not disciplined enough about separation of markup and serverside logic. I have used JackBe/BackBase in last projects and I enjoyed xml templates work...

Spring: replace SqlMapClientTemplate for all clients?

I have a number of DAO classes that extend SqlMapClientDaoSupport, and call getSqlMapClientTemplate() to run iBatis queries. For a particular test, I wish to replace the object returned when each DAO calls getSqlMapClientTemplate(), with my own custom class. How can I do this? I know that there is a setSqlMapClientTemplate( org.sprin...

Junit4 : expected=Exception not working with SPRING

I'm trying to use the @Test(expected = RuntimeException.class) annotation in order to test for an expected exception. My code is as follows: @Test(expected = RuntimeException.class) public void testSaveThrowsRuntimeException(){ User user = domain.save(null); } and my save method simple like this : publ...

Problem with ModelAndView and ModelMap in AnnotationController, Springframework

I have a question that is a point difference between ModelAndView and ModelMap. I want to maintain modelAndView when requestMethod is "GET" and requestMethod is "POST". My modelAndView saved others. So I made modelAndView return type to "GET", "POST" methods. But, Request lost commandObject, form:errors..., if request return showForm ...

How can I inject a bean into an ApplicationContext before it loads from a file?

I have a FileSystemXmlApplicationContext and I would like the beans defined in the XML to take as a constructor argument a bean which is not declared in Spring For example, I would like to do: <bean class="some.MyClass"> <constructor-arg ref="myBean" /> </bean> So I could imagine doing this via something like: Object myBean = .....

Data access layer with Spring DAO and Hibernate.Problems

hi guys this is my first application in with spring and hibernate.So please bear with me with stupid questions :). i created a simple java application in netbeans 6.7. here are my daos interfaces UsersDAO package Dao; import Entities.Users; public interface UsersDAO { public Long GetIdByUsernameAndPasswor(String username, String ...

Spring DaoSupport and @PersistanceContext EntityManager?

One of the most difficult things about understand Spring is that Spring supports multiple approaches to the same problem. So in my application I using injected EntityManager using the @PersistanceContext annotation, for example: @Repository public class JpaDao extends JpaDaoSupport implements Dao { @PersistenceContext(unitName = "...

Is it hard to convert a web app built with Jsp, Servlets & mySQL to one with Spring & Hibernate?

I'm currently working on building a java web app. I've been looking to use Spring and Hibernate so I get some proper exposure to them, but I'm just getting burned out reading and learning about them. If I go ahead and build it with JSP and Servlets on a MySQL back end, what kind of levels of code reuse would I be looking at? I imagine th...

working with object with spring and hibernate

Hello people! hope everybody is cool.I've been trying to do something with spring-hibernate but it's still a failure.i'm very new to it.i need a little help.supposing a POJO class Users.i want to return an Users object by username.While i had no problem to return Users object by id by doing this return (Users) getHibernateTemplate()....

Oracle - connection Pooling with spring framework

Hi, We are trying to implement Oracle connection pooling with the help of Spring Framework. We are using DBCP connection pooling method. However the integration between DBCP and spring doesn't go down that well. Problem that we face is that DBCP returns PoolableConnections Object while Oracle expects OracleConnection Objects. (Thorws C...

Is Spring hard compared to Ruby on Rails?

If I have no to little experience in either of them, but know enough Java and Ruby to be comfortable, is one framework harder to learn than the other? Is one easier to use for the beginner on these? I know it is hard to answer. Just looking for general thoughts on it. ...

spring beanpostprocessor doesn't work on component-scan?

Hi, I have many cookie-cutter spring beans and don't want to explicitly define each one in xml. So I went the component scanning route which lets me do this. This is nice, but I just realized that MyBeanPostProcessor isn't being called for the beans loaded in using the component-scan technique. MyBeanPostProcessor simply attempts to...

Newbie Spring Config Question

My applicationContext.xml: <bean id="studentService" class="com.coe.StudentService"> <property name="studentProfile" ref="studentProfile" /> </bean> <bean id="studentProfile" class="com.coe.student.StudentProfile"> </bean> My web.xml: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class...

Specifying relative resource path via Spring XmlWebApplicationContext

The actual question is: Is there a way to get XmlWebApplicationContext to load resources using paths relative to the context location? For clarity's sake, let's say "context location" is the location of the first file specified via setConfigLocation() method. Detailed explanation is below: I'm using Spring MVC in web tier and Spring...

postgresql: Large Objects may not be used in auto-commit mode [CLOSED]

Hi, I'm working on a application which uses spring and hibernate. We are using postgresql as the database. When I try to insert a record into a table which has a OID column it is throwing the following error. org.hibernate.exception.GenericJDBCException: could not insert: [com.greytip.cougar.model.misc.MailAttachment] at org.hibernate...

What can be done with 'PermGen out of space' exception in Tomcat-Spring-Hibernate web application?

We have an web application that uses Spring-Hibernate to persist registered users data in Oracle database. The application works fine in development environment, but when we copy it int live environment with much more data, it failed. Initially the application starts normally, but after few actions 'PermGen out of space' exception occure...

why does Spring use XML for component wiring?

Hi all, I understand the IOC concept, which we can mix-and-match different classes using wiring. Every class can get away from hard code it's dependancy by delegating the wiring / relationship handling to base xml (context xml). Here is my question, why do we use xml? we can simply wire all the components by using java class. Instead o...