openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy Bauer" <techhu...@gmail.com>
Subject Re: NullPointerException when calling createEntityManager on EntityManagerFactory
Date Mon, 08 Dec 2008 19:38:09 GMT
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 <martin@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message