The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

david2552 (1) [Avatar] Offline
#1
Hi Chris,

I am new to java and just got a copy of your book. I like the book that tell me everything I need.



I was able to run the "mvn test" from the parent directory (C:pia-1.0-SNAPSHOT) and Chapter 1 (C:pia-1.0-SNAPSHOTpia-ch-01-banking-example), with the in-memory database.

However, when I tried to run the "mvn test" for Chapter 1 with the hsqldb local database server. I got error.

Here is what I did with my work PC (XP Pro).

1. local Maven repository is at Csmilieocuments and SettingsI273501.m2 epository.
2. The repository for hsqldb: Csmilieocuments and SettingsI273501.m2 epositoryorghsqldbcom.springsource.org.hsqldb1.8.0.9


3. I modified the hsqldb-datasource.xml for Chpt 1 (under C:pia-1.0-SNAPSHOTpia-ch-01-banking-examplesrcmain esources):

<!-- <br /> <property name="url"><value>jdbc:hsqldb:mem:testdb</value></property> <br /> -->
<property name="url"><value>jdbc:hsqldb:hsql://localhost/testdb</value></property>

4. Then I swtched to C:pia-1.0-SNAPSHOTpia-ch-01-banking-example, and started the hsqldb with the command:
"%JAVA_HOME%/bin/java" -classpath Csmilieevworkspace-sts-2.1.0.SR01PetClinicwarWEB-INFlibhsqldb.jar org.hsqldb.Server -database testdb

03/21/2011 11:42:48.87
C:pia-1.0-SNAPSHOTpia-ch-01-banking-example>"%JAVA_HOME%/bin/java" -classpath
"Csmilieocuments and SettingsI273501.m2 epositoryorghsqldbcom.springsource.or
g.hsqldb1.8.0.9com.springsource.org.hsqldb-1.8.0.9.jar" org.hsqldb.Server -da
tabase testdb
[Server@12152e6]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@12152e6]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@12152e6]: Startup sequence initiated from main() method
[Server@12152e6]: Loaded properties from [C:pia-1.0-SNAPSHOTpia-ch-01-banking-
exampleserver.properties]
[Server@12152e6]: Initiating startup sequence...
[Server@12152e6]: Server socket opened successfully in 16 ms.
[Server@12152e6]: Database [index=0, id=0, db=file:testdb, alias=] opened sucess
fully in 547 ms.
[Server@12152e6]: Startup sequence completed in 563 ms.
[Server@12152e6]: 2011-03-21 11:43:41.078 HSQLDB server 1.8.0 is online
[Server@12152e6]: To close normally, connect and execute SHUTDOWN SQL
[Server@12152e6]: From command line, use [Ctrl]+[C] to abort abruptly



5. Opened another dos cmd, and ran the test with "mvn test". The build failed.


03/21/2011 11:10:03.67
C:pia-1.0-SNAPSHOTpia-ch-01-banking-example>mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building POJOs in Action - Chapter 1, Hibernate Banking Example
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:pia-1.0-SNAPSHOTpia-ch-01-banking
-examplesrc est esources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:pia-1.0-SNAPSHOTpia-ch-01-banking-example\r
targetsurefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.chrisrichardson.bankingExample.domain.AccountTests

AccountTests.test_normal()


AccountTests.test_overdrawn()

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.14 sec
Running net.chrisrichardson.bankingExample.facade.BankingExampleFacadeAllTests
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running net.chrisrichardson.bankingExample.facade.TransferFacadeImplTests
acctId1: A.1300723971203
B.1300723971203

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.172 sec
Running net.chrisrichardson.bankingExample.facade.spring.SpringHibernateTransfer
FacadeImplTests
log4j:WARN No appenders could be found for logger (net.chrisrichardson.bankingEx
ample.facade.spring.SpringHibernateTransferFacadeImplTests).
log4j:WARN Please initialize the log4j system properly.
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 5.234 sec <<< FA
ILURE!
Running net.chrisrichardson.bankingExample.domain.BankingDomainAllTests
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running net.chrisrichardson.bankingExample.domain.hibernate.HibernateAccountPers
istenceTests
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.562 sec <<< FA
ILURE!
Running net.chrisrichardson.bankingExample.domain.hibernate.HibernateAccountRepo
sitoryTests
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.157 sec <<< FA
ILURE!
Running net.chrisrichardson.bankingExample.domain.MoneyTransferServiceTests
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.203 sec
Running net.chrisrichardson.bankingExample.domain.hibernate.ManyAccountPersisten
celTests
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
Running net.chrisrichardson.bankingExample.tests.Chapter01BankingExampleAllTests

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running net.chrisrichardson.bankingExample.domain.hibernate.BankingSchemaTests
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.063 sec <<< FA
ILURE!
Running net.chrisrichardson.bankingExample.domain.hibernate.HibernateBankingExam
pleMappingTests
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.046 sec
Running net.chrisrichardson.bankingExample.domain.hibernate.BankingDomainHiberna
teAllTests
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running net.chrisrichardson.bankingExample.domain.hibernate.HibernateAccountRepo
sitoryMockTests
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.328 sec

Results :

Tests in error:
test(net.chrisrichardson.bankingExample.facade.spring.SpringHibernateTransferF
acadeImplTests)
testTransfer(net.chrisrichardson.bankingExample.facade.spring.SpringHibernateT
ransferFacadeImplTests)
testSimple(net.chrisrichardson.bankingExample.domain.hibernate.HibernateAccoun
tPersistenceTests)
test(net.chrisrichardson.bankingExample.domain.hibernate.HibernateAccountRepos
itoryTests)
testBankingSchema(net.chrisrichardson.bankingExample.domain.hibernate.BankingS
chemaTests)

Tests run: 12, Failures: 0, Errors: 5, Skipped: 0

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to C:pia-1.0-SNAPSHOTpia-ch-01-banking-example argetsurefire-re
ports for the individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19 seconds
[INFO] Finished at: Mon Mar 21 11:12:58 CDT 2011
[INFO] Final Memory: 9M/16M
[INFO] ------------------------------------------------------------------------

03/21/2011 11:12:58.46
C:pia-1.0-SNAPSHOTpia-ch-01-banking-example>

6. The hsqldb console showed error.


C:pia-1.0-SNAPSHOTpia-ch-01-banking-example>"%JAVA_HOME%/bin/java" -classpath
"Csmilieocuments and SettingsI273501.m2 epositoryorghsqldbcom.springsource.or
g.hsqldb1.8.0.9com.springsource.org.hsqldb-1.8.0.9.jar" org.hsqldb.Server -da
tabase testdb
[Server@12152e6]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@12152e6]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@12152e6]: Startup sequence initiated from main() method
[Server@12152e6]: Loaded properties from [C:pia-1.0-SNAPSHOTpia-ch-01-banking-
exampleserver.properties]
[Server@12152e6]: Initiating startup sequence...
[Server@12152e6]: Server socket opened successfully in 16 ms.
[Server@12152e6]: Database [index=0, id=0, db=file:testdb, alias=] opened sucess
fully in 547 ms.
[Server@12152e6]: Startup sequence completed in 563 ms.
[Server@12152e6]: 2011-03-21 11:43:41.078 HSQLDB server 1.8.0 is online
[Server@12152e6]: To close normally, connect and execute SHUTDOWN SQL
[Server@12152e6]: From command line, use [Ctrl]+[C] to abort abruptly
[Server@12152e6]: [Thread[HSQLDB Connection @1f5d386,5,HSQLDB Connections @12152
e6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @18088c0,5,HSQLDB Connections @12152
e6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @1922221,5,HSQLDB Connections @12152
e6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @fec107,5,HSQLDB Connections @12152e
6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @132e13d,5,HSQLDB Connections @12152
e6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @1617189,5,HSQLDB Connections @12152
e6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @191d8c1,5,HSQLDB Connections @12152
e6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @2d9c06,5,HSQLDB Connections @12152e
6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @5e5a50,5,HSQLDB Connections @12152e
6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @7b6889,5,HSQLDB Connections @12152e
6]]: database alias=testdb does not exist
[Server@12152e6]: [Thread[HSQLDB Connection @c2ff5,5,HSQLDB Connections @12152e6
]]: database alias=testdb does not exist



What did I do wrong? It seems that the testdb was not availble to Hibernate to I ran the maven test with the local database server.

I do have a question. If I choose to create my local database server, where are the scripts to create the schema and tables, or do I need them?

Could you please shed me some light on how to run the Chapter 1 test with my local database server, so that I can view the data?


Thank you in advance.

David