Hi Vishal,

If you did the persistence tutorial, you should have the following bean
definition in your Spring configuration file:

 <bean id="personDao" class="org.appfuse.dao.hibernate.GenericDaoHibernate">
         <constructor-arg value="org.appfuse.tutorial.model.Person"/>
       <property name="sessionFactory" ref="sessionFactory"/>

</bean>

in which case you could use

<bean id="personManager" class="
org.appfuse.tutorial.service.impl.PersonManagerImpl">
  <constructor-arg ref="personDao"/>
</bean>

Spring is basically complaining that the personDao bean definition is
missing from your configuration files.

AppFuse gives you some choice with respect to Dao's. Either you can write
your own Dao's  (as per the persistence tutorial), or, if all you want is
basic CRUD, use the GenericDao which is basically the second configuration
you have above. The idea is to save you coding - you only write your own Dao
or manager if you want some custom functionality, such as a search method,
in all other cases you use the generic versions.

Mike




On 7/6/07, Vishal S <[EMAIL PROTECTED]> wrote:


Hi Tobias,

Thank you very much for your response. I am a little confused here.

'Register your Manager Implementation' section in
http://appfuse.org/display/APF/Services for reference  says

Open your src/main/webapp/WEB-INF/applicationContext.xml file and replace
the personDao   bean with the following:

<bean id="personManager"
class="org.appfuse.tutorial.service.impl.PersonManagerImpl">
   <constructor-arg ref="personDao"/>
</bean>

  So I replaced

<bean id="personManager"
class="org.appfuse.service.impl.GenericManagerImpl">
   <constructor-arg>
       <bean class="org.appfuse.dao.hibernate.GenericDaoHibernate"
autowire="byType">
           <constructor-arg value="org.appfuse.tutorial.model.Person"/>
       </bean>
   </constructor-arg>
</bean>

  with the first one, can somebody clarify me here.

  Thank you.

Vishal





