Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2
This is the forum to discuss the Wrox book Beginning Spring Framework 2 by Thomas Van de Velde, Bruce Snyder, Christian Dupuis, Sing Li, Anne Horton, Naveen Balani; ISBN: 9780470101612
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 11th, 2008, 07:11 PM
Registered User
 
Join Date: Jan 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Failing DAO Tests

When attempting to run the AlbumDaoTest as shown on p. 62, I'm getting the following failure:

java.sql.SQLException: Table not found in statement [insert into album_sequence
values (null)]

and displaying tables in the database via the SqlTool show that no tables are defined.

Can anyone tell me what is supposed to define the DB before running the test? I've successfully built the project as shown in Appendix C and don't think I'm missing any steps from the book.

Any help, much appreciated!

  #2 (permalink)  
Old January 11th, 2008, 08:30 PM
Registered User
 
Join Date: Jan 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, please disregard! User error. I stepped back through the procedure and the test is working as expected.

  #3 (permalink)  
Old January 18th, 2008, 01:27 PM
Registered User
 
Join Date: Jan 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dgalehouse
 Sorry, please disregard! User error. I stepped back through the procedure and the test is working as expected.

I am running into the same failure. I have gone back and checked to make sure that I am following the steps correctly in the 'try-it-out' on pg 60. You mentioned that you stepped through the procedure and the test is working as expected for you, can you give more details? You must have done something different after getting the initial error, I don't know what I am doing wrong. Thanks for your help.


  #4 (permalink)  
Old January 23rd, 2008, 05:10 PM
Registered User
 
Join Date: Jan 2008
Location: Aurora, CO, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi. I was able to get past this by running the pixhsql.sql script found in wrox-pix-web/src/test/resources directory. There is probably a better way, but doing the following could help if you are stuck.

First off, I am having a little more success when starting my db via the instructions in appendix C (start from within my spring dir) over those in Chapter 3 (start db using the hsqldb-1.8.0.7.jar that comes with the wrox download).

C:\spring-framework-2.0.8\lib\hsqldb>java -cp hsqldb.jar org.hsqldb.Server -database.0 temp -dbname.0 pix

I also started SqlTool using my spring-framework-2.0.8 hsqldb.jar rather than the one in wrox-pix-web.

C:\spring-framework-2.0.8\lib\hsqldb>java -cp hsqldb.jar org.hsqldb.util.SqlTool pix-sa

Then I ran the following at the sql prompt
sql> \i C:\apps\begspring2\wrox-pix-web\src\test\resources\pixhsql.sql

This yielded quite a few errors (constraint/table already exists) but alas I was able to run
C:\apps\begspring2\wrox-pix-web>mvn exec:java -Dexec.mainClass=com.wrox.beginspring.pix.dao.examp les.AlbumDaoTest

after that I got an NullPointerException when running "select * from album", but I could "select id from album". Trying each column, I deduced that no creationdate was inserted so I did the following.

sql> update album set creationdate = current_date;
1 row updated
sql> select * from album
  +> ;
DTYPE ID NAME DESCRIPTION CREATIONDATE LABELS USER_US
ERNAME
----- -- ---------------- ----------- --------------------- ------ -------
------
H 1 This is my album [null] 2008-01-23 00:00:00.0 user1

Looks like I can finally press on.


  #5 (permalink)  
Old March 2nd, 2008, 06:29 PM
gxp gxp is offline
Registered User
 
Join Date: Dec 2007
Location: Wilmington, DE, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks anjie. After running pixhsql.sql as you suggested, I was then able to run the mvn command to insert the record into the album table. You saved me alot of time.

Now I can also press onward!

-Greg


  #6 (permalink)  
Old June 24th, 2008, 02:16 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello
I actually have different problem, I do not know what is the kind of exception, it looks like something missing in maven:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. com.wrox.beginspring.pix.dao.examples.AlbumDaoTest

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionExcep tion: An exception occured while executing the Java class. com.wrox.beginspring.pix.dao.examples.AlbumDaoTest
        at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoals(DefaultLifecycleExecutor.java:583)
        at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeStandaloneGoal(DefaultLifecycleExecutor.j ava:512)
        at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoal(DefaultLifecycleExecutor.java:482)
        at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoalAndHandleFailures(DefaultLifecycleExe cutor.java:330)
        at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeTaskSegments(DefaultLifecycleExecutor.jav a:291)
        at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMav en.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven .java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:2 87)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(L auncher.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.ja va:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. com.wrox.beginspring.pix.dao.examples.AlbumDaoTest
        at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJa vaMojo.java:345)
        at org.apache.maven.plugin.DefaultPluginManager.execu teMojo(DefaultPluginManager.java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoals(DefaultLifecycleExecutor.java:558)
        ... 16 more
Caused by: java.lang.ClassNotFoundException: com.wrox.beginspring.pix.dao.examples.AlbumDaoTest
        at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJava Mojo.java:283)
        at java.lang.Thread.run(Thread.java:619)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Tue Jun 24 14:35:56 GMT+08:00 2008
