axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "pawan bhole (JIRA)" <axis-...@ws.apache.org>
Subject [jira] Created: (AXIS-2800) Axis locators not thread safe (java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread)
Date Thu, 13 Aug 2009 14:46:15 GMT
Axis locators not thread safe (java.util.ConcurrentModificationException: concurrent access
to HashMap attempted by Thread)
---------------------------------------------------------------------------------------------------------------------------

                 Key: AXIS-2800
                 URL: https://issues.apache.org/jira/browse/AXIS-2800
             Project: Axis
          Issue Type: Bug
          Components: Basic Architecture
    Affects Versions: 1.4
         Environment: Axis version: 1.4
Jre version: 1.5
windows server 2003 R2 Service pack 2
Websphere version : 6.1.0.25
            Reporter: pawan bhole


i am creating locators only once and storing those in HashMap. And at every service call (by
multiple threads parallely) I am just retriving locators from HashMap and using those for
creating methode call.

Code:

public class WsClientRetriever {

    protected final Log log = LogFactory.getLog(getClass());
    
    protected final HashMap<Class<? extends Service>,Object> servicesMapCache
= new HashMap<Class<? extends Service>, Object>();
    
    /**
     * The url for the services
     */
    private String rootUrl;
    
    /**
     * This generic method will return the WebService class using the given web service locator
class
     * @param serviceLocatorClass
     * @return
     * @throws ServiceRetrievalException if the service could not be retrieved in any ways
     */
    public synchronized Object getWebService(Class<? extends Service> serviceLocatorClass)
throws ServiceRetrievalException {
        Object locator = servicesMapCache.get(serviceLocatorClass);
        Object result = null;
        // it's not in our cache, we have to get it using reflexion
        try {
        	if (locator == null) {
        		locator = serviceLocatorClass.newInstance();
        		servicesMapCache.put(serviceLocatorClass, locator);
        	}
            Method[] methods = serviceLocatorClass.getMethods();
            // we look for the method that needs an URL as parameter and starts with get
            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];
                if (method.getName().startsWith("get") && (method.getParameterTypes().length
== 1) && (method.getParameterTypes()[0] == URL.class)){
                    // we found it, we need to call it
                    result = method.invoke(locator, getWSURL(serviceLocatorClass));
                }
                
            }
        } catch (Exception e) {
            throw new ServiceRetrievalException(serviceLocatorClass, e);
        }
        // now we are sure to have it
        return result;
    }

    
    /**
     * Creates the URL to access the web service
     * @param serviceLocatorClass service locator class name
     * @return URL of the service where deployed
     */
    private URL getWSURL(Class<? extends Service> serviceLocatorClass) {

        String slClassName = serviceLocatorClass.getName();

        String serviceClassName = slClassName.substring(slClassName.lastIndexOf('.') + 1,
slClassName.lastIndexOf("ServiceLocator"));
        String serviceURLString = rootUrl + serviceClassName;
        URL serviceURL = null;
        try {
            serviceURL = new URL(serviceURLString);
            return serviceURL;
        } catch (MalformedURLException e) {
            log.debug("caught an exception", e);
            throw new WebServiceRetrievalException(serviceURLString, e);
        }
    }

    /**
     * @param rootUrl the rootUrl to set
     */
    public void setRootUrl(String rootUrl) {
        this.rootUrl = rootUrl;
        if (this.rootUrl != null && !this.rootUrl.endsWith("/")) {
            this.rootUrl += "/";
        }
    }

}
    
*********************************************************************************************************************************


stack trace :

[8/13/09 16:55:21:077 IST] 00000026 ExceptionUtil E   CNTR0020E: EJB threw an unexpected (non-declared)
exception during invocation of method "onMessage" on bean "BeanId(ProPayEAR#ProPayEJB-1.2-ENGINE-SPR7-IT1-SNAPSHOT.jar#MessageProcessor,
null)". Exception data: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:96)
	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132)
	at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:492)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
Caused by: java.lang.RuntimeException: com.te.jpay.exception.EnvironmentalException: Failure
trying to get the Call object; nested exception is: 
	java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[MessageListenerThreadPool
: 0,5,main]
	at com.te.jpay.ejb.messagesreceiver.MessagesProcessorBean.onMessage(MessagesProcessorBean.java:62)
	at com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:302)
	at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
	at com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:271)
	at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:240)
	at com.ibm.mq.jms.MQSession.run(MQSession.java:1691)
	at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:975)
	at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:957)
	at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:667)
	at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:634)
	... 9 more
Caused by: com.te.jpay.exception.EnvironmentalException: Failure trying to get the Call object;
nested exception is: 
	java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[MessageListenerThreadPool
: 0,5,main]
	at com.te.jpay.backendintegration.tietoapps.jdir.CreditMechanismHelperWsImpl.getCreditMechanism(CreditMechanismHelperWsImpl.java:75)
	at com.te.jpay.backendintegration.tietoapps.jdir.CreditMechanismHelperWsImpl.assignCreditMechanism(CreditMechanismHelperWsImpl.java:101)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
	at org.perf4j.aop.AbstractTimingAspect.doPerfLogging(AbstractTimingAspect.java:69)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy73.assignCreditMechanism(Unknown Source)
	at com.te.jpay.backendintegration.tietoapps.jdir.JDirectoryClientImpl.assignCreditMechanism(JDirectoryClientImpl.java:123)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
	at org.perf4j.aop.AbstractTimingAspect.doPerfLogging(AbstractTimingAspect.java:69)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy76.assignCreditMechanism(Unknown Source)
	at com.te.jpay.processing.InwardDDCollectionReceiverImpl.performGroupLevelProcessing(InwardDDCollectionReceiverImpl.java:110)
	at com.te.jpay.processing.InwardDDCollectionReceiverImpl.doBusinessLogic(InwardDDCollectionReceiverImpl.java:64)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
	at org.perf4j.aop.AbstractTimingAspect.doPerfLogging(AbstractTimingAspect.java:69)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy77.doBusinessLogic(Unknown Source)
	at com.te.jpay.dispatch.DefaultPaymentDispatcher.dispatchMessageFromBulker(DefaultPaymentDispatcher.java:108)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
	at org.perf4j.aop.AbstractTimingAspect.doPerfLogging(AbstractTimingAspect.java:69)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:618)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy78.dispatchMessageFromBulker(Unknown Source)
	at com.te.jpay.ejb.messagesreceiver.MessagesProcessorBean.onMessage(MessagesProcessorBean.java:49)
	... 18 more
Caused by: Failure trying to get the Call object; nested exception is: 
	java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[MessageListenerThreadPool
: 0,5,main]
	at com.te.prodirectory.ws.client.mechanism.MechanismWSSoapBindingStub.createCall(MechanismWSSoapBindingStub.java:384)
	at com.te.prodirectory.ws.client.mechanism.MechanismWSSoapBindingStub.getMechanismParameterByCodeword(MechanismWSSoapBindingStub.java:460)
	at com.te.jpay.backendintegration.tietoapps.jdir.CreditMechanismHelperWsImpl.getCreditMechanism(CreditMechanismHelperWsImpl.java:73)
	... 108 more
Caused by: java.util.ConcurrentModificationException: concurrent access to HashMap attempted
by Thread[MessageListenerThreadPool : 0,5,main]
	at java.util.HashMap.onExit(HashMap.java:226)
	at java.util.HashMap.transfer(HashMap.java:690)
	at java.util.HashMap.resize(HashMap.java:676)
	at java.util.HashMap.addEntry(HashMap.java:1049)
	at java.util.HashMap.put(HashMap.java:561)
	at org.apache.axis.encoding.TypeMappingImpl.internalRegister(TypeMappingImpl.java:263)
	at org.apache.axis.encoding.TypeMappingImpl.register(TypeMappingImpl.java:221)
	at org.apache.axis.encoding.TypeMappingDelegate.register(TypeMappingDelegate.java:73)
	at org.apache.axis.client.Call.registerTypeMapping(Call.java:2285)
	at org.apache.axis.client.Call.registerTypeMapping(Call.java:2322)
	at com.te.prodirectory.ws.client.mechanism.MechanismWSSoapBindingStub.createCall(MechanismWSSoapBindingStub.java:369)
	... 110 more



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message