You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mick Knutson <mi...@gmail.com> on 2008/03/21 00:14:04 UTC

Fwd: Issues trying to run Maven, OpenJPA, DBUnit example.

I have been trying to run this example:
http://bill.dudney.net/roller/bill/entry/20070428

Now it seems, that when the testNG tests run, I get an NPE here:

*DbUnitTestBase.java
*
    @BeforeClass(groups = {"database"})
    protected void loadSeedData() throws Exception {
        logger.debug("loadSeedData");
        IDatabaseConnection dbunitConn = null;
        EntityManager em = null;
        try {
            *em = entityManagerFactory.createEntityManager();*


Here is my error in *testng-results.xml*

    <test name="Command line test">
      <class name="net.dudney.jpaund.domain.SimpleTest">
        <test-method status="SKIP" signature="initDB()" name="initDB"
is-config="true" duration-ms="0" started-at="2008-03-20T11:51:46Z"
finished-at="2008-03-20T11:51:46Z">
        </test-method>
        <test-method status="SKIP" signature="testCreateSiteUser()"
name="testCreateSiteUser" duration-ms="0" started-at="2008-03-20T11:51:46Z"
finished-at="2008-03-20T11:51:46Z">
        </test-method>
        <test-method status="FAIL" signature="loadSeedData()"
name="loadSeedData" is-config="true" duration-ms="0"
started-at="2008-03-20T11:51:46Z" finished-at="2008-03-20T11:51:46Z">
          <exception class="java.lang.NullPointerException">
            <full-stacktrace>
              <![CDATA[java.lang.NullPointerException
    at net.dudney.jpaund.domain.DbUnitTestBase.loadSeedData(
DbUnitTestBase.java:43)
    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:585)
    at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java
:398)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(
TestMethodWorker.java:166)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:103)
    at org.testng.TestRunner.runWorkers(TestRunner.java:689)
    at org.testng.TestRunner.privateRun(TestRunner.java:566)
    at org.testng.TestRunner.run(TestRunner.java:466)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
    at org.testng.SuiteRunner.run(SuiteRunner.java:191)
    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
    at org.testng.TestNG.run(TestNG.java:701)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(
TestNGExecutor.java:62)
    at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(
TestNGDirectoryTestSuite.java:136)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    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:585)
    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
SurefireBooter.java:338)
    at org.apache.maven.surefire.booter.SurefireBooter.main(
SurefireBooter.java:997)
]]>
            </full-stacktrace>
          </exception>
        </test-method>
      </class>
      <class name="net.dudney.jpaund.dao.jpa.BaseDaoJpaTest">
        <test-method status="PASS" signature="testGetUpdateObjects()"
name="testGetUpdateObjects" duration-ms="13078"
started-at="2008-03-20T11:50:42Z" finished-at="2008-03-20T11:50:55Z">
        </test-method>
        <test-method status="PASS" signature="testQueryBuildingRealClass()"
name="testQueryBuildingRealClass" duration-ms="0"
started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:50:55Z">
        </test-method>
        <test-method status="PASS"
signature="testQueryBuildingNullParameter()"
name="testQueryBuildingNullParameter" duration-ms="0"
started-at="2008-03-20T11:51:46Z" finished-at="2008-03-20T11:51:46Z">
        </test-method>
        <test-method status="PASS" signature="testGetObject()"
name="testGetObject" duration-ms="219" started-at="2008-03-20T11:51:45Z"
finished-at="2008-03-20T11:51:46Z">
        </test-method>
        <test-method status="PASS"
signature="testSaveOrUpdateObjectExistingObject()"
name="testSaveOrUpdateObjectExistingObject" duration-ms="12735"
started-at="2008-03-20T11:51:20Z" finished-at="2008-03-20T11:51:33Z">
        </test-method>
        <test-method status="PASS" signature="setUpSpring()"
name="setUpSpring" is-config="true" duration-ms="1281"
started-at="2008-03-20T11:50:13Z" finished-at="2008-03-20T11:50:14Z">
        </test-method>
        <test-method status="PASS" signature="testQueryBuildingEmptyParam()"
name="testQueryBuildingEmptyParam" duration-ms="0"
started-at="2008-03-20T11:50:30Z" finished-at="2008-03-20T11:50:30Z">
        </test-method>
        <test-method status="PASS" signature="testDeleteObject()"
name="testDeleteObject" duration-ms="13281"
started-at="2008-03-20T11:51:07Z" finished-at="2008-03-20T11:51:20Z">
        </test-method>
        <test-method status="PASS"
signature="testQueryBuildingDoubleParamOrderBy()"
name="testQueryBuildingDoubleParamOrderBy" duration-ms="0"
started-at="2008-03-20T11:51:33Z" finished-at="2008-03-20T11:51:33Z">
        </test-method>
        <test-method status="PASS"
signature="testSaveOrUpdateObjectNewObject()"
name="testSaveOrUpdateObjectNewObject" duration-ms="12203"
started-at="2008-03-20T11:50:30Z" finished-at="2008-03-20T11:50:42Z">
        </test-method>
        <test-method status="PASS" signature="testParameterQuery()"
