jquery

gist JS

Monday, December 05, 2005

rod johnson's love for the common man

Add Spring Capabilities...
Add Hibernate Capabilities...


Class:
public class Knight {
public String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString(){
return "My name is "+getName();
}
}


applicationContext.xml
add:
<bean id="Knight" class="com.wos.test.Knight">
<property name="name">
<value>JoJo</value>
</property>
</bean>


TestApplication:
BeanFactory factory = new XmlBeanFactory(new FileSystemResource(new File("src\\applicationContext.xml")));
Knight k = (Knight) factory.getBean("Knight");
System.out.println(k);



Gotcha number 1:
java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
Problem: No commons-pool-1.2.jar
http://jakarta.apache.org/site/downloads/downloads_commons-pool.cgi

Add this to WEB-INF/lib/

Gotcha number 2:
Add:
BasicConfigurator.configure();
To the test app & add a log4j.properties file to get rid of the log4j warnings.

And...

My name is JoJo

Hotdang.



Ok, now we add Hibernate..

hmm, error that it can't find net.sf.HibernateException
odd considering that we're using hibernate3, which should look like org.hibernate...

adding hibernate2.jar to the /lib... and we're past that one.

Now it's:
PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy0] to required type [net.sf.hibernate.SessionFactory] for property 'sessionFactory']

Looks sketchily like another hibernate 2 v 3 problem to me. does spring perhaps not support hibernate 3? Worth checking...

hah!!!!! spring "not support hibernate"?? what a joke. Spring is a super star. The problem is MyEclipse. It brings in such a hunk of jar's that it turns out you can get one's that reference different version of hibernate. I think I'll be adding jars myself from now on.

Now it's all set. And if AbstractTransactionalDataSourceSpringContextTests isn't the end all expression of Rod Johnson's love for the common man, I don't know what is.

Just remember to use:

on your datasource, or you could end up doing a bit more comitting than you meant to ;)

No comments: