Community
Participate
Working Groups
>The following common NullPointerException occurs because weaving VH methods were not found. The cause is the fact that because weaving is on globally or for a mapping via FetchType.LAZY - the validation check during the entityManager deploy will fail with a NPE on an expected value holder method that should have been weaved into the .class file >Solution: Switch the order of modules in application.xml to load the module (usually ejb.jar) containing the injected EM/EMF - the module (here a JSF managed-bean POJO in the WAR) that uses for example the Stateless session bean containing the @PersistenceContext injection (in the ejb.jar) should come after the ejb.jar in the EAR's application.xml deployment descriptor >Another workaround is to disable weaving if you do not need it in the persistence.xml or by mapping via FetchType.EAGER -------------------details-------------------- >Environment - GlassFish 3.x or WebLogic 10.3.3+ - Container managed EntityManager as an injected @PersistenceContext resource on a @Stateless session bean - on the ejb.jar - a JTA TX datasource on the server (here Derby 10.5.3.0) >Exception Exception [EclipseLink-60] (Eclipse Persistence Services - 2.2.0.qualifier): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The method [_persistence_set_left_vh] or [_persistence_get_left_vh] is not defined in the object [org.eclipse.persistence.example.jpa.server.business.Cell]. Internal Exception: java.lang.NoSuchMethodException: org.eclipse.persistence.example.jpa.server.business.Cell._persistence_get_left_vh() Mapping: org.eclipse.persistence.mappings.OneToOneMapping[left] Descriptor: RelationalDescriptor(org.eclipse.persistence.example.jpa.server.business.Cell --> [DatabaseTable(EL_CELL)]) Runtime Exceptions: --------------------------------------------------------- java.lang.NullPointerException at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:471) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:374) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:157) at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:243) Truncated. see log file for complete stacktrace java.lang.NullPointerException at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getMethodReturnType(PrivilegedAccessHelper.java:327) at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getGetMethodReturnType(MethodAttributeAccessor.java:126) at org.eclipse.persistence.mappings.ForeignReferenceMapping.validateBeforeInitialization(ForeignReferenceMapping.java:1709) at org.eclipse.persistence.descriptors.ClassDescriptor.validateBeforeInitialization(ClassDescriptor.java:5282) at org.eclipse.persistence.descriptors.ClassDescriptor.preInitialize(ClassDescriptor.java:3346) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:429) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:374) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:157) at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:243) at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:352) at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:332) at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:134) at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:336) at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptor(AbstractPersistenceUnitRegistry.java:250) at weblogic.deployment.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:69) at weblogic.ejb.container.deployer.EJBModule.setupPersistenceUnitRegistry(EJBModule.java:221) at weblogic.ejb.container.deployer.EJBModule$1.execute(EJBModule.java:322) at weblogic.deployment.PersistenceUnitRegistryInitializer.setupPersistenceUnitRegistries(PersistenceUnitRegistryInitializer.java:62) at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:398) at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176) at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199) at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45) at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:1221) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41) at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:367) at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58) at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154) at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747) at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216) at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) >Stacktrace Oracle WebLogic Server 11gR1 PatchSet 2 at localhost [Oracle WebLogic Launch Configuration] Oracle JRockit(R)[localhost:8453] Daemon Thread [[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended (breakpoint at line 327 in PrivilegedAccessHelper)) PrivilegedAccessHelper.getMethodReturnType(Method) line: 327 MethodAttributeAccessor.getGetMethodReturnType(DatabaseMapping) line: 126 OneToOneMapping(ForeignReferenceMapping).validateBeforeInitialization(AbstractSession) line: 1709 RelationalDescriptor(ClassDescriptor).validateBeforeInitialization(AbstractSession) line: 5282 RelationalDescriptor(ClassDescriptor).preInitialize(AbstractSession) line: 3346 ServerSession(DatabaseSessionImpl).initializeDescriptors(Map) line: 429 ServerSession(DatabaseSessionImpl).initializeDescriptors() line: 406 EntityManagerSetupImpl.deploy(ClassLoader, Map) line: 374 EntityManagerFactoryImpl.getServerSession() line: 157 PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnitInfo, Map) line: 243 PersistenceUnitInfoImpl.createEntityManagerFactory(boolean) line: 352 PersistenceUnitInfoImpl.createEntityManagerFactory() line: 332 PersistenceUnitInfoImpl.<init>(PersistenceUnitBean, PersistenceUnitConfigurationBean, GenericClassLoader, String, URL, URL) line: 134 ModulePersistenceUnitRegistry(AbstractPersistenceUnitRegistry).storeDescriptors(Map, Map) line: 336 ModulePersistenceUnitRegistry(AbstractPersistenceUnitRegistry).loadPersistenceDescriptor(VirtualJarFile, boolean, File) line: 250 ModulePersistenceUnitRegistry.<init>(GenericClassLoader, ApplicationContextInternal, Module, boolean) line: 69 EJBModule.setupPersistenceUnitRegistry() line: 221 EJBModule$1.execute() line: 322 PersistenceUnitRegistryInitializer.setupPersistenceUnitRegistries() line: 62 WebAppModule.prepare() line: 398 ScopedModuleDriver.prepare() line: 176 ModuleListenerInvoker.prepare() line: 199 DeploymentCallbackFlow$1.next(Object) line: 507 StateMachineDriver.nextState(StateChange, Object[]) line: 41 DeploymentCallbackFlow.prepare(Module[]) line: 149 DeploymentCallbackFlow.prepare() line: 45 BaseDeployment$1.next(Object) line: 1221 StateMachineDriver.nextState(StateChange, Object[]) line: 41 EarDeployment(BaseDeployment).prepare(DeploymentContext) line: 367 EarDeployment.prepare(DeploymentContext) line: 58 DeploymentStateChecker.prepare(DeploymentContext) line: 154 AppContainerInvoker.prepare(DeploymentContext) line: 60 ActivateOperation.createAndPrepareContainer() line: 207 ActivateOperation.doPrepare() line: 98 ActivateOperation(AbstractOperation).prepare() line: 217 DeploymentManager.handleDeploymentPrepare(Deployment, DeploymentManager$DeploymentRequestInfo) line: 747 DeploymentManager.prepareDeploymentList(ArrayList, DeploymentContext) line: 1216 DeploymentManager.handlePrepare(DeploymentContext) line: 250 DeploymentServiceDispatcher.prepare(DeploymentContext) line: 159 DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentContext) line: 171 DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer, DeploymentContext) line: 13 DeploymentReceiverCallbackDeliverer$1.run() line: 46 SelfTuningWorkManagerImpl$WorkAdapterImpl.run() line: 528 ExecuteThread.execute(Runnable) line: 201 ExecuteThread.run() line: 173 >As you can see we have the weaving method names but not the methods themselves this MethodAttributeAccessor (id=12548) attributeName "right" (id=12549) getMethod null getMethodName "_persistence_get_right_vh" (id=12563) isReadOnly false isWriteOnly false setMethod null setMethodName "_persistence_set_right_vh" (id=12564) mapping OneToOneMapping (id=12547) getMethod null >cause: calling method.getReturnType() when method == null without checking this PrivilegedAccessHelper.java:326 public static Class getMethodReturnType(final Method method) { // 323148: a null method as a possible problem with module ordering breaking weaving - has been trapped by implementors of this method. return method.getReturnType(); } >The cause of the NPE was a group effort between Michael O'Brien, Douglas Clarke and Steve Button. >The following open issues benefit from this fix. Re: [eclipselink-users] OneToOne AND ManyToOne Mapping works with FetchType.EAGER but not with FetchType.LAZY -> Exception when deploying (SGES 2.1) http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05147.html Re: [eclipselink-users] JPA not working inside Equinox but fine in unit tests http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05146.html Re: [eclipselink-users] Can't deploy when using LAZY, can deply when using EAGER http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05145.html Re: [eclipselink-users] NPE when running with option javaagent:eclipselink.jar http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05144.html JPA test suties failed in OSGi with enabled weaving https://bugs.eclipse.org/bugs/show_bug.cgi?id=293193#c7
Created attachment 177233 [details] EAR (with JSF managed-bean element) that reproduces NPE exception when application.xml module order is war first
Created attachment 177234 [details] EAR Eclipse Project Source (3) (with JSF managed-bean element) that reproduces NPE exception when application.xml module order is war first
Created attachment 177253 [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)
>post patch to eclipselink-dev for review http://dev.eclipse.org/mhonarc/lists/eclipselink-dev/msg04791.html
>Note: the secondary NPE on missing _vh_ weaved functions in bug # 322679 will show this change after checkin
Created attachment 177431 [details] New 218 DescriptorException specifically for "_persistence_*_vh" weaved methods that would have thrown a secondary NPE
Created attachment 177469 [details] Remove override of MethodAttributeAccessor function so there is no redirect of SDOMethodAttributAccessor for SDO
>See checkin of new 218 exception patch https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8081 >See JPA fix that fixes SDO temporary redirection of SDOMethodAttributeAccessor.getGetMethodReturnType() to superclass https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8085
>retest 8085 on WebLogic with a broken JSF ear in web/ejb order - OK (expected exception on deploy) Exception Description: A NullPointerException would have occurred accessing a non-existent weaved _vh_ method [_persistence_get_right_vh]. The class was not weaved properly - for EE deployments, check the module order in the application.xml deployment descriptor and verify that the module containing the persistence unit is ahead of any other module that uses it. - reversing the application.xml order failed to print the exception on deploy - as expected, where JSF was initialized fine in this case 25-Aug-2010 4:04:34 PM com.sun.faces.config.ConfigureListener contextInitialized INFO: Initializing Mojarra (1.2_09-20081212-SNAPSHOT) for context '/enterprise_jsf'
>See rev# 8081, 8085 for new 218 DescriptorException
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink