You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Jeremy Bauer <te...@gmail.com> on 2008/12/08 20:38:09 UTC

Re: NullPointerException when calling createEntityManager on EntityManagerFactory

Martin,
The Animal class is listed as an entity class in the persistence.xml, but it
is not annotated (or defined in orm.xml) as an entity.  Annotating the
entity should correct the problem.  I'll open a JIRA to address the NPE,
since OpenJPA should be able to handle this condition more appropriately.

Also, after I annotated the entity, I needed to use the maven compiler
plugin to set the compile source and target to 1.5.  You can do that by
adding this to your pom, after dependencies:

    <build>
      <plugins>
         <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-compiler-plugin</artifactId>
             <configuration>
                 <source>1.5</source>
                 <target>1.5</target>
             </configuration>
         </plugin>
       </plugins>
   </build>

-Jeremy

On Sat, Dec 6, 2008 at 5:11 AM, Martin Olsen <ma...@martinolsen.net> wrote:

> Hi.
>
> I am receiving a NullPointerException when I try to get an EntityManager
> in a jUnit test.
>
> What am I missing?
>
>
> The attached files is organised like this:
>  pom.xml
>  src/main/java/domain/Animal.java
>  src/test/java/domain/OpenJPATest.java
>  src/test/resources/META-INF/persistence.xml
>
> The test is run with `mvn test`.
>
> The stacktrace is in the attached file domain.OpenJPATest.txt
>
>
> --
> Martin Olsen
> martin@martinolsen.net