Uploaded image for project: 'Axis'
  1. Axis
  2. AXIS-2826

Fine-grained lock is required in public synchronized ServiceDesc getInitializedServiceDesc

    XMLWordPrintableJSON

Details

    Description

      The below exception is getting for all web service requests.

      201109 23:18:30,187 [DEBUG][org.apache.axis.utils.NSStack ][queue: 'default'] NSPop (empty)
      AxisFault
      faultCode:

      {http://schemas.xmlsoap.org/soap/envelope/}

      Server.userException
      faultSubcode:
      faultString: java.lang.NullPointerException
      faultActor:
      faultNode:
      faultDetail:

      {http://xml.apache.org/axis/}

      stackTrace:java.lang.NullPointerException
      at org.apache.axis.description.JavaServiceDesc.loadServiceDescByIntrospection(JavaServiceDesc.java:901)
      at org.apache.axis.description.JavaServiceDesc.loadServiceDescByIntrospection(JavaServiceDesc.java:846)
      at org.apache.axis.description.JavaServiceDesc.initQNameMap(JavaServiceDesc.java:544)
      at org.apache.axis.description.JavaServiceDesc.getOperationsByQName(JavaServiceDesc.java:484)
      at org.apache.axis.MessageContext.getPossibleOperationsByQName(MessageContext.java:243)
      at org.apache.axis.message.BodyBuilder.onStartChild(BodyBuilder.java:132)
      at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
      at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1289)
      at org.apache.xerces.framework.XMLParser.callStartElement(XMLParser.java:1922)
      at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1831)
      at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1223)
      at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
      at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1208)
      at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
      at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
      at org.apache.axis.server.AxisServer.initSOAPConstants(AxisServer.java:345)
      at org.apache.axis.server.AxisServer.invoke(AxisServer.java:279)
      at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

      My observations are for every request to WSDL/API, the below is the stack trace for initializing operations list. Now four requests came for service parallelly and processing started by ExecuteThreads: '11' , 12, 13, 14. In this flow method 'SOAPService.getInitializedServiceDesc' is already synchronized, so we can expect only one thread allowed inside but here four threads are entering with the same instance of JavaServiceDesc(org.apache.axis.description.JavaServiceDesc@e94a8)

      WSDDService calling SOAPService.getInitializedServiceDesc and WSDDService/SOAPService are not static or singleton classes. Every time new instance of SOAPService is created and breaking thread safety.

      If AxisServlet.doGet called parellelly from different IP addresses then multiple threads loading 'operations' ArrayList parellelly and duplicate entries adding. This list size showing differently for every restart. Some times values are overriding with null by other threads.

      Stack Trace:
      org.apache.axis.description.JavaServiceDesc.createOperationForMethod(JavaServiceDesc.java:1331)
      org.apache.axis.description.JavaServiceDesc.createOperationsForName(JavaServiceDesc.java:1188)
      org.apache.axis.description.JavaServiceDesc.getSyncedOperationsForName(JavaServiceDesc.java:1150)
      org.apache.axis.description.JavaServiceDesc.loadServiceDescByIntrospectionRecursive(JavaServiceDesc.java:997)
      org.apache.axis.description.JavaServiceDesc.loadServiceDescByIntrospection(JavaServiceDesc.java:922)
      org.apache.axis.providers.java.JavaProvider.initServiceDesc(JavaProvider.java:477)
      org.apache.axis.handlers.soap.SOAPService.getInitializedServiceDesc(SOAPService.java:285)
      org.apache.axis.deployment.wsdd.WSDDService.makeNewInstance(WSDDService.java:503)
      org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployableItem.java:274)
      org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableItem.java:260)
      org.apache.axis.deployment.wsdd.WSDDDeployment.getService(WSDDDeployment.java:427)
      org.apache.axis.configuration.FileProvider.getService(FileProvider.java:231)
      org.apache.axis.AxisEngine.getService(AxisEngine.java:311)
      org.apache.axis.MessageContext.setTargetService(MessageContext.java:758)
      org.apache.axis.handlers.http.URLMapper.invoke(URLMapper.java:50)
      org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
      org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
      org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
      org.apache.axis.server.AxisServer.invoke(AxisServer.java:239)
      org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)

      SOAPService.getInitializedServiceDesc with more debugs:

      /**

      • Returns a service description with the implementation class filled in.
      • Syncronized to prevent simutaneous modification of serviceDescription.
        */
        public synchronized ServiceDesc getInitializedServiceDesc(
        MessageContext msgContext)
        throws AxisFault {

      count++;
      if (log.isDebugEnabled())

      { log.debug("serviceDescription.isInitialized():"+serviceDescription.isInitialized()+",count:"+count+",this:"+this); }

      if (!serviceDescription.isInitialized()) {

      // Let the provider do the work of filling in the service
      // descriptor. This is so that it can decide itself how best
      // to map the Operations. In the future, we may want to support
      // providers which don't strictly map to Java class backends
      // (BSFProvider, etc.), and as such we hand off here.
      if (pivotHandler instanceof BasicProvider)

      { ((BasicProvider)pivotHandler).initServiceDesc(this, msgContext); }

      }
      if (log.isDebugEnabled())

      { log.debug("end of serviceDescription"+serviceDescription.isInitialized()+",count:"+count+",this:"+this); }

      return serviceDescription;
      }

      axis logs :

      181209 19:18:08,903 [DEBUG][e.axis.handlers.soap.SOAPService][ExecuteThread: '11' for queue: 'default'] serviceDescription.isInitialized():false,count:1,this:org.apache.axis.han dlers.soap.SOAPService@c3da75
      181209 19:18:08,903 [DEBUG][e.axis.handlers.soap.SOAPService][ExecuteThread: '12' for queue: 'default'] serviceDescription.isInitialized():false,count:1,this:org.apache.axis.handlers.soap.SOAPService@3b7230
      181209 19:18:08,904 [DEBUG][e.axis.handlers.soap.SOAPService][ExecuteThread: '13' for queue: 'default'] serviceDescription.isInitialized():false,count:1,this:org.apache.axis.handlers.soap.SOAPService@1255c01
      181209 19:18:08,904 [DEBUG][e.axis.handlers.soap.SOAPService][ExecuteThread: '14' for queue: 'default'] serviceDescription.isInitialized():false,count:1,this:org.apache.axis.handlers.soap.SOAPService@1bb660a
      181209 19:18:08,906 [DEBUG][axis.providers.java.JavaProvider][ExecuteThread: '11' for queue: 'default'] JavaServiceDesc instanceorg.apache.axis.description.JavaServiceDesc@e94a8 8
      181209 19:18:08,906 [DEBUG][axis.providers.java.JavaProvider][ExecuteThread: '14' for queue: 'default'] JavaServiceDesc instanceorg.apache.axis.description.JavaServiceDesc@e94a8 8
      181209 19:18:08,906 [DEBUG][axis.providers.java.JavaProvider][ExecuteThread: '12' for queue: 'default'] JavaServiceDesc instanceorg.apache.axis.description.JavaServiceDesc@e94a8 8
      181209 19:18:08,906 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '11' for queue: 'default'] Array List operations:[] size:0 implClass:class com.xxxxxxx.services .axis.MM7BackwardService
      181209 19:18:08,906 [DEBUG][axis.providers.java.JavaProvider][ExecuteThread: '13' for queue: 'default'] JavaServiceDesc instanceorg.apache.axis.description.JavaServiceDesc@e94a8 8
      181209 19:18:08,907 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '11' for queue: 'default'] Before loadServiceDescByIntrospectionRecursive Array List operations:[] size:0
      181209 19:18:08,907 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '14' for queue: 'default'] Array List operations:[] size:0 implClass:class com.xxxxxxx.services .axis.MM7BackwardService
      181209 19:18:08,907 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '11' for queue: 'default'] loadServiceDescByIntrospectionRecursive implClass:class com.xxxxxxxx.s ervices.axis.MM7BackwardService methods:[Ljava.lang.reflect.Method;@1c62af
      181209 19:18:08,907 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '12' for queue: 'default'] Array List operations:[] size:0 implClass:class com.xxxxxxx.services .axis.MM7BackwardService
      181209 19:18:08,908 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '11' for queue: 'default'] isSkeletonClass:false,methodName:deliveryReportReq
      181209 19:18:08,908 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '14' for queue: 'default'] Before loadServiceDescByIntrospectionRecursive Array List operations:[] size:0
      181209 19:18:08,909 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '14' for queue: 'default'] loadServiceDescByIntrospectionRecursive implClass:class com.xxxxxxxx.s ervices.axis.MM7BackwardService methods:[Ljava.lang.reflect.Method;@192cf37
      181209 19:18:08,909 [DEBUG][e.axis.description.OperationDesc][ExecuteThread: '11' for queue: 'default'] @1624896setReturnType(

      {http://www.w3.org/2001/XMLSchema}

      int)
      181209 19:18:08,909 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '14' for queue: 'default'] isSkeletonClass:false,methodName:deliveryReportReq
      181209 19:18:08,908 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '12' for queue: 'default'] Before loadServiceDescByIntrospectionRecursive Array List operations:[]
      size:0
      181209 19:18:08,910 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '12' for queue: 'default'] loadServiceDescByIntrospectionRecursive implClass:class com.xxxxxxx.s ervices.axis.MM7BackwardService methods:[Ljava.lang.reflect.Method;@18bad15
      181209 19:18:08,910 [DEBUG][axis.description.JavaServiceDesc][ExecuteThread: '12' for queue: 'default'] isSkeletonClass:false,methodName:deliveryReportReq

      Fine-grain lock will gives the solution for this.

      Attachments

        1. SOAPService.java
          16 kB
          Jaganmohan Reddy

        Activity

          People

            Unassigned Unassigned
            jaganmohanreddyk Jaganmohan Reddy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: