AppFuse JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile
  • AppFuse
  • APF-998

PersonDaoTest fails in tutorial-jpa

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.1
  • Fix Version/s: 2.0.2
  • Component/s: Documentation
  • Labels:
    None

Description

From http://www.nabble.com/AppFuse-2.0.1---Error-while-testing-the-tutorial-jpa-module-from-appfuse-demos-to14254631s2369.html#a14254631:

I tried the tutorial-jpa module from appfuse-demos. If you run mvn test -Dtest=PersonDaoTest you get the following error message:

-------------------------------------------------------------------------------
Test set: org.appfuse.tutorial.dao.PersonDaoTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.444 sec <<< FAILURE!
testFindPersonByLastName(org.appfuse.tutorial.dao.PersonDaoTest) Time elapsed: 0.401 sec <<<
ERROR!
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean
with name 'org.appfuse.tutorial.dao.PersonDaoTest': Unsatisfied dependency expressed
through bean property 'personDao': Set this property value or disable dependency
checking for this bean.

I only can avoid it if I move the <bean id="personDao" class="org.appfuse.tutorial.dao.jpa.PersonDaoJpa"/> entry from src/main/webapp/WEB-INF/applicationContext.xml to src/main/resources/applicationContext-resources.xml.

If this is the only way to do it then it would be an error in your tutorial, because you mention explicitely that src/main/webapp/WEB-INF/applicationContext.xml is the prefered location if you have a base archetype.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Source
Hide
Permalink
vijay added a comment - 21/Jan/08 1:17 AM
For me, this issue seems to come up only while running the tests
While running a test, the context path for Spring are set to
 AbstractSingleSpringContextTests.loadContextLocations(210) | Loading context for locations: classpath:/applicationContext-resources.xml,classpath:/applicationContext-dao.xml,classpath*:/applicationContext.xml,classpath:**/applicationContext*.xml
Maybe , the applicationContext.xml in the WEB-INF directory is not present in the path.
As of now, I am using applicationContext-resources for my spring DI
Show
vijay added a comment - 21/Jan/08 1:17 AM For me, this issue seems to come up only while running the tests While running a test, the context path for Spring are set to  AbstractSingleSpringContextTests.loadContextLocations(210) | Loading context for locations: classpath:/applicationContext-resources.xml,classpath:/applicationContext-dao.xml,classpath*:/applicationContext.xml,classpath:**/applicationContext*.xml Maybe , the applicationContext.xml in the WEB-INF directory is not present in the path. As of now, I am using applicationContext-resources for my spring DI
Hide
Permalink
Matt Raible added a comment - 26/Jan/08 11:11 AM
I was able to resolve this two ways. The first was to change the testResources section to use src/main/webapp/WEB-INF instead of src/main/webapp.
 
       <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>src/main/webapp/WEB-INF</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </testResource>
        </testResources>

After this, I changed it back to src/main/webapp and ran "mvn -U" to get the latest surefire-plugin. After getting the latest surefire version, the test passes when using the default (src/main/webapp).

Hope this helps,

Matt
Show
Matt Raible added a comment - 26/Jan/08 11:11 AM I was able to resolve this two ways. The first was to change the testResources section to use src/main/webapp/WEB-INF instead of src/main/webapp.          <testResources>             <testResource>                 <directory>src/test/resources</directory>                 <filtering>true</filtering>             </testResource>             <testResource>                 <directory>src/main/webapp/WEB-INF</directory>                 <filtering>true</filtering>                 <includes>                     <include>**/*.xml</include>                 </includes>             </testResource>         </testResources> After this, I changed it back to src/main/webapp and ran "mvn -U" to get the latest surefire-plugin. After getting the latest surefire version, the test passes when using the default (src/main/webapp). Hope this helps, Matt
Hide
Permalink
Waldo Rochow added a comment - 08/Mar/08 6:26 PM
I had the same problem with the tutorial-hibernate.

After reading this ticket, I only had to run "mvn -U", and all my problems went away.

Do you think you could add a note about this to the tutorial-hibernate?

Thanks,

Waldo
Show
Waldo Rochow added a comment - 08/Mar/08 6:26 PM I had the same problem with the tutorial-hibernate. After reading this ticket, I only had to run "mvn -U", and all my problems went away. Do you think you could add a note about this to the tutorial-hibernate? Thanks, Waldo
Hide
Permalink
Matt Raible added a comment - 11/Mar/08 1:52 AM
I'll adjust the documentation if there's more reports of this problem on the mailing list.
Show
Matt Raible added a comment - 11/Mar/08 1:52 AM I'll adjust the documentation if there's more reports of this problem on the mailing list.
Hide
Permalink
Ryan WIthers added a comment - 24/Apr/08 9:34 PM
test comment.
Show
Ryan WIthers added a comment - 24/Apr/08 9:34 PM test comment.
Hide
Permalink
Ryan WIthers added a comment - 24/Apr/08 9:38 PM
Okay the first was a test I think my session timed out the first time I attempted to post. I'm writing an article on appfuse and as a result I'm passing through the tutorial. I noticed the same issues that have been mentioned above. With one exception the command 'mvn -U' did not work for me. The only thing that seemed to help was modifying the testResources area adding the WEB-INF to the directory. I emailed a colleague earlier today concerning this, and I've pasted a snippet from that email below. Please let me know if you need further information:

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.52 sec <<< FAILURE!
testFindEntryByProjectNumber(com.oci.jnb.timeEntry.dao.TimeEntryDAOTest) Time elapsed: 1.482 sec <<< ERROR!
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.oci.jnb.timeEntry.dao.TimeEntryDAOTest': Unsatisfied dependency expressed through bean property 'timeEntryDao': Set this property value or disable dependency checking for this bean.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies(AbstractAutowireCapableBeanFactory.java:1213)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1038)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:291)
    at org.springframework.test.AbstractDependencyInjectionSpringContextTests.injectDependencies(AbstractDependencyInjectionSpringContextTests.java:230)
    at org.springframework.test.AbstractDependencyInjectionSpringContextTests.prepareTestInstance(AbstractDependencyInjectionSpringContextTests.java:195)


So in my ApplicationContext I have the following definition, this file is located in the src/main/webapp/web-inf/ directory.

    <bean id="timeEntryDao" class="com.oci.jnb.timeEntry.dao.hibernate.TimeEntryDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
   

The TimeEntryDAOTest has the setter that I'm interested in injecting. So from the xml fragment above I'm trying to inject the "bean id=timeEntryDao" with the class TimeEntryDaoImpl. This setter is defined as:

   private TimeEntryDao dao = null;
  
   public void setTimeEntryDao(TimeEntryDao timeEntryDao) {
       dao = timeEntryDao;
   }
  

The other interesting thing to note about the TimeEntryDAOTest is that it extends from BaseDaoTestCase which is an appFuse provided class and that extends from AbstractTransactionalDataSourceSpringContextTests. Inside the BaseDaoTestCase there is the following method that is returning config locations:

    protected String[] getConfigLocations() {
        setAutowireMode(AUTOWIRE_BY_NAME);
        return new String[] {
                "classpath:/applicationContext-resources.xml",
                "classpath:/applicationContext-dao.xml",
                "classpath*:/applicationContext.xml", // for modular projects
                "classpath:**/applicationContext*.xml" // for web projects
            };
    }