name="testParameterQuery" duration-ms="344"
started-at="2008-03-20T11:51:07Z" finished-at="2008-03-20T11:51:07Z">
        </test-method>
        <test-method status="PASS" signature="testFetchWithOrderBy()"
name="testFetchWithOrderBy" duration-ms="12360"
started-at="2008-03-20T11:51:33Z" finished-at="2008-03-20T11:51:45Z">
        </test-method>
        <test-method status="PASS"
signature="testQueryBuildingSingleParam()"
name="testQueryBuildingSingleParam" duration-ms="0"
started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:50:55Z">
        </test-method>
        <test-method status="PASS" signature="testGetPKFieldName()"
name="testGetPKFieldName" duration-ms="0" started-at="2008-03-20T11:50:55Z"
finished-at="2008-03-20T11:50:55Z">
        </test-method>
        <test-method status="PASS" signature="testDeleteNonObject()"
name="testDeleteNonObject" duration-ms="11140"
started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:51:07Z">
        </test-method>
        <test-method status="PASS" signature="testSingleParameterQuery()"
name="testSingleParameterQuery" duration-ms="1079"
started-at="2008-03-20T11:50:29Z" finished-at="2008-03-20T11:50:30Z">
        </test-method>
        <test-method status="PASS" signature="loadSeedData()"
name="loadSeedData" is-config="true" duration-ms="15234"
started-at="2008-03-20T11:50:14Z" finished-at="2008-03-20T11:50:29Z">
        </test-method>
        <test-method status="PASS"
signature="testQueryBuildingDoubleParam()"
name="testQueryBuildingDoubleParam" duration-ms="0"
started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:50:55Z">
        </test-method>
      </class>
    </test>
  </suite>

The strange thing is, most of the tests pass in *BaseDaoJpaTest.java*
but not in *SimpleTest.java*

I am very perplexed and want to fully understand how to get DBUnit, Maven,
and openJPA forking please.

-- 
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---



-- 
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---

Re: Issues trying to run Maven, OpenJPA, DBUnit example.

Posted by Wayne Fay <wa...@gmail.com>.
Knowing nothing more than what you've presented, it appears that
Spring is not wiring up EntityManagerFactory properly.

Toss a check for null in there before you use it and I'm sure it will
be true. As for why exactly, well, I have absolutely no idea without
getting elbow-deep with the code.

Have you contacted Bill Dudney (the originator of the code) and asked
him for assistance?

Wayne

On 3/20/08, Mick Knutson <mi...@gmail.com> wrote:
> I have been trying to run this example:
> http://bill.dudney.net/roller/bill/entry/20070428
>
> Now it seems, that when the testNG tests run, I get an NPE here:
>
> *DbUnitTestBase.java
> *
> @BeforeClass(groups = {"database"})
> protected void loadSeedData() throws Exception {
> logger.debug("loadSeedData");
> IDatabaseConnection dbunitConn = null;
> EntityManager em = null;
> try {
> *em = entityManagerFactory.createEntityManager();*
>
>
> Here is my error in *testng-results.xml*
>
> <test name="Command line test">
> <class name="net.dudney.jpaund.domain.SimpleTest">
> <test-method status="SKIP" signature="initDB()" name="initDB"
> is-config="true" duration-ms="0" started-at="2008-03-20T11:51:46Z"
> finished-at="2008-03-20T11:51:46Z">
> </test-method>
> <test-method status="SKIP" signature="testCreateSiteUser()"
> name="testCreateSiteUser" duration-ms="0" started-at="2008-03-20T11:51:46Z"
> finished-at="2008-03-20T11:51:46Z">
> </test-method>
> <test-method status="FAIL" signature="loadSeedData()"
> name="loadSeedData" is-config="true" duration-ms="0"
> started-at="2008-03-20T11:51:46Z" finished-at="2008-03-20T11:51:46Z">
> <exception class="java.lang.NullPointerException">
> <full-stacktrace>
> <![CDATA[java.lang.NullPointerException
> at net.dudney.jpaund.domain.DbUnitTestBase.loadSeedData(
> DbUnitTestBase.java:43)
> 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:585)
> at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
> at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java
> :398)
> at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
> at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
> at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(
> TestMethodWorker.java:166)
> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:103)
> at org.testng.TestRunner.runWorkers(TestRunner.java:689)
> at org.testng.TestRunner.privateRun(TestRunner.java:566)
> at org.testng.TestRunner.run(TestRunner.java:466)
> at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
> at org.testng.SuiteRunner.run(SuiteRunner.java:191)
> at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
> at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
> at org.testng.TestNG.run(TestNG.java:701)
> at org.apache.maven.surefire.testng.TestNGExecutor.run(
> TestNGExecutor.java:62)
> at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(
> TestNGDirectoryTestSuite.java:136)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> 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:585)
> at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
> SurefireBooter.java:338)
> at org.apache.maven.surefire.booter.SurefireBooter.main(
> SurefireBooter.java:997)
> ]]>
> </full-stacktrace>
> </exception>
> </test-method>
> </class>
> <class name="net.dudney.jpaund.dao.jpa.BaseDaoJpaTest">
> <test-method status="PASS" signature="testGetUpdateObjects()"
> name="testGetUpdateObjects" duration-ms="13078"
> started-at="2008-03-20T11:50:42Z" finished-at="2008-03-20T11:50:55Z">
> </test-method>
> <test-method status="PASS" signature="testQueryBuildingRealClass()"
> name="testQueryBuildingRealClass" duration-ms="0"
> started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:50:55Z">
> </test-method>
> <test-method status="PASS"
> signature="testQueryBuildingNullParameter()"
> name="testQueryBuildingNullParameter" duration-ms="0"
> started-at="2008-03-20T11:51:46Z" finished-at="2008-03-20T11:51:46Z">
> </test-method>
> <test-method status="PASS" signature="testGetObject()"
> name="testGetObject" duration-ms="219" started-at="2008-03-20T11:51:45Z"
> finished-at="2008-03-20T11:51:46Z">
> </test-method>
> <test-method status="PASS"
> signature="testSaveOrUpdateObjectExistingObject()"
> name="testSaveOrUpdateObjectExistingObject" duration-ms="12735"
> started-at="2008-03-20T11:51:20Z" finished-at="2008-03-20T11:51:33Z">
> </test-method>
> <test-method status="PASS" signature="setUpSpring()"
> name="setUpSpring" is-config="true" duration-ms="1281"
> started-at="2008-03-20T11:50:13Z" finished-at="2008-03-20T11:50:14Z">
> </test-method>
> <test-method status="PASS" signature="testQueryBuildingEmptyParam()"
> name="testQueryBuildingEmptyParam" duration-ms="0"
> started-at="2008-03-20T11:50:30Z" finished-at="2008-03-20T11:50:30Z">
> </test-method>
> <test-method status="PASS" signature="testDeleteObject()"
> name="testDeleteObject" duration-ms="13281"
> started-at="2008-03-20T11:51:07Z" finished-at="2008-03-20T11:51:20Z">
> </test-method>
> <test-method status="PASS"
> signature="testQueryBuildingDoubleParamOrderBy()"
> name="testQueryBuildingDoubleParamOrderBy" duration-ms="0"
> started-at="2008-03-20T11:51:33Z" finished-at="2008-03-20T11:51:33Z">
> </test-method>
> <test-method status="PASS"
> signature="testSaveOrUpdateObjectNewObject()"
> name="testSaveOrUpdateObjectNewObject" duration-ms="12203"
> started-at="2008-03-20T11:50:30Z" finished-at="2008-03-20T11:50:42Z">
> </test-method>
> <test-method status="PASS" signature="testParameterQuery()"
> name="testParameterQuery" duration-ms="344"
> started-at="2008-03-20T11:51:07Z" finished-at="2008-03-20T11:51:07Z">
> </test-method>
> <test-method status="PASS" signature="testFetchWithOrderBy()"
> name="testFetchWithOrderBy" duration-ms="12360"
> started-at="2008-03-20T11:51:33Z" finished-at="2008-03-20T11:51:45Z">
> </test-method>
> <test-method status="PASS"
> signature="testQueryBuildingSingleParam()"
> name="testQueryBuildingSingleParam" duration-ms="0"
> started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:50:55Z">
> </test-method>
> <test-method status="PASS" signature="testGetPKFieldName()"
> name="testGetPKFieldName" duration-ms="0" started-at="2008-03-20T11:50:55Z"
> finished-at="2008-03-20T11:50:55Z">
> </test-method>
> <test-method status="PASS" signature="testDeleteNonObject()"
> name="testDeleteNonObject" duration-ms="11140"
> started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:51:07Z">
> </test-method>
> <test-method status="PASS" signature="testSingleParameterQuery()"
> name="testSingleParameterQuery" duration-ms="1079"
> started-at="2008-03-20T11:50:29Z" finished-at="2008-03-20T11:50:30Z">
> </test-method>
> <test-method status="PASS" signature="loadSeedData()"
> name="loadSeedData" is-config="true" duration-ms="15234"
> started-at="2008-03-20T11:50:14Z" finished-at="2008-03-20T11:50:29Z">
> </test-method>
> <test-method status="PASS"
> signature="testQueryBuildingDoubleParam()"
> name="testQueryBuildingDoubleParam" duration-ms="0"
> started-at="2008-03-20T11:50:55Z" finished-at="2008-03-20T11:50:55Z">
> </test-method>
> </class>
> </test>
> </suite>
>
> The strange thing is, most of the tests pass in *BaseDaoJpaTest.java*
> but not in *SimpleTest.java*
>
> I am very perplexed and want to fully understand how to get DBUnit, Maven,
> and openJPA forking please.
>
> --
> Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.linkedin.com/in/mickknutson
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/BLiNCMagazine
> http://tahoe.baselogic.com
> ---
>
>
>
> --
> Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.linkedin.com/in/mickknutson
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/BLiNCMagazine
> http://tahoe.baselogic.com
> ---
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org