[INFO] Final Memory: 9M/16M
[INFO] ------------------------------------------------------------------------


Has anyone been through this, how can I fix it? do I need to change the pom to include different resources?

Thanks
ibrahim

  #7 (permalink)  
Old June 24th, 2008, 04:17 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same problem as Ibrahim.

Could anyone help please?

Thanks a lot,

Alice

  #8 (permalink)  
Old July 16th, 2008, 11:33 PM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Just copy whole 'com' package from 'test-classes' directory to classes directory and run it, it will work.

Thanks

Deepak
  #9 (permalink)  
Old May 16th, 2009, 05:10 AM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default still can't pass the DaoTest

hi all

I got problem in page 62. if l used the pom.xml provieded by wrox office site, the error msg is
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.codehaus.mojo:xfire-maven-plugin' does not exist or no valid versio
n could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sat May 16 16:47:32 SGT 2009
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------


if l follow the forum to edit the pom.xml as add
<version>1.0-20061017.160413-3</version>
after line 61

<pluginRepositories>
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/
</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>

after line 82

l still got the error msg
Scanning for projecs...
Searching repository for plugin with prefix: 'exec'.
------------------------------------------------------------------------
Building Unnamed - wrox:pixweb:war:0.0.1
task-segment: [exec:java]
------------------------------------------------------------------------
Preparing exec:java
No goals needed for project - skipping
G] POM for 'jaxen:jaxen:pom:1.1-beta-9:compile' is invalid.

endencies (if any) will NOT be available to the current build.
G] POM for 'xfire:xfire-jsr181-api:pom:1.0-M1:compile' is invalid.

endencies (if any) will NOT be available to the current build.
[exec:java]
------------------------------------------------------------------------
BUILD ERROR
------------------------------------------------------------------------
An exception occured while executing the Java class. com.wrox.beginspring.pix.dao.e
.AlbumDaoTest

------------------------------------------------------------------------
For more information, run Maven with the -e switch
------------------------------------------------------------------------
Total time: 1 second
Finished at: Sat May 16 16:46:50 SGT 2009
Final Memory: 11M/20M


l really have tried all the solution, l still can't pass it


Any help will be appreciated. thanks for all
  #10 (permalink)  
Old August 30th, 2009, 02:29 PM
Authorized User
 
Join Date: Aug 2009
Location: Everett, WA
Posts: 10
Thanks: 3
Thanked 3 Times in 3 Posts
Smile Failing DAO Tests

I was also having trouble with the AlbumDaoTest on page 62. I was getting a ClassNotFound exception. I used the suggestion from deepakv75 but only copied AlbumDaoTest.class and AlbumDao.class from target\test-classes\com\wrox\begspring\pix\dao\examples to target\classes\com\wrox\begspring\pix\dao\examples [i had to first create the examples directory]. I then reran the test and it processed to the point of trying to insert the record into the album_sequence table. The table did not exist. I manually created the table with SQLTool and manually inserted the record following the SQL statements in the pixhsql.sql file located in src\test\resources. I also looked at the rest of the code in AlbumDao.java and discovered that I needed to do the same thing for the picture_sequence table. I reran AlbumDaoTest and was successful.

What I want to know is why wasn't the original AlbumDaoTest.class located at test-classes\com\wrox\begspring\pix\dao\examples executed? I think it has something to do with the classpath info in the pom.xml file.

Also, how do you fix it so that it runs properly?

Hope this helps. Thank you.

EverettG.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Where are all the unit tests? Extrakun BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 July 17th, 2007 05:39 PM
Chapter 2 AD HOC Testdriven.net tests? phsarjk BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 May 17th, 2007 04:12 PM
PHP Editor: beta tests Luckasoft Pro PHP 2 March 13th, 2005 09:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.