|
Description
Michael OBrien
>Fix for Repro 2: switch the application.xml ordering to ejb/war <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="Application_ID" version="5"> <display-name> org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR</display-name> <module> <ejb>org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar</ejb> </module> <module> <web> <web-uri>org.eclipse.persistence.example.jpa.server.weblogic.enterpriseWeb.war</web-uri> <context-root>enterprise</context-root> </web> </module> </application> >There is a secondary issue here - when weaving is on and we do not find weaved methods
- we will want to warn and mention this classLoader order issue (EJB jar containing persistence unit must preceed any WAR injecting a bean containing the persistence unit) instead of throwing a NullPointerException because we expect the [value holder] method lookup to pass
>This bug is for community reference on the workaround for cases where a secondary NPE occurs because of application.xml ejb/war ordering >The bug was reopened because we have the goahead to enter a Warning to the user on the primary cause of the secondary NullPointerException - that occurs when an Entity is not weaved because the injected session bean containing the injected persistence context is processed after a war that uses the persistence unit via injection of the session bean in the ejb.jar. - the NPE cause is because the weaved "_*_vh" method was not found on the entity class >Warning addition: - add a warning to initializeDescriptors() that fails with a weaving method check - that we expected the current class to be woven/instrumented. >Bug is assigned only until I attach 2 nearly identical reproduction EAR files (one that fails and the other that does not) >Narrowed the issue down to the way JSF managed beans are deployed. As soon as we reference any POJO class as a managed-bean (where it contains an @EJB injection of a SSB that itself has an @PersistenceContext injection) - we fail with a secondary NPE when weaved methods are not found on the "should have been weaved" entity class >If you remove the managed-bean element or the faces-config-xml file itself - you deploy fine with any application.xml module order <managed-bean> <managed-bean-name>cell</managed-bean-name> <managed-bean-class>org.eclipse.persistence.example.jpa.server.weblogic.enterprise.presentation.CellBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> >where the annotated class is on the WAR public class CellBean { @EJB private ApplicationServiceLocal applicationService; private Cell cell; } >and the SSB is on the ejb.jar @Local public interface ApplicationServiceLocal {...} @Stateless public class ApplicationService implements ApplicationServiceLocal, ApplicationServiceRemote { @PersistenceContext(unitName="example", type=PersistenceContextType.TRANSACTION) private EntityManager entityManager; ...} >Note: it is not the @EJB injection itself that causes the issue - because a servlet works fine this way - it is the JSF use of classLoaders >I am attaching two reproduction EAR's and their Eclipse 3.5 OEPE project sets http://127.0.0.1:7001/enterprise_jsf/FrontController?action=demo WebLogicJTAbasedJSFSSB_EAR - fails on deploy (after a predeploy success) WebLogicJTAbasedServletSSB_EAR - works fine >Note: if you don't want to launch the URL above - you can do a deploy as part of the predeploy - using the following property in your persistence.xml <!-- 323148: force an early em.deploy() as part of the emf.predeploy() - normally done on first entityManager login --> <property name="eclipselink.validation-only" value="True"/> >exception is
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:74)
... 70 more
Exception [EclipseLink-70] (Eclipse Persistence Services - 2.2.0.qualifier): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A NullPointerException was thrown while extracting a value through the method [_persistence_get_right_vh] in the object [org.eclipse.persistence.example.jpa.server.business.Cell].
Internal Exception: java.lang.NullPointerException
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[right]
Descriptor: RelationalDescriptor(org.eclipse.persistence.example.jpa.server.business.Cell --> [DatabaseTable(EL_CELL)])
at org.eclipse.persistence.exceptions.DescriptorException.nullPointerWhileGettingValueThruMethodAccessor(DescriptorException.java:1256)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:84)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:53)
at org.eclipse.persistence.mappings.DatabaseMapping.getAttributeValueFromObject(DatabaseMapping.java:497)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.getAttributeValueFromObject(ForeignReferenceMapping.java:792)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.buildClone(ForeignReferenceMapping.java:180)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.populateAttributesForClone(ObjectBuilder.java:3146)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.populateAndRegisterObject(UnitOfWorkImpl.java:3690)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.cloneAndRegisterObject(UnitOfWorkImpl.java:1005)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:618)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:555)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:495)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:454)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:721)
at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:726)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:423)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1074)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:764)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1034)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:383)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1112)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2910)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1301)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1283)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1257)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:479)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:714)
at org.eclipse.persistence.example.jpa.server.business.ApplicationService.query(ApplicationService.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy142.query(Unknown Source)
at org.eclipse.persistence.example.jpa.server.business.ApplicationService_5ptwty_ApplicationServiceLocalImpl.query(ApplicationService_5ptwty_ApplicationServiceLocalImpl.java:181)
Created attachment 177110 [details]
EAR (with JSF managed-bean element) that reproduces NPE exception when application.xml module order is war first
Created attachment 177111 [details]
EAR (works fine application.xml module order is war first or ejb first) - no JSF = no JPA issues
>Major P2 because em deploy will not work without the module order workaround until JSF is fixed
Created attachment 177112 [details]
JSF EAR Eclipse projects - broken deploy reproduction
Created attachment 177113 [details]
Servlet EAR Eclipse projects - work fine as reference
>Note: it is only the deployment of the managed-bean that causes the issue - as the no-weaving issue occurs even without any functional JSF pages or navigation rules - a minimal faces-config.xml descriptor is all that is needed to break the persistenceContext - for even when the same injected persistence unit is used via @EJB injection on a separate non-JSF servlet the first-time deploy of the entityManager causes the NPE exception. >Here is the minimal faces-config.xml that will cause early loading of the Entity that disallows weaving later in em processing <?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> <application> <message-bundle>resources.application</message-bundle> <locale-config> <default-locale>en</default-locale> </locale-config> </application> <managed-bean> <managed-bean-name>cell</managed-bean-name> <managed-bean-class>org.eclipse.persistence.example.jpa.server.weblogic.enterprise.presentation.CellBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config> >The fix for the real issue is in JSF
>marking bug unassigned for the secondary fix of adding a proper EclipseLink warning
- when the class that should have been weaved - was not.
>Glassfish JSF 1.2: Of note is the fact that the JSF implementation used comes from Glassfish
C:\wse\wls10330\.metadata\.plugins\oracle.eclipse.tools.weblogic\libraries\jsf_1.2_1.2.9.0\1\WEB-INF\lib\glassfish.jsf_1.2.9.0.jar
C:\wse\wls10330\.metadata\.plugins\oracle.eclipse.tools.weblogic\libraries\jsf_1.2_1.2.9.0\1\WEB-INF\lib\javax.jsf_1.0.0.0_1-2.jar
C:\wse\wls10330\.metadata\.plugins\oracle.eclipse.tools.weblogic\libraries\jsf_1.2_1.2.9.0\1\WEB-INF\lib\wls.jsf.di.jar
Created attachment 177254 [details] New DescriptorException specifically for "_persistence_*_vh" weaved methods that would have thrown a secondary NPE >New DescriptorException specifically for "_persistence_*_vh" weaved methods that would have thrown a secondary NPE Exception [EclipseLink-218] (Eclipse Persistence Services - 2.2.0.qualifier): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A NullPointerException would have occurred accessing a non-existent weaved method [_persistence_get_right_vh] for the mapping [org.eclipse.persistence.mappings.OneToOneMapping[right]]. The class was not weaved properly - check the module order in the application.xml deployment descriptor and verify that the module containing the persistence unit is ahead of any module that uses it. at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:471) >Change to throw descriptive DescriptorException only for missing weaving "_persistence_*_vh" functions is in bug # 323403 >This bug representing the base issue with either the dependency injection wls.js.di.jar or the glassfish.jsf_1.2.9.0.jar is for tracking only and will be set to NOFIX The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |