openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Deppe <jde...@vmware.com>
Subject NullPointerException from EntityManagerImpl
Date Fri, 04 Mar 2011 23:59:12 GMT
Hi,

I'm trying to use OpenJPA 2.0.1 with the Spring WebFlow booking sample
app and am having some trouble.

I've set up my data access as follows:

           <!-- Drives transactions using local JPA APIs -->
           <bean id="transactionManager" 
class="org.springframework.orm.jpa.JpaTransactionManager">
                   <property name="entityManagerFactory"
ref="entityManagerFactory" />
           </bean>

           <!-- Creates a EntityManagerFactory for use with the OpenJPA
provider and a simple in-memory data source populated with test data -->
           <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                   <property name="dataSource" ref="dataSource" />
                   <property name="jpaVendorAdapter">
                           <bean
class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter" />
                   </property>
                   <property name="loadTimeWeaver">
                       <bean
class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
                   </property>
           </bean>

My persistence.xml looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
              version="1.0">
    <persistence-unit name="bookingDatabase">
 
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
       <class>org.springframework.webflow.samples.booking.User</class>
       <class>org.springframework.webflow.samples.booking.Booking</class>
       <class>org.springframework.webflow.samples.booking.Hotel</class>
       <properties>
           <property name="openjpa.RuntimeUnenhancedClasses" 
value="supported"/>
           <property name="openjpa.jdbc.SynchronizeMappings" 
value="buildSchema(ForeignKeys=true)"/>
           <property name="openjpa.MetaDataFactory" 
value="jpa(Types=org.springframework.webflow.samples.booking.User;org.springframework.webflow.samples.booking.Booking;org.springframework.webflow.samples.booking.Hotel)"/>
       </properties>
    </persistence-unit>
</persistence>



Everything seems to work fine until I hit a page which signals the start 
of a flow, at which point I get the following exception:

java.lang.NullPointerException
	org.apache.openjpa.persistence.EntityManagerImpl.readExternal(EntityManagerImpl.java:1441)
	java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)
	java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
	java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
	java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
	java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
	java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
	java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
	java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
	java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
	java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
	java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
	java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
	org.springframework.webflow.core.collection.LocalAttributeMap.readObject(LocalAttributeMap.java:342)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	java.lang.reflect.Method.invoke(Method.java:597)
	java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
	java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
	java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
	java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
	java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
	org.springframework.webflow.engine.impl.FlowSessionImpl.readExternal(FlowSessionImpl.java:147)
	java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)
	java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
	java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
	java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
	java.util.LinkedList.readObject(LinkedList.java:964)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	java.lang.reflect.Method.invoke(Method.java:597)
	java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
	java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
	java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
	java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
	java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
	org.springframework.webflow.engine.impl.FlowExecutionImpl.readExternal(FlowExecutionImpl.java:305)
	java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1791)
	java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
	java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
	java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
	org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.deserialize(SerializedFlowExecutionSnapshot.java:194)
	org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.unmarshal(SerializedFlowExecutionSnapshot.java:99)
	org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.restoreExecution(SerializedFlowExecutionSnapshotFactory.java:80)
	org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.restoreFlowExecution(AbstractSnapshottingFlowExecutionRepository.java:89)
	org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.getFlowExecution(DefaultFlowExecutionRepository.java:112)
	org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:168)
	org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	com.gemstone.gemfire.modules.session.filter.ServletWrapper.service(ServletWrapper.java:72)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
	org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	com.gemstone.gemfire.modules.session.filter.SessionCachingFilter.doFilter(SessionCachingFilter.java:434)


Doing some debugging, I can see that the factoryKey
(EntityManagerImpl.java:1437) being deserialized is null. That's because
it was written as null (line 1464):

Object factoryKey = ((AbstractBrokerFactory) _broker
                 .getBrokerFactory()).getPoolKey();

Here getPoolKey() returns null.

So is this a bug, or should I be configuring something else/differently
to get this to work?

TIA.

--Jens

Mime
View raw message