Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

JPA + Spring + WebSphere NullPointerExcetion > PersistenceAnnotationBeanPostProcessor

$
0
0
I have an application that can run as either a stand-alone application (bundled as an executable JAR) or within a web container using Spring MVC (bundled as a WAR). On the back end I'm using the same configuration for both the stand-alone JAR and WAR with JPA/EclipseLink and JTA/Atomikos. My DAOs extend from a common DAO that injects multiple @Resource DataSource (for reference) and multiple @PersistenceContext EntityManager. Spring is configured using ContextSingletonBeanFactoryLocator with the standard beanRefContext.xml which loads all of the back end related beans in a service provider. web.xml is configured to use locatorFactorySelector that points to beanRefContext.xml and a parentContextKey with the same key used in the service provider to BeanFactoryReference#getFactory()#getBean(String). Both the stand-alone JAR and the WAR (tested in Tomcat and Tomee) runs without a problem. The problem is when I try to deploy the same WAR into WebSphere it has a problem with Spring's class loading mechanism when dealing with the DAO's. I get the following error:
Code:

Caused by: java.lang.NullPointerException: null
        at java.io.DataInputStream.readFully(DataInputStream.java:189) ~[na:1.6.0]
        at java.util.jar.JarFile.getBytes(JarFile.java:423) ~[na:1.6.0]
        at java.util.jar.JarFile.getManifestFromReference(JarFile.java:178) ~[na:1.6.0]
        at java.util.jar.JarFile.getManifest(JarFile.java:162) ~[na:1.6.0]
        at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:928) ~[na:1.6.0]
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:458) ~[na:1.6.0]
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:451) ~[na:1.6.0]
        at java.net.URLClassLoader.access$300(URLClassLoader.java:79) ~[na:1.6.0]
        at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1038) ~[na:1.6.0]
        at java.security.AccessController.doPrivileged(AccessController.java:284) ~[na:na]
        at java.net.URLClassLoader.findClass(URLClassLoader.java:429) ~[na:1.6.0]
        at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:191) ~[bootstrap.jar:WAS70.SERV1 [cf211150.04]]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:660) ~[na:1.6.0]
        at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:111) ~[bootstrap.jar:WAS70.SERV1 [cf211150.04]]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:626) ~[na:1.6.0]
        at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62) ~[com.ibm.ws.runtime.jar:WAS70.SERV1 [cf211150.04]]
        at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58) ~[com.ibm.ws.runtime.jar:WAS70.SERV1 [cf211150.04]]
        at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:510) ~[com.ibm.ws.runtime.jar:WAS70.SERV1 [cf211150.04]]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:626) ~[na:1.6.0]
        at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:510) ~[com.ibm.ws.runtime.jar:WAS70.SERV1 [cf211150.04]]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:626) ~[na:1.6.0]
        at java.lang.Class.getDeclaredMethodsImpl(Native Method) ~[na:1.6.0]
        at java.lang.Class.getDeclaredMethods(Class.java:680) ~[na:1.6.0]
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:384) ~[spring-orm-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:322) ~[spring-orm-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:844) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        ... 102 common frames omitted

As a side note... In order to keep the application generic enough to run as a stand-alone application or in any web container without any code modifications I'm not utilizing any of the EE configuration within WebSphere. Everything is self-contained by Spring within the WAR.

Viewing all articles
Browse latest Browse all 297

Trending Articles