Monday, August 11, 2014

incompatible JPA spec

Sometimes you can get an error like so:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/sprin
g/spring-orm.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMod
e()Ljavax/persistence/ValidationMode;


It could also mean that the dependency you are including may be dependent on an incompatible dependency with your project.
for example..
you can do <exclusions> tag to not package the offending dependency in your war by doing something like this:

<dependency>
   <groupId>com.ibm.websphere</groupId>
   <artifactId>wxsutils</artifactId>
   <version>2.5.4-SNAPSHOT</version>
           <exclusions>
                 <exclusion>
                   <groupId>org.apache.geronimo.specs</groupId>
                   <artifactId>geronimo-jpa_3.0_spec</artifactId>
                </exclusion>
           </exclusions>
</dependency>