PDA

View Full Version : Error using Maven with Spring / cannot run unit test..



MmarcoM
Sep 30th, 2004, 01:48 PM
hello all,
i am a newbie with Spring and i am experiencing problems in running jUnit test cases with Spring.
I am using Maven 1.0 to build my application.
structure of directory in my project is

src/java contains all java source
target/ generated by maven, contains all generated classes
test/java

after classes are compiled (and thus placed in target/classes directory), i place in that directory also the hibernate .hbm. files.
applicationContext.xml is placed in the target/classes directory.

when i run my tests, i got following exception( i includefull stack trace):

2004-09-30 18:50:45,359 DEBUG com.myapp.hibernate.HibernatePersistenceManager [
main] - Creating HibernatePM..
[junit] Running com.myapp.hibernate.HibernatePersistenceManagerTes t
2004-09-30 18:50:46,156 INFO org.springframework.beans.factory.xml.XmlBeanDefi
nitionReader [main] - Loading XML bean definitions from URL [file:/c:/Sw/applic
ationContext.xml]
2004-09-30 18:50:46,156 DEBUG org.springframework.beans.factory.xml.XmlBeanDefi
nitionReader [main] - Using JAXP implementation [org.apache.xerces.jaxp.Documen
tBuilderFactoryImpl@14b74a7]
2004-09-30 18:50:46,171 DEBUG org.springframework.context.support.ResourceEntit
yResolver [main] - Trying to resolve XML entity with public ID [-//SPRING//DTD
BEAN//EN] and system ID [http://www.springframework.org/dtd/spring-beans.dtd]
2004-09-30 18:50:46,171 DEBUG org.springframework.context.support.ResourceEntit
yResolver [main] - Trying to locate [spring-beans.dtd] under [/org/springframew
ork/beans/factory/xml/]
2004-09-30 18:50:46,171 DEBUG org.springframework.context.support.ResourceEntit
yResolver [main] - Found beans DTD [http://www.springframework.org/dtd/spring-b
eans.dtd] in classpath
2004-09-30 18:50:46,187 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Loading bean definitions
2004-09-30 18:50:46,203 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Default lazy init 'false'
2004-09-30 18:50:46,203 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Default dependency check 'none'
2004-09-30 18:50:46,203 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Default autowire 'no'
2004-09-30 18:50:46,234 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Registering bean definition with id 'sessionFactor
y'
2004-09-30 18:50:46,312 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Registering bean definition with id 'transactionMa
nager'
2004-09-30 18:50:46,312 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Registering bean definition with id 'persistenceMa
nager'
2004-09-30 18:50:46,312 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Found 3 <bean> elements defining beans
2004-09-30 18:50:46,312 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - Bean factory for application context [org.springfra
mework.context.support.FileSystemXmlApplicationCon text;hashCode=6997525]: org.sp
ringframework.beans.factory.support.DefaultListabl eBeanFactory defining beans [s
essionFactory,transactionManager,persistenceManage r]; Root of BeanFactory hierar
chy
2004-09-30 18:50:46,328 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - 3 beans defined in ApplicationContext [org.springfr
amework.context.support.FileSystemXmlApplicationCo ntext;hashCode=6997525]
2004-09-30 18:50:46,328 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - No MessageSource found for context [org.springframe
work.context.support.FileSystemXmlApplicationConte xt;hashCode=6997525]: using em
pty default
2004-09-30 18:50:46,343 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - No ApplicationEventMulticaster found for context [o
rg.springframework.context.support.FileSystemXmlAp plicationContext;hashCode=6997
525]: using default
2004-09-30 18:50:46,343 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - Refreshing listeners
2004-09-30 18:50:46,343 DEBUG org.springframework.context.support.FileSystemXml
ApplicationContext [main] - Found 0 listeners in bean factory
2004-09-30 18:50:46,343 INFO org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Pre-instantiating singletons in factory [org.sprin
gframework.beans.factory.support.DefaultListableBe anFactory defining beans [sess
ionFactory,transactionManager,persistenceManager]; Root of BeanFactory hierarchy
]
2004-09-30 18:50:46,343 INFO org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Creating shared instance of singleton bean 'sessio
nFactory'
2004-09-30 18:50:46,343 DEBUG org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Creating instance of bean 'sessionFactory' with me
rged definition [Root bean with class [org.springframework.orm.hibernate.LocalSe
ssionFactoryBean] defined in URL [file:/c:/Sw/applicationContext.xml]]
2004-09-30 18:50:46,421 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Getting BeanInfo for class [org.springframework.orm.hibernate.Loca
lSessionFactoryBean]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Caching PropertyDescriptors for class [org.springframework.orm.hib
ernate.LocalSessionFactoryBean]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'class' of type [class java.lang.Class]; editor=[nu
ll]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'configLocation' of type [interface org.springframe
work.core.io.Resource]; editor=[null]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'configuration' of type [class net.sf.hibernate.cfg
.Configuration]; editor=[null]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'dataSource' of type [interface javax.sql.DataSourc
e]; editor=[null]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'entityInterceptor' of type [interface net.sf.hiber
nate.Interceptor]; editor=[null]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'hibernateProperties' of type [class java.util.Prop
erties]; editor=[null]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'jtaTransactionManager' of type [interface javax.tr
ansaction.TransactionManager]; editor=[null]
2004-09-30 18:50:46,437 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'lobHandler' of type [interface org.springframework
.jdbc.support.lob.LobHandler]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'mappingDirectoryLocations' of type [class [Lorg.sp
ringframework.core.io.Resource;]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'mappingJarLocations' of type [class [Lorg.springfr
amework.core.io.Resource;]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'mappingLocations' of type [class [Lorg.springframe
work.core.io.Resource;]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'mappingResources' of type [class [Ljava.lang.Strin
g;]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'namingStrategy' of type [interface net.sf.hibernat
e.cfg.NamingStrategy]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'object' of type [class java.lang.Object]; editor=[
null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'objectType' of type [class java.lang.Class]; edito
r=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'schemaUpdate' of type [boolean]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Found property 'singleton' of type [boolean]; editor=[null]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
is cache-safe
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- About to invoke write method [public void org.springframework.orm.hibernate.L
ocalSessionFactoryBean.setMappingResources(java.la ng.String[])] on object of cla
ss [org.springframework.orm.hibernate.LocalSessionFact oryBean]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- Invoked write method [public void org.springframework.orm.hibernate.LocalSess
ionFactoryBean.setMappingResources(java.lang.Strin g[])] with value [[Ljava.lang.
String;@75b3ee]
2004-09-30 18:50:46,453 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- About to invoke write method [public void org.springframework.orm.hibernate.L
ocalSessionFactoryBean.setHibernateProperties(java .util.Properties)] on object o
f class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
2004-09-30 18:50:46,468 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- Invoked write method [public void org.springframework.orm.hibernate.LocalSess
ionFactoryBean.setHibernateProperties(java.util.Pr operties)] with value of type
[java.util.Properties]
2004-09-30 18:50:46,468 DEBUG org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Invoking BeanPostProcessors before initialization
of bean 'sessionFactory'
2004-09-30 18:50:46,468 DEBUG org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Calling afterPropertiesSet() on bean with beanName
'sessionFactory'
2004-09-30 18:50:46,500 INFO net.sf.hibernate.cfg.Environment [main] - Hibern
ate 2.1.6
2004-09-30 18:50:46,500 INFO net.sf.hibernate.cfg.Environment [main] - hibern
ate.properties not found
2004-09-30 18:50:46,515 INFO net.sf.hibernate.cfg.Environment [main] - using
CGLIB reflection optimizer
2004-09-30 18:50:46,515 INFO org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Destroying singletons in factory {org.springframew
ork.beans.factory.support.DefaultListableBeanFacto ry defining beans [sessionFact
ory,transactionManager,persistenceManager]; Root of BeanFactory hierarchy}
Exception in HibernateEntryTest.setup()
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
h name 'sessionFactory' defined in URL [file:/c:/Sw/applicationContext.xml]: Ini
tialization of bean failed; nested exception is java.io.FileNotFoundException: C
ould not open class path resource [com/myapp/hibernate/HibernateEntry.hmb.xml]
a today date isThu Sep 30 18:50:46 GMT 2004
2004-09-30 18:50:46,531 ERROR com.myapp.hibernate.HibernatePersistenceManager [
main] - INSERTING ENTRY...:TestExpense
2004-09-30 18:50:46,546 ERROR com.myapp.hibernate.HibernatePersistenceManager [
main] - Exception in creating HibernateEntry
java.lang.NullPointerException
Exception in testCreateEntry!
com.myapp.exceptions.PersistenceException: java.lang.NullPointerException
2004-09-30 18:50:46,609 INFO org.springframework.beans.factory.xml.XmlBeanDefi
nitionReader [main] - Loading XML bean definitions from URL [file:/c:/Sw/applic
ationContext.xml]
2004-09-30 18:50:46,609 DEBUG org.springframework.beans.factory.xml.XmlBeanDefi
nitionReader [main] - Using JAXP implementation [org.apache.xerces.jaxp.Documen
tBuilderFactoryImpl@1abf87]
2004-09-30 18:50:46,640 DEBUG org.springframework.context.support.ResourceEntit
yResolver [main] - Trying to resolve XML entity with public ID [-//SPRING//DTD
BEAN//EN] and system ID [http://www.springframework.org/dtd/spring-beans.dtd]
2004-09-30 18:50:46,640 DEBUG org.springframework.context.support.ResourceEntit
yResolver [main] - Trying to locate [spring-beans.dtd] under [/org/springframew
ork/beans/factory/xml/]
2004-09-30 18:50:46,640 DEBUG org.springframework.context.support.ResourceEntit
yResolver [main] - Found beans DTD [http://www.springframework.org/dtd/spring-b
eans.dtd] in classpath
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Loading bean definitions
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Default lazy init 'false'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Default dependency check 'none'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Default autowire 'no'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Registering bean definition with id 'sessionFactor
y'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Registering bean definition with id 'transactionMa
nager'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Registering bean definition with id 'persistenceMa
nager'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.xml.DefaultXmlB
eanDefinitionParser [main] - Found 3 <bean> elements defining beans
2004-09-30 18:50:46,656 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - Bean factory for application context [org.springfra
mework.context.support.FileSystemXmlApplicationCon text;hashCode=2707298]: org.sp
ringframework.beans.factory.support.DefaultListabl eBeanFactory defining beans [s
essionFactory,transactionManager,persistenceManage r]; Root of BeanFactory hierar
chy
2004-09-30 18:50:46,656 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - 3 beans defined in ApplicationContext [org.springfr
amework.context.support.FileSystemXmlApplicationCo ntext;hashCode=2707298]
2004-09-30 18:50:46,656 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - No MessageSource found for context [org.springframe
work.context.support.FileSystemXmlApplicationConte xt;hashCode=2707298]: using em
pty default
2004-09-30 18:50:46,656 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - No ApplicationEventMulticaster found for context [o
rg.springframework.context.support.FileSystemXmlAp plicationContext;hashCode=2707
298]: using default
2004-09-30 18:50:46,656 INFO org.springframework.context.support.FileSystemXml
ApplicationContext [main] - Refreshing listeners
2004-09-30 18:50:46,656 DEBUG org.springframework.context.support.FileSystemXml
ApplicationContext [main] - Found 0 listeners in bean factory
2004-09-30 18:50:46,656 INFO org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Pre-instantiating singletons in factory [org.sprin
gframework.beans.factory.support.DefaultListableBe anFactory defining beans [sess
ionFactory,transactionManager,persistenceManager]; Root of BeanFactory hierarchy
]
2004-09-30 18:50:46,656 INFO org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Creating shared instance of singleton bean 'sessio
nFactory'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Creating instance of bean 'sessionFactory' with me
rged definition [Root bean with class [org.springframework.orm.hibernate.LocalSe
ssionFactoryBean] defined in URL [file:/c:/Sw/applicationContext.xml]]
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.CachedIntrospectionResu
lts [main] - Using cached introspection results for class [org.springframework.
orm.hibernate.LocalSessionFactoryBean]
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- About to invoke write method [public void org.springframework.orm.hibernate.L
ocalSessionFactoryBean.setMappingResources(java.la ng.String[])] on object of cla
ss [org.springframework.orm.hibernate.LocalSessionFact oryBean]
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- Invoked write method [public void org.springframework.orm.hibernate.LocalSess
ionFactoryBean.setMappingResources(java.lang.Strin g[])] with value [[Ljava.lang.
String;@25b72a]
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- About to invoke write method [public void org.springframework.orm.hibernate.L
ocalSessionFactoryBean.setHibernateProperties(java .util.Properties)] on object o
f class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.BeanWrapperImpl [main]
- Invoked write method [public void org.springframework.orm.hibernate.LocalSess
ionFactoryBean.setHibernateProperties(java.util.Pr operties)] with value of type
[java.util.Properties]
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Invoking BeanPostProcessors before initialization
of bean 'sessionFactory'
2004-09-30 18:50:46,656 DEBUG org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Calling afterPropertiesSet() on bean with beanName
'sessionFactory'
2004-09-30 18:50:46,671 INFO org.springframework.beans.factory.support.Default
ListableBeanFactory [main] - Destroying singletons in factory {org.springframew
ork.beans.factory.support.DefaultListableBeanFacto ry defining beans [sessionFact
ory,transactionManager,persistenceManager]; Root of BeanFactory hierarchy}
Exception in HibernateEntryTest.setup()
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
h name 'sessionFactory' defined in URL [file:/c:/Sw/applicationContext.xml]: Ini
tialization of bean failed; nested exception is java.io.FileNotFoundException: C
ould not open class path resource [com/myapp/hibernate/HibernateEntry.hmb.xml]
[junit] Tests run: 2, Failures: 1, Errors: 0, Time elapsed: 1.312 sec
[junit] [ERROR] TEST com.myapp.hibernate.HibernatePersistenceManagerTes t FAI
LED


it seems to me that spring cannot locate the com.myapp.hibernate.HibernateEntry.hmb.xml

but it is in target/classes directory....

anyone can help?
thanks in advance and regards
marco

peterb
Oct 1st, 2004, 04:27 AM
I guess you should use a ClassPathXMLApplicationContext instead of a FileSystem . :)

I'am trying to run spring/hibernate with tomcat. There is a bean creation problem cause spring can't find the class path resource as stated in the applicationcontext. It seems like a simple problem but I can't find what's wrong
Here is the applicationContext:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<!-- ========================= GENERAL DEFINITIONS ========================= -->

<!-- Message source for this context, loaded from localized "messages_xx" files
<bean id="messageSource" class="org.springframework.context.support.ResourceBundle MessageSource">
<property name="basename"><value>messages</value></property>
</bean>
-->
<!-- ========================= Start of PERSISTENCE DEFINITIONS ========================= -->

<!-- NOTE: Choose exactly 1 "dataSource" bean and 1 "clinicTarget" bean -->

<!-- Local HSQL DataSource that works in any environment -->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"><value>org.gjt.mm.mysql.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/course1</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>braken</value></property>
</bean>

<!-- Hibernate SessionFactory for MySql -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFact oryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>hibernate-mapping/UserLogin.hbm.xml</value> :(
<value>hibernate-mapping/UserProfile.hbm.xml</value>
<value>hibernate-mapping/Role.hbm.xml</value>
<value>hibernate-mapping/Course.hbm.xml</value>
<value>hibernate-mapping/CourseClass.hbm.xml</value>
<value>hibernate-mapping/CourseCondition.hbm.xml</value>
<value>hibernate-mapping/CourseResult.hbm.xml</value>
<value>hibernate-mapping/CourseRuntime.hbm.xml</value>
<value>hibernate-mapping/Criterium.hbm.xml</value>
<value>hibernate-mapping/CourseBlockCriterium.hbm.xml</value>
<value>hibernate-mapping/Period.hbm.xml</value>
<value>hibernate-mapping/Score.hbm.xml</value>
<value>hibernate-mapping/Lesson.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.query.substitutions">true=1 false=0</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransac tionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>



<!-- Transactional proxy for the course primary business object -->
<bean id="course" class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<property name="transactionManager"><ref local="transactionManager"/></property>
<property name="target"><ref local="courseFacade"/></property>
<property name="transactionAttributes">
<props>

<prop key="store*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
<!--prop key="*">PROPAGATION_REQUIRED</prop-->
</props>
</property>
</bean>

<!-- a primary business object: Hibernate implementation -->
<bean id="userTarget" class="org.kissolutions.user.domain.hibernate.HibernateUs erDao">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<!-- a primary business object: Hibernate implementation -->
<bean id="courseTarget" class="org.kissolutions.course.domain.hibernate.Hibernate CourseDao">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- a primary business object: Hibernate implementation -->
<bean id="courseConditionTarget" class="org.kissolutions.coursecondition.domain.hibernate. HibernateCourseConditionDao">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<bean id="testTarget" class="org.kissolutions.test.TestContextDao">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<bean id="courseFacade" class="org.kissolutions.business.CourseImpl">
<property name="userDao">
<ref local="userTarget"/>
</property>
<property name="courseDao">
<ref local="courseTarget"/>
</property>
<property name="courseConditionDao">
<ref local="courseConditionTarget"/>
</property>
<property name="testDao">
<ref local="testTarget"/>
</property>
</bean>
<!-- ========================= End of PERSISTENCE DEFINITIONS ========================= -->

</beans>


Anyone have a clou

thanks,
peter

peterb
Oct 1st, 2004, 04:53 AM
Some how thougth that the classpath started from WEB-INF down

MmarcoM
Oct 1st, 2004, 08:28 AM
hello there,
thanx for the reply.well then if it starts from WEB-INF i should already have the jar generated even before i run my tests..
according to maven, if i run the test within the same project, the classes won't get generated until the tests run successfully...

i have tried to use ClassPathXmlApplicationContext, but got no help..same error happens..

can anyone who is having success in running maven tests wtih spring shows up and show the way?

thanx in advance and regards
marco

thomasvdv
Oct 4th, 2004, 01:56 PM
Maybe a stupid point but did you check that Maven copies your mapping files to the classpath?

<build>
<sourceDirectory>${basedir}/src/java</sourceDirectory>
<unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
<include>**/*.xml</include>
</includes>
<excludes>
<exclude>**/*Test*All.java</exclude>
</excludes>
</unitTest>
<resources>
<resource>
<directory>src/conf</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/java</directory>
<includes>
<include>**/*.hbm.xml</include> </includes>
<filtering>false</filtering>
</resource>
</resources>
</build>

MmarcoM
Oct 5th, 2004, 02:36 PM
hello,
thanx for the reply.... i have tried many solutions,and right now what i got is

EXCEPTION IN SETUP
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
h name 'sessionFactory' defined in class path resource [applicationContext.xml]:
Initialization of bean failed; nested exception is java.io.FileNotFoundExceptio
n: Could not open class path resource [com/myapp/hibernate/HibernateEntry.hmb.xm
l]
Callingt est...
i really don't know what to do...

below is my project.xml and maven.xml.... i have the applicationContext.xml in the directory target/classes, and i don't know why it does not find it

*** project.xml ******
<?xml version="1.0"?>
<!-- Define references to files containing common targets -->
<!DOCTYPE project [
<!ENTITY xdoclet-common SYSTEM
"file:${basedir}/../xdoclet-commons.ent">
<!ENTITY hibernate-common SYSTEM
"file:${basedir}/../hibernate-commons.ent">
<!ENTITY framework-common SYSTEM
"file:${basedir}/../framework-commons.ent">

]>


<project>
<extend>${basedir}/../project.xml</extend>
<id>Backend</id>
<name>Backend Middleware</name>
<package>com.myapp.*</package>
<description>Backend JAR project.</description>
<shortDescription>Project that contains implementation for backend services</shortDescription>

<build>
<nagEmailAddress>mistroni@mistroni.fsworld.co.uk</nagEmailAddress>
<sourceDirectory>${basedir}/src/java</sourceDirectory>
<unitTestSourceDirectory>${basedir}/test/java</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>

<resources>
<resource>
<directory>${basedir}src/conf</directory>
<includes>
<include>applicationContext.xml</include>
</includes>
</resource>

<resource>
<directory>${basedir}</directory>
<includes>
<include>*.*</include>
</includes>
</resource>
<resource>
<directory>${ basedir}/hibernate</directory>
<includes>
<include>**/*.hbm.xml</include> </includes>
</resource>



</resources>
</build>

<!-- Project dependencies -->
<dependencies>
&xdoclet-common;
&hibernate-common;
&framework-common;

<dependency>
<groupId>Budget-Project</groupId>
<artifactId>Commons</artifactId>
<version>${pom.currentVersion}</version>
<properties>
<war.bundle>true</war.bundle>
<war.manifest.classpath>true</war.manifest.classpath>
</properties>
</dependency>

</dependencies>

</project>

**** maven.xml ****
<?xml version="1.0"?>
<project xmlns:m="jelly:maven"
xmlns:ant="jelly:ant">
<goal name="budget-dist">
<attainGoal name="xdoclet:ejbdoclet"/>
<attainGoal name="xdoclet:webdoclet"/>
<attainGoal name="xdoclet:hibernatedoclet"/>
<echo>Copying castor mapping....</echo>
<ant:copy file="${backend.castormapping}" toDir="${basedir}/src/conf"/>
<echo>Copying hibernate files....</echo>
<ant:copy toDir="${backend.classesDir}">
<ant:fileset dir="${backend.hibernatefiles}"/>
</ant:copy>
<attainGoal name="jar:install"/>
</goal>

<postGoal name="jar:install">
<ant:copy file="${backend.appcontext}" toDir="${backend.classesDir}"/>

</postGoal>


</project>


things that i cannot understand is where do i have to put the files?
they are in the target/classes directory.. why applicationContext cannot find them?
even applicationContext.xml is in the classes directory...

anyone can pls help me out? i am stuck since 1 week....

regards
marco

jbetancourt
Oct 5th, 2004, 03:19 PM
Is this with Spring 1.1.1?

MmarcoM
Oct 6th, 2004, 02:57 AM
hello all,

i have solved the problem....and sorry for bothering all of you.
It was my stupid mistake, i declared in applicationContext all Hibernate related classes with an extension of .hmb.xml instead of .hbm.xml

apologies to all !

thanx and regards
marco