2 Replies Latest reply on Nov 27, 2002 12:10 PM by Ron Jawanda

    java.lang.NoSuchMethodError: org.apache.axis.client.Call.set

    Ron Jawanda Novice

      I installed jboss 3.0.4 out of the box installation
      I modified the run.bat to add these options

      -c all -Daxis.enableListQuery=true

      Then I deploy my services.
      They deploy fine.

      I can call them from DOS clients

      I then try to call the service from a servlet

      I get this

      08:46:41,496 WARN [jbossweb] WARNING: Error for /dpkg/jbaan/WebServiceTest?eite
      m=ABCDEFGHIJKLMNOP&revision=0
      java.lang.NoSuchMethodError: org.apache.axis.client.Call.setOperationName(Ljavax
      /xml/namespace/QName;)V
      at ca.husky.jbaan.WebServiceTest.service(Unknown Source)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:366
      )
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicati
      onHandler.java:293)



      Servlet is this



      Anybody know why??
      PS: My service is registered ok and works from the dos command line in my client java code.

      Thanks
      Ron





      package ca.husky.jbaan;

      import java.io.* ;
      import javax.servlet.*;
      import javax.servlet.http.*;
      import java.util.Properties ;
      import javax.naming.Context ;
      import javax.rmi.PortableRemoteObject;
      import java.rmi.server.ObjID ;

      import java.util.* ;

      /* import java.rmi.* ; */

      import com.oreilly.servlet.multipart.* ;


      import ca.husky.HuskyUtils.PropertyLoader ;

      import java.util.Properties ;

      import java.net.URL ;

      // file download
      import org.apache.axis.client.Service;

      import org.apache.axis.client.Call;
      import org.apache.axis.encoding.XMLType;

      import javax.xml.rpc.ParameterMode;
      import javax.xml.namespace.QName;
      import org.apache.axis.encoding.ser.BeanSerializerFactory;
      import org.apache.axis.encoding.ser.BeanDeserializerFactory;
      import java.lang.reflect.InvocationTargetException ;
      import ca.husky.sparepart.SparePartBean ;
      import javax.xml.rpc.ServiceFactory;
      import org.apache.axis.utils.Options;




      public class WebServiceTest extends HttpServlet {



      /** Destroys the servlet when the VM stops. ie: Jboss
      don't use this.

      */
      public void destroy() {


      }


      protected void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException
      {


      HttpSession session = req.getSession() ;
      session.setMaxInactiveInterval(2*60*60) ;

      ObjID oid = new ObjID() ;

      res.setBufferSize(8*1024) ;

      res.setContentType("text/html");
      java.io.PrintWriter out = res.getWriter();



      String formEitem = req.getParameter("eitem") ;
      String formRevision = req.getParameter("revision") ;

      int len = 16 - formEitem.length() ;

      StringBuffer temp = new StringBuffer() ;
      for(int i=0;i<len;i++) {
      temp.append(" ") ;
      }
      temp.append(formEitem) ;
      String eitem = temp.toString() ;

      len = 6 - formRevision.length() ;

      temp.setLength(0) ;
      for(int i=0;i<len;i++) {
      temp.append(" ") ;
      }
      temp.append(formRevision) ;
      String revision = temp.toString() ;




      try {
      // EndPoint URL for the SparePartPrice Web Service
      String endpointURL = "http://bmdrjawanda:8080/axis/services/SparePartDetails";

      // Method Name to invoke for the SparePartDetails Web Service

      // Create the Call object and set properties like endPointURL, method
      // name etc.
      org.apache.axis.client.Service service = new org.apache.axis.client.Service();


      org.apache.axis.client.Call call = (org.apache.axis.client.Call) service.createCall();

      call.setTargetEndpointAddress(new java.net.URL(endpointURL));
      // call.setOperation(new javax.xml.namespace.QName("SparePartDetails","getSparePart") , "getSparePart") ;



      call.setOperationName(new QName("SparePartDetails","getSparePart")) ;
      //call.setTransport(new Transport().setTransportName("Java:RPC") ) ;

      call.addParameter("eitem", XMLType.XSD_STRING,
      ParameterMode.IN);
      call.addParameter("revision", XMLType.XSD_STRING,
      ParameterMode.IN);

      QName qname = new QName("SparePartDetails", "SparePartBean");

      Class cls = SparePartBean.class;

      // register the SparePartBean class

      call.registerTypeMapping(cls, qname,
      BeanSerializerFactory.class,
      BeanDeserializerFactory.class);
      call.setReturnType(qname);
      out.println("eitem[" + eitem + "]") ;
      out.println("revision[" + revision+ "]") ;


      // Setup the Parameters i.e. the Part SKU to be passed as
      // input parameter to the SparePartDetails Web Service





      Object[] params = new Object[] { eitem,revision };

      // Invoke the SparePartPrice Web Service
      SparePartBean spBean = (SparePartBean) call.invoke(params);

      // Print out the result
      out.println("Input Baan Item: [" + spBean.getItem()+ "]");
      out.println("It's baan description is: [" + spBean.getDescription() + "]");
      out.println("The status is [" + spBean.getStatus() + "]");
      out.println("The Effective Date [" + spBean.getEffectiveDateString() + "]");
      out.println("The Expiry Date [" + spBean.getExpiryDateString() + "]");
      out.println("The Owner [" + spBean.getOwner() + "]");


      } catch (Exception e) {
      out.println("error " + e.getMessage());
      }



      }


      /** Processes requests for both HTTP GET and POST methods.
      * @param request servlet request
      * @param response servlet response
      */

      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {

      response.setContentType("text/html");
      //java.io.PrintWriter out = response.getWriter();
      // out.println("process Request Remote user is " + request.getRemoteUser() ) ;



      }

      /** Handles the HTTP GET method.
      * @param request servlet request
      * @param response servlet response
      */
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
      processRequest(request, response);



      }

      /** Handles the HTTP POST method.
      * @param request servlet request
      * @param response servlet response
      */
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
      processRequest(request, response);
      }

      /** Returns a short description of the servlet.
      */
      public String getServletInfo() {
      return "Used for creating a drawing package for technical publications";
      }





      }










        • 1. Re: java.lang.NoSuchMethodError: org.apache.axis.client.Call
          Ron Jawanda Novice

          This is a DOS JAVA client that works on the command line.
          I can't figure out why the servlet can't determine the method.
          I opened the axis.jar file (for the jboss installation) and looked at the method. it is there and in the beta2 documentation as well.
          This must be a bug.
          Ron




          import javax.xml.rpc.ParameterMode;
          import javax.xml.namespace.QName;
          import org.apache.axis.encoding.ser.BeanSerializerFactory;
          import org.apache.axis.encoding.ser.BeanDeserializerFactory;
          import java.lang.reflect.InvocationTargetException ;


          public class SparePartServiceClient1 {

          public SparePartServiceClient1() {}

          public static void main(String args[]) {
          try {
          // Get the SKU number from the command prompt. If the SKU number is not
          // supplied display the usage.
          if (args.length == 0) {
          System.out.println(" Usage: java SparePartServiceClient"
          + " <baan-e-item-number ABCDEFGHIJKLMNOP> <0revision>");
          System.exit(1);
          }

          // EndPoint URL for the SparePartPrice Web Service
          String endpointURL = "http://bmdrjawanda:8080/axis/services/SparePartDetails";

          // Method Name to invoke for the SparePartDetails Web Service
          String methodName = "getSparePart";

          // Create the Call object and set properties like endPointURL, method
          // name etc.
          Service service = new Service();
          Call call = (Call) service.createCall();
          call.setTargetEndpointAddress(new java.net.URL(endpointURL));
          call.setOperationName(new QName("SparePartDetails",methodName));
          call.addParameter("eitem", XMLType.XSD_STRING,
          ParameterMode.IN);
          call.addParameter("revision", XMLType.XSD_STRING,
          ParameterMode.IN);
          QName qname = new QName("SparePartDetails", "SparePartBean");
          Class cls = SparePartBean.class;

          // register the SparePartBean class

          call.registerTypeMapping(cls, qname,
          BeanSerializerFactory.class,
          BeanDeserializerFactory.class);
          call.setReturnType(qname);

          // Setup the Parameters i.e. the Part SKU to be passed as
          // input parameter to the SparePartDetails Web Service
          Object[] params = new Object[] { args[0],args[1] };

          // Invoke the SparePartPrice Web Service
          SparePartBean spBean = (SparePartBean) call.invoke(params);

          // Print out the result
          System.out.println("Input Baan Item: [" + spBean.getItem()+ "]");
          System.out.println("It's baan description is: [" + spBean.getDescription() + "]");
          System.out.println("The status is [" + spBean.getStatus() + "]");
          System.out.println("The Effective Date [" + spBean.getEffectiveDateString() + "]");
          System.out.println("The Expiry Date [" + spBean.getExpiryDateString() + "]");
          System.out.println("The Owner [" + spBean.getOwner() + "]");

          } catch (Exception e) {
          e.printStackTrace() ;

          System.err.println("error " + e.getMessage());
          }
          }
          }

          • 2. Re: java.lang.NoSuchMethodError: org.apache.axis.client.Call
            Ron Jawanda Novice

            Message based services work fine out of a servlet
            They of course dont call setOperationName()

            RPC based services fail.

            Ron



            try {
            String endpointURL = "http://bmdrjawanda:8080/axis/services/SparePartPrice" ;

            Service service = new Service() ;
            Call call = (Call) service.createCall() ;
            call.setTargetEndpointAddress(new URL(endpointURL) ) ;
            SOAPBodyElement [] reqSOAPBodyElements = new SOAPBodyElement[1] ;
            File catalogFile = new File("c:\\catalog.xml") ;
            FileInputStream fis = new FileInputStream(catalogFile) ;

            reqSOAPBodyElements[0] = new SOAPBodyElement(XMLUtils.newDocument(fis).getDocumentElement()) ;

            Vector resSOAPBodyElements = (Vector) call.invoke(reqSOAPBodyElements) ;
            SOAPBodyElement resSOAPBodyElement = null ;
            resSOAPBodyElement = (SOAPBodyElement) resSOAPBodyElements.get(0) ;
            out.println("" + XMLUtils.ElementToString(resSOAPBodyElement.getAsDOM())+ "") ;
            }catch( Exception e) {
            out.println("Exception caught " + e.getMessage() ) ;
            }