Tobias Vogel wrote:
>
> You don't have a personDao configured in your applicationContext.xml.
You
> either have to define one, or construct it on the fly:
>
> <bean id="personManager"
> class="org.appfuse.service.impl.GenericManagerImpl">
>     <constructor-arg>
>         <bean class="org.appfuse.dao.hibernate.GenericDaoHibernate"
> autowire="byType">
>             <constructor-arg value="org.appfuse.tutorial.model.Person"/>
>         </bean>
>     </constructor-arg>
> </bean>
>
> See http://appfuse.org/display/APF/Services for reference.
>
> Kind regards,
> Tobias
>
>
> -----Ursprüngliche Nachricht-----
> Von: Vishal S [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 5. Juli 2007 18:27
> An: [email protected]
> Betreff: [appfuse-user] Error while running test [mvn test
> -Dtest=PersonListTest]
>
>
> Hello Friends
>
>   My working environment is
>
>   AppFuse 2
>   JDK - 1.6
>   Maven - 2.0.7
>   OS - Windows 2003
>
>   I am new to AppFuse, I have successfully completed the following part
of
> the tutorial
>
>    1. Create a Person Entity.
>    2. Create a PersonDao in Hibernate, iBATIS or JPA.
>    3. Create a PersonManager to act as a service facade to PersonDao.
>    4. Create the web tier using JSF, Struts 2, Spring MVC or Tapestry.
>
>     When I tried to do the the JSF part of tutorial (Using JSF). I got
> stuck at the PersonListTest.
>
>     When I issued the following command.
>
>     mvn test -Dtest=PersonListTest
>
>     The following errors were listed. Errors are listed below the
relevant
> source code.
>
>      Please help.
>
>      Thank you.
>
> Vishal S
>
>
> ******************************************
> PersonListTest.java
> ******************************************
> package com.mycompany.webapp.action;
>
> import org.appfuse.webapp.action.BasePageTestCase;
> import org.appfuse.service.GenericManager;
> import com.mycompany.model.Person;
>
> public class PersonListTest extends BasePageTestCase {
>     private PersonList bean;
>
>     protected void setUp() throws Exception {
>         super.setUp();
>         bean = (PersonList) getManagedBean("personList");
>         GenericManager<Person, Long> personManager =
>                 (GenericManager<Person, Long>)
> applicationContext.getBean("personManager");
>
>         // add a test person to the database
>         Person person = new Person();
>         person.setFirstName("Abbie Loo");
>         person.setLastName("Raible");
>         personManager.save(person);
>     }
>
>     protected void tearDown() throws Exception {
>         super.tearDown();
>         bean = null;
>     }
>
>     public void testSearch() throws Exception {
>         assertTrue(bean.getPersons().size() >= 1);
>         assertFalse(bean.hasErrors());
>     }
> }
> ****************************************** End of  PersonListTest.java
>
>
>
> ******************************************
> PersonList.java
> ******************************************
> package com.mycompany.webapp.action;
>
> import java.io.Serializable;
> import java.util.List;
>
> import org.appfuse.webapp.action.BasePage;
> import com.mycompany.service.PersonManager;
>
> public class PersonList extends BasePage implements Serializable {
>     private PersonManager personManager;
>
>     public void setPersonManager(PersonManager manager) {
>         this.personManager = manager;
>     }
>
>     public PersonList() {
>         setSortColumn("id"); // sets the default sort column
>     }
>
>     public List getPersons() {
>         return sort(personManager.getAll());
>     }
> }
> ******************************************End of PersonList.java
>
>
>
> ******************************************
> Changes made in faces-config.xml
> ******************************************
> <managed-bean>
>    <managed-bean-name>personList</managed-bean-name>
>
> <managed-bean-class>com.mycompany.webapp.action.PersonList
</managed-bean-class>
>    <managed-bean-scope>request</managed-bean-scope>
>    <managed-property>
>       <property-name>personManager</property-name>
>       <value>#{personManager}</value>
>    </managed-property>
> </managed-bean>
>
>
>
> ******************************************
> applicationContext.xml
> ******************************************
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>                  xsi:schemaLocation="
http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>
>
>       <bean id="personManager"
> class="com.mycompany.service.impl.PersonManagerImpl">
>               <constructor-arg ref="personDao"/>
>       </bean>
>       <!-- Add new Managers here -->
> </beans>
>
>
>
>
> ******************************************
> ERROR LISTING
> ******************************************
> [myproject] ERROR [main] ContextLoader.initWebApplicationContext(203) |
> Context initialization failed
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> with name 'personManager' defined in ServletContext resource
> [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
> 'personDao' while setting constructor argument; nested exception is
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'personDao' is defined
> Caused by:
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'personDao' is defined
>       at
>
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition
(DefaultListableBeanFactory.java:353)
>       at
>
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition
(AbstractBeanFactory.java:916)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:243)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:160)
>       at
>
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference
(BeanDefinitionValueResolver.java:261)
>       at
>
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary
(BeanDefinitionValueResolver.java:109)
>       at
>
org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments
(ConstructorResolver.java:389)
>       at
>
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor
(ConstructorResolver.java:120)
>       at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor
(AbstractAutowireCapableBeanFactory.java:800)
>       at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance
(AbstractAutowireCapableBeanFactory.java:720)
>       at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:387)
>       at
>
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(
AbstractBeanFactory.java:251)
>       at
>
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton
(DefaultSingletonBeanRegistry.java:156)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:248)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:160)
>       at
>
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:287)
>       at
> org.springframework.context.support.AbstractApplicationContext.refresh(
AbstractApplicationContext.java:352)
>       at
>
org.springframework.web.context.ContextLoader.createWebApplicationContext(
ContextLoader.java:244)
>       at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(
ContextLoader.java:187)
>       at
> org.springframework.web.context.ContextLoaderListener.contextInitialized
(ContextLoaderListener.java:49)
>       at
> org.appfuse.webapp.action.BasePageTestCase.<clinit>(
BasePageTestCase.java:51)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
>       at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>       at junit.framework.TestSuite.createTest(TestSuite.java:54)
>       at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
>       at junit.framework.TestSuite.<init>(TestSuite.java:140)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
>       at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>       at
> org.apache.maven.surefire.junit.JUnitTestSet.constructTestObject(
JUnitTestSet.java:151)
>       at
> org.apache.maven.surefire.junit.JUnitTestSet.getTestCount(
JUnitTestSet.java:247)
>       at
>
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(
AbstractDirectoryTestSuite.java:104)
>       at
> org.apache.maven.surefire.Surefire.createSuiteFromDefinition(
Surefire.java:150)
>       at org.apache.maven.surefire.Surefire.run(Surefire.java:111)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
SurefireBooter.java:290)
>       at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java
:818)
> org.apache.maven.surefire.booter.SurefireExecutionException:
> com.mycompany.webapp.action.PersonListTest; nested exception is
> java.lang.ExceptionInInitializerError: null; nested exception is
> org.apache.maven.surefire.testset.TestSetFailedException:
> com.mycompany.webapp.action.PersonListTest; nested exception is
> java.lang.ExceptionInInitializerError: null
> org.apache.maven.surefire.testset.TestSetFailedException:
> com.mycompany.webapp.action.PersonListTest; nested exception is
> java.lang.ExceptionInInitializerError: null
> java.lang.ExceptionInInitializerError
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
>       at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>       at junit.framework.TestSuite.createTest(TestSuite.java:54)
>       at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
>       at junit.framework.TestSuite.<init>(TestSuite.java:140)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
>       at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>       at
> org.apache.maven.surefire.junit.JUnitTestSet.constructTestObject(
JUnitTestSet.java:151)
>       at
> org.apache.maven.surefire.junit.JUnitTestSet.getTestCount(
JUnitTestSet.java:247)
>       at
>
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(
AbstractDirectoryTestSuite.java:104)
>       at
> org.apache.maven.surefire.Surefire.createSuiteFromDefinition(
Surefire.java:150)
>       at org.apache.maven.surefire.Surefire.run(Surefire.java:111)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
SurefireBooter.java:290)
>       at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java
:818)
> Caused by: org.springframework.beans.factory.BeanCreationException:
Error
> creating bean with name 'personManager' defined in ServletContext
resource
> [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
> 'personDao' while setting constructor argument; nested exception is
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'personDao' is defined
>       at
>
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference
(BeanDefinitionValueResolver.java:269)
>       at
>
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary
(BeanDefinitionValueResolver.java:109)
>       at
>
org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments
(ConstructorResolver.java:389)
>       at
>
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor
(ConstructorResolver.java:120)
>       at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor
(AbstractAutowireCapableBeanFactory.java:800)
>       at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance
(AbstractAutowireCapableBeanFactory.java:720)
>       at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:387)
>       at
>
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(
AbstractBeanFactory.java:251)
>       at
>
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton
(DefaultSingletonBeanRegistry.java:156)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:248)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:160)
>       at
>
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons
(DefaultListableBeanFactory.java:287)
>       at
> org.springframework.context.support.AbstractApplicationContext.refresh(
AbstractApplicationContext.java:352)
>       at
>
org.springframework.web.context.ContextLoader.createWebApplicationContext(
ContextLoader.java:244)
>       at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(
ContextLoader.java:187)
>       at
> org.springframework.web.context.ContextLoaderListener.contextInitialized
(ContextLoaderListener.java:49)
>       at
> org.appfuse.webapp.action.BasePageTestCase.<clinit>(
BasePageTestCase.java:51)
>       ... 22 more
> Caused by:
> org.springframework.beans.factory.NoSuchBeanDefinitionException:
> No bean named 'personDao' is defined
>       at
>
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition
(DefaultListableBeanFactory.java:353)
>       at
>
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition
(AbstractBeanFactory.java:916)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:243)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
AbstractBeanFactory.java:160)
>       at
>
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference
(BeanDefinitionValueResolver.java:261)
>       ... 38 more
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] There are test failures.
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Trace
> org.apache.maven.BuildFailureException: There are test failures.
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
DefaultLifecycleExecutor.java:560)
>       at
>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle
(DefaultLifecycleExecutor.java:480)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(
DefaultLifecycleExecutor.java:459)
>       at
>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:311)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(
DefaultLifecycleExecutor.java:278)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(
DefaultLifecycleExecutor.java:143)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
>       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
>       at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java
:315)
>       at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>       at org.codehaus.classworlds.Launcher.mainWithExitCode(
Launcher.java:430)
>       at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> Caused by: org.apache.maven.plugin.MojoFailureException: There are test
> failures.
>       at
> org.apache.maven.plugin.surefire.SurefirePlugin.execute(
SurefirePlugin.java:425)
>       at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(
DefaultPluginManager.java:443)
>       at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
DefaultLifecycleExecutor.java:539)
>       ... 16 more
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 14 seconds
> [INFO] Finished at: Thu Jul 05 21:22:04 IST 2007
> [INFO] Final Memory: 16M/29M
> [INFO]
> ------------------------------------------------------------------------
>
> --
> View this message in context:
>
http://www.nabble.com/Error-while-running-test--mvn-test--Dtest%3DPersonListTest--tf4030806s2369.html#a11449953
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
Register your Manager Implementation
--
View this message in context:
http://www.nabble.com/Error-while-running-test--mvn-test--Dtest%3DPersonListTest--tf4030806s2369.html#a11458324
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to