cancel
Showing results for 
Search instead for 
Did you mean: 

EJB ref injection fails with NullPointerException on heavy load in WebServ.

patrik_spiess
Participant
0 Kudos

Hello,

I am facing a strange performance problem. I have two stateless session beans in one EJB project, both are exposed as web services. <br>One bean has only one method and forwards the incoming object to the other bean via an ejb reference.

@WebService(
   endpointInterface = "org.oasis_open.docs.wsrf.rw_2.NotificationConsumer", 
   serviceName = "ServiceMonitorNotificationConsumerService", 
   portName = "NotificationConsumerBindingPort", 
   targetNamespace = "http://docs.oasis-open.org/wsn/bw-2", 
   wsdlLocation = "META-INF/wsdl/org/oasis_open/docs/wsn/bw_2/NotificationConsumer/NotificationConsumer.wsdl"
)
@Stateless
public class NotificationConsumerImplBean {

	@EJB
	ServiceMonitorLocal serviceMonitor;

	public void notify(org.oasis_open.docs.wsn.b_2.Notify notify) {
		serviceMonitor.notify(notify);
	}

}

When I call the notify() method with low load (i.e. once every few seconds), everything works fine. <br>However, as soon as the load increases to e.g. 2-10 calls / second, I start getting the followng error message.

System exception  
[EXCEPTION]
 javax.ejb.EJBException: (Failed in component: com.sap/SIA_service_monitor_EAR) Exception raised from invocation of public void org.oasis_open.docs.wsrf.rw_2.NotificationConsumerImplBean.notify(org.oasis_open.docs.wsn.b_2.Notify) method on bean instance org.oasis_open.docs.wsrf.rw_2.NotificationConsumerImplBean@4852bccf for bean com.sap/SIA_service_monitor_EAR*annotation|SIA_service_monitor_ejb.jar*annotation|NotificationConsumerImplBean in application com.sap/SIA_service_monitor_EAR.; nested exception is: javax.ejb.EJBException: Exception in getMethodReady() for stateless bean com.sap/SIA_service_monitor_EAR*annotation|SIA_service_monitor_ejb.jar*annotation|ServiceMonitorBean; nested exception is: com.sap.engine.services.ejb3.util.pool.PoolException: javax.ejb.EJBException: (Failed in component: com.sap/SIA_service_monitor_EAR) Exception raised from invocation of public void com.sap.sia.serviceMonitor.ServiceMonitorBean.initPostConstruct() method on bean instance com.sap.sia.serviceMonitor.ServiceMonitorBean@5a8ab489 for bean com.sap/SIA_service_monitor_EAR*annotation|SIA_service_monitor_ejb.jar*annotation|ServiceMonitorBean in application com.sap/SIA_service_monitor_EAR.; nested exception is: java.lang.NullPointerException 
javax.ejb.EJBException: Exception in getMethodReady() for stateless bean com.sap/SIA_service_monitor_EAR*annotation|SIA_service_monitor_ejb.jar*annotation|ServiceMonitorBean; nested exception is: com.sap.engine.services.ejb3.util.pool.PoolException: javax.ejb.EJBException: (Failed in component: com.sap/SIA_service_monitor_EAR) Exception raised from invocation of public void com.sap.sia.serviceMonitor.ServiceMonitorBean.initPostConstruct() method on bean instance com.sap.sia.serviceMonitor.ServiceMonitorBean@5a8ab489 for bean com.sap/SIA_service_monitor_EAR*annotation|SIA_service_monitor_ejb.jar*annotation|ServiceMonitorBean in application com.sap/SIA_service_monitor_EAR.; nested exception is: java.lang.NullPointerException 
com.sap.engine.services.ejb3.util.pool.PoolException: javax.ejb.EJBException: (Failed in component: com.sap/SIA_service_monitor_EAR) Exception raised from invocation of public void com.sap.sia.serviceMonitor.ServiceMonitorBean.initPostConstruct() method on bean instance com.sap.sia.serviceMonitor.ServiceMonitorBean@5a8ab489 for bean com.sap/SIA_service_monitor_EAR*annotation|SIA_service_monitor_ejb.jar*annotation|ServiceMonitorBean in application com.sap/SIA_service_monitor_EAR.; nested exception is: java.lang.NullPointerException 
at com.sap.engine.services.ejb3.util.pool.ContainerPool.translate(ContainerPool.java:288) 
at com.sap.engine.services.ejb3.util.pool.ContainerPoolImpl.doResizeOneStepUp(ContainerPoolImpl.java:378) 
at com.sap.engine.services.ejb3.util.pool.ContainerPoolImpl.ensureNotEmpty(ContainerPoolImpl.java:342) 
at com.sap.engine.services.ejb3.util.pool.ContainerPoolImpl.pop(ContainerPoolImpl.java:309) 
at com.sap.engine.services.ejb3.runtime.impl.StatelessInstanceLifecycleManager.getMethodReady(StatelessInstanceLifecycleManager.java:64) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:14) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:21) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:16) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:133) 
at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:164) 
at $Proxy1993.notify(Unknown Source) 
at org.oasis_open.docs.wsrf.rw_2.NotificationConsumerImplBean.notify(NotificationConsumerImplBean.java:44) 
at sun.reflect.GeneratedMethodAccessor986.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:585) 
at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:46) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_WS.invoke(Interceptors_WS.java:31) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:71) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:38) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:22) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:189) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:16) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:21) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:16) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:133) 
at com.sap.engine.services.ejb3.webservice.impl.DefaultImplementationContainer.invokeMethod(DefaultImplementationContainer.java:203) 
at com.sap.engine.services.webservices.espbase.server.runtime.RuntimeProcessingEnvironment.process0(RuntimeProcessingEnvironment.java:456) 
at com.sap.engine.services.webservices.espbase.server.runtime.OneWayProcessor.run(OneWayProcessor.java:40) 
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:169) 
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:266) 
Caused by: javax.ejb.EJBException: (Failed in component: com.sap/SIA_service_monitor_EAR) Exception raised from invocation of public void com.sap.sia.serviceMonitor.ServiceMonitorBean.initPostConstruct() method on bean instance com.sap.sia.serviceMonitor.ServiceMonitorBean@5a8ab489 for bean com.sap/SIA_service_monitor_EAR*annotation|SIA_service_monitor_ejb.jar*annotation|ServiceMonitorBean in application com.sap/SIA_service_monitor_EAR.; nested exception is: java.lang.NullPointerException 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Application.invoke(Interceptors_Application.java:76) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_BeanClassCallbackApplication.invoke(Interceptors_BeanClassCallbackApplication.java:17) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:71) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_DependencyInjection.invoke(Interceptors_DependencyInjection.java:46) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_EJBContext30DependencyInjection.invoke(Interceptors_EJBContext30DependencyInjection.java:11) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ApplicationInstancesCreator.invoke(Interceptors_ApplicationInstancesCreator.java:53) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:71) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:189) 
at com.sap.engine.services.ejb3.runtime.impl.Interceptors_NewBeanContext.invoke(Interceptors_NewBeanContext.java:17) 
at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) 
at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startCallback(DefaultInvocationChainsManager.java:147) 
at com.sap.engine.services.ejb3.runtime.impl.StatelessInstanceLifecycleManager.makeExist(StatelessInstanceLifecycleManager.java:108) 
at com.sap.engine.services.ejb3.runtime.impl.StatelessInstanceLifecycleManager.access$000(StatelessInstanceLifecycleManager.java:23) 
at com.sap.engine.services.ejb3.runtime.impl.StatelessInstanceLifecycleManager$PoolUserImpl.createObject(StatelessInstanceLifecycleManager.java:34) 
at com.sap.engine.services.ejb3.util.pool.ContainerPoolImpl.doResizeOneStepUp(ContainerPoolImpl.java:373) 
... 42 more 
[... many more of the same kind ...]

Intuition tells me this is a configuration problem, and if I find the setting for initial pool size and set it to a high number, this will not happen. <br>I assume this because the doResizeOneStepUp() method fails.

Am I right? If so, where can I set this setting? I have been looking, but could not find it in documetation.

For completeness, here is also the code of the initPostConstruct method (of the bean that is called) it complains about:

	@PostConstruct
	public void initPostConstruct() {
		if (serviceStateCache == null) {
			serviceStateCache = ServiceStateCache.getSingletonInstance();
		}
		if (eventingPort == null) {
			eventingPort = eventingService.getEventingPort();
		}
		if (getCentralConfigProperty("servicemonitor.publisherRegistrationReference") == null) {
			throw new SiaNotConfiguredException();
		}
		if (topicNameServiceChange == null) {
			topicNameServiceChange = getCentralConfigProperty("topicName.serviceEvent");
		}
		if (generateRandomDevices == null) {
			String tmp = getCentralConfigProperty("servicemonitor.generateRandomDevices");
			generateRandomDevices = !(tmp == null || tmp.length() == 0
					|| tmp.equalsIgnoreCase("no") || tmp.equals("0"));
			if (generateRandomDevices
					&& serviceStateCache.getNumberOfInstances() == 0) {
				generateRandomServiceInstances(1000);
			}
		}
	}

Best regards,

Patrik

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Patrik,

> Exception raised from invocation of public void com.sap.sia.serviceMonitor.ServiceMonitorBean.initPostConstruct() method on bean instance com.sap.sia.serviceMonitor.ServiceMonitorBean@5a8ab489 ... ; nested exception is: java.lang.NullPointerException

The NPE occurs in the bean code, in the initPostConstruct() method or some other method it calls. Unfortunately, its stack trace is not available above, but you should be able to find it in the defaultTrace file.

HTH!

\-- Vladimir

Answers (0)