[RESOLU] [TP12] IllegalArgumentException: Unknown entity

Modérateurs : graffion, jmdouin, agoncal, mlebihan

LUYI
Messages : 4
Inscription : 16 nov. 2016 10:52

[RESOLU] [TP12] IllegalArgumentException: Unknown entity

Message par LUYI » 16 janv. 2017 21:29

I finished all the building of the Entity beans and DAOs.
and when I ran the testcase, all the errors and exceptions point to one place:

java.lang.IllegalArgumentException:
Unknown entity bean class: class com.yaps.petstore.server.util.uidgen.Counter, please verify that this class has been marked with the @Entity annotation.

Even I was running the testCase<UniquelIdGeneratorTest.java>,it showed:
java.lang.IllegalArgumentException: Unknown entity bean class: class com.yaps.petstore.server.util.uidgen.Counter, please verify that this class has been marked with the @Entity annotation.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:576)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:460)
at com.yaps.petstore.server.util.persistence.AbstractDataAccessObject.findById(AbstractDataAccessObject.java:130)
at com.yaps.petstore.server.util.persistence.AbstractDataAccessObject.select(AbstractDataAccessObject.java:171)
at com.yaps.petstore.server.util.uidgen.UniqueIdGeneratorTest.findName(UniqueIdGeneratorTest.java:77)
at com.yaps.petstore.server.util.uidgen.UniqueIdGeneratorTest.testUtilUniqueId(UniqueIdGeneratorTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)



and the Counter class is given, I do not change anything of it.
and I checked the persistence.xml, I also saw the definition of it.(I do not change it either)
Why the Counter class can not be recoginzed ?

Thanks for your advice.

graffion
Messages : 607
Inscription : 21 juin 2005 14:05

Re: [TP12] IllegalArgumentException: Unknown entity bean cla

Message par graffion » 17 janv. 2017 13:56

How do you run the tests? From Eclipse or Netbeans or using 'ant yaps-test'?

Try to run the tests with the command 'ant yaps-test'.
I should work since this target copies the right persistence.xml to the right place:

Code : Tout sélectionner

    <target name="yaps-test" depends="check, yaps-compile">
        <echo message="Tests the application"/>
    	<copy file="${yaps.test.src.dir}/META-INF/persistence.xml" todir="${yaps.test.classes.dir}/META-INF" overwrite="true" preservelastmodified="true"/>
        <junit printsummary="on" fork="yes">
               ...
Have also a look to the "Tests des DAO" section of the TP12 documentation http://aisl.cnam.fr/xwiki/wiki/aisl/vie ... _GlassFish

LUYI
Messages : 4
Inscription : 16 nov. 2016 10:52

Re: [TP12] IllegalArgumentException: Unknown entity bean cla

Message par LUYI » 17 janv. 2017 16:43

Yes,I ran it on the eclipse
Now I ran ant yaps-test as you said,
it worked well!

Thanks

graffion
Messages : 607
Inscription : 21 juin 2005 14:05

[RESOLU]Re: [TP12] IllegalArgumentException: Unknown entity

Message par graffion » 17 janv. 2017 16:57

As stated (in french) in TP12 documentation http://aisl.cnam.fr/xwiki/wiki/aisl/vie ... _GlassFish:
(Pour lancer ce test depuis Eclipse, il faudra préalablement copier ce fichier dans bin/META-INF/persistence.xml (en supposant que bin est le "default output folder" du projet pour Eclipse)).
To run a DAO test from Eclipse, you have to copy Yaps/test/src/META-INF/persistence.xml into bin/META-INF/persistence.xml (assuming bin is the "default output folder" of your project in Eclipse))

Répondre

Qui est en ligne ?

Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 1 invité