There are a couple things I don't understand about the method above, one is the asterisks surrounding the file names. It seems like the entry classpath*:/applicationContext.xml could be incorrect.

Thanks for your time,

Ryan

Show
Ryan WIthers added a comment - 24/Apr/08 9:38 PM Okay the first was a test I think my session timed out the first time I attempted to post. I'm writing an article on appfuse and as a result I'm passing through the tutorial. I noticed the same issues that have been mentioned above. With one exception the command 'mvn -U' did not work for me. The only thing that seemed to help was modifying the testResources area adding the WEB-INF to the directory. I emailed a colleague earlier today concerning this, and I've pasted a snippet from that email below. Please let me know if you need further information: Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.52 sec <<< FAILURE! testFindEntryByProjectNumber(com.oci.jnb.timeEntry.dao.TimeEntryDAOTest) Time elapsed: 1.482 sec <<< ERROR! org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.oci.jnb.timeEntry.dao.TimeEntryDAOTest': Unsatisfied dependency expressed through bean property 'timeEntryDao': Set this property value or disable dependency checking for this bean.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies(AbstractAutowireCapableBeanFactory.java:1213)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1038)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:291)     at org.springframework.test.AbstractDependencyInjectionSpringContextTests.injectDependencies(AbstractDependencyInjectionSpringContextTests.java:230)     at org.springframework.test.AbstractDependencyInjectionSpringContextTests.prepareTestInstance(AbstractDependencyInjectionSpringContextTests.java:195) So in my ApplicationContext I have the following definition, this file is located in the src/main/webapp/web-inf/ directory.     <bean id="timeEntryDao" class="com.oci.jnb.timeEntry.dao.hibernate.TimeEntryDaoImpl">         <property name="sessionFactory" ref="sessionFactory"/>     </bean>     The TimeEntryDAOTest has the setter that I'm interested in injecting. So from the xml fragment above I'm trying to inject the "bean id=timeEntryDao" with the class TimeEntryDaoImpl. This setter is defined as:    private TimeEntryDao dao = null;       public void setTimeEntryDao(TimeEntryDao timeEntryDao) {        dao = timeEntryDao;    }    The other interesting thing to note about the TimeEntryDAOTest is that it extends from BaseDaoTestCase which is an appFuse provided class and that extends from AbstractTransactionalDataSourceSpringContextTests. Inside the BaseDaoTestCase there is the following method that is returning config locations:     protected String[] getConfigLocations() {         setAutowireMode(AUTOWIRE_BY_NAME);         return new String[] {                 "classpath:/applicationContext-resources.xml",                 "classpath:/applicationContext-dao.xml",                 "classpath*:/applicationContext.xml", // for modular projects                 "classpath:**/applicationContext*.xml" // for web projects             };     } There are a couple things I don't understand about the method above, one is the asterisks surrounding the file names. It seems like the entry classpath*:/applicationContext.xml could be incorrect. Thanks for your time, Ryan
Hide
Permalink
Matt Raible added a comment - 24/Apr/08 10:31 PM
You might try using a specific version of the maven-surefire-plugin:

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.3.1</version>
            </plugin>

The available versions are listed at:

http://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin
Show
Matt Raible added a comment - 24/Apr/08 10:31 PM You might try using a specific version of the maven-surefire-plugin:             <plugin>                 <artifactId>maven-surefire-plugin</artifactId>                 <version>2.3.1</version>             </plugin> The available versions are listed at: http://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin

People

  • Assignee:
    Matt Raible
    Reporter:
    Matt Raible
Vote (0)
Watch (1)

Dates

  • Created:
    07/Jan/08 11:21 AM
    Updated:
    24/Apr/08 10:31 PM
    Resolved:
    26/Jan/08 11:11 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for AppFuse. Try JIRA - bug tracking software for your team.