Package com.google.gwt.user.client.rpc

Examples of com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException


      String fieldName = clientOracle.getFieldId(x.getFieldDeclClass(),
          x.getField());

      if (fieldName == null) {
        // TODO: What does it mean if the client doesn't have a field?
        throw new IncompatibleRemoteServiceException(
            "The client does not have field " + x.getField() + " in type "
                + x.getFieldDeclClass().getName());
      }

      // i[3].foo = bar
View Full Code Here


      // beginning of the encoded string.
      while (idx < encodedTokens.length() && Character.isDigit(encodedTokens.charAt(idx))) {
        ++idx;
      }
      if (idx == 0) {
        throw new IncompatibleRemoteServiceException(
            "Malformed or old RPC message received - expecting version between "
                + SERIALIZATION_STREAM_MIN_VERSION + " and " + SERIALIZATION_STREAM_MAX_VERSION);
      } else {
        int version = Integer.valueOf(encodedTokens.substring(0, idx));
        throw new IncompatibleRemoteServiceException("Expecting version between "
            + SERIALIZATION_STREAM_MIN_VERSION + " and " + SERIALIZATION_STREAM_MAX_VERSION
            + " from client, got " + version + ".");
      }
    }

    super.prepareToRead(encodedTokens);

    // Check the RPC version number sent by the client
    if (getVersion() < SERIALIZATION_STREAM_MIN_VERSION
        || getVersion() > SERIALIZATION_STREAM_MAX_VERSION) {
      throw new IncompatibleRemoteServiceException("Expecting version between "
          + SERIALIZATION_STREAM_MIN_VERSION + " and " + SERIALIZATION_STREAM_MAX_VERSION
          + " from client, got " + getVersion() + ".");
    }

    // Check the flags
    if (!areFlagsValid()) {
      throw new IncompatibleRemoteServiceException("Got an unknown flag from " + "client: "
          + getFlags());
    }

    // Read the type name table
    deserializeStringTable();
View Full Code Here

            serviceIntf = RPC_getClassFromSerializedName(serviceIntfName,
                  classLoader);
            if (!RemoteService.class.isAssignableFrom(serviceIntf))
            {
               // The requested interface is not a RemoteService interface
               throw new IncompatibleRemoteServiceException(
                     "Blocked attempt to access interface '"
                           + printTypeName(serviceIntf)
                           + "', which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
            }
         } catch (ClassNotFoundException e)
         {
            throw new IncompatibleRemoteServiceException(
                  "Could not locate requested interface '" + serviceIntfName
                        + "' in default classloader", e);
         }

         String serviceMethodName = streamReader.readString();

         int paramCount = streamReader.readInt();
         Class<?>[] parameterTypes = new Class[paramCount];

         for (int i = 0; i < parameterTypes.length; i++)
         {
            String paramClassName = streamReader.readString();
            try
            {
               parameterTypes[i] = RPC_getClassFromSerializedName(
                     paramClassName, classLoader);
            } catch (ClassNotFoundException e)
            {
               throw new IncompatibleRemoteServiceException("Parameter " + i
                     + " of is of an unknown type '" + paramClassName + "'", e);
            }
         }

         try
         {
            Method method = serviceIntf.getMethod(serviceMethodName,
                  parameterTypes);

            Object[] parameterValues = new Object[parameterTypes.length];
            for (int i = 0; i < parameterValues.length; i++)
            {
               parameterValues[i] = streamReader
                     .deserializeValue(parameterTypes[i]);
            }

            return new SeamRPCRequest(method, parameterValues, parameterTypes,
                  serializationPolicy);

         } catch (NoSuchMethodException e)
         {
            throw new IncompatibleRemoteServiceException(
                  formatMethodNotFoundErrorMessage(serviceIntf,
                        serviceMethodName, parameterTypes));
         }
      } catch (SerializationException ex)
      {
         throw new IncompatibleRemoteServiceException(ex.getMessage(), ex);
      }
   }
View Full Code Here

      String serviceIntfName = streamReader.readString();

      if (type != null) {
        if (!implementsInterface(type, serviceIntfName)) {
          // The service does not implement the requested interface
          throw new IncompatibleRemoteServiceException(
              "Blocked attempt to access interface '" + serviceIntfName
                  + "', which is not implemented by '" + printTypeName(type)
                  + "'; this is either misconfiguration or a hack attempt");
        }
      }

      SerializationPolicy serializationPolicy = streamReader.getSerializationPolicy();
      Class serviceIntf;
      try {
        serviceIntf = getClassFromSerializedName(serviceIntfName, classLoader);
        if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
          // The requested interface is not a RemoteService interface
          throw new IncompatibleRemoteServiceException(
              "Blocked attempt to access interface '"
                  + printTypeName(serviceIntf)
                  + "', which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
        }
      } catch (ClassNotFoundException e) {
        throw new IncompatibleRemoteServiceException(
            "Could not locate requested interface '" + serviceIntfName
                + "' in default classloader", e);
      }

      String serviceMethodName = streamReader.readString();

      int paramCount = streamReader.readInt();
      Class[] parameterTypes = new Class[paramCount];

      for (int i = 0; i < parameterTypes.length; i++) {
        String paramClassName = streamReader.readString();
        try {
          parameterTypes[i] = getClassFromSerializedName(paramClassName,
              classLoader);
        } catch (ClassNotFoundException e) {
          throw new IncompatibleRemoteServiceException("Parameter " + i
              + " of is of an unknown type '" + paramClassName + "'", e);
        }
      }

      Method method = findInterfaceMethod(serviceIntf, serviceMethodName,
          parameterTypes, true);

      if (method == null) {
        throw new IncompatibleRemoteServiceException(
            formatMethodNotFoundErrorMessage(serviceIntf, serviceMethodName,
                parameterTypes));
      }

      Object[] parameterValues = new Object[parameterTypes.length];
      for (int i = 0; i < parameterValues.length; i++) {
        parameterValues[i] = streamReader.deserializeValue(parameterTypes[i]);
      }

      return new RPCRequest(method, parameterValues, serializationPolicy);

    } catch (SerializationException ex) {
      throw new IncompatibleRemoteServiceException(ex.getMessage(), ex);
    }
  }
View Full Code Here

      while (idx < encodedTokens.length()
          && Character.isDigit(encodedTokens.charAt(idx))) {
        ++idx;
      }
      if (idx == 0) {
        throw new IncompatibleRemoteServiceException(
            "Malformed or old RPC message received - expecting version between "
                + SERIALIZATION_STREAM_MIN_VERSION + " and "
                + SERIALIZATION_STREAM_VERSION);
      } else {
        int version = Integer.valueOf(encodedTokens.substring(0, idx));
        throw new IncompatibleRemoteServiceException("Expecting version between "
            + SERIALIZATION_STREAM_MIN_VERSION + " and "
            + SERIALIZATION_STREAM_VERSION + " from client, got " + version
            + ".");
      }
    }

    super.prepareToRead(encodedTokens);

    // Check the RPC version number sent by the client
    if (getVersion() < SERIALIZATION_STREAM_MIN_VERSION
        || getVersion() > SERIALIZATION_STREAM_VERSION) {
      throw new IncompatibleRemoteServiceException("Expecting version between "
          + SERIALIZATION_STREAM_MIN_VERSION + " and "
          + SERIALIZATION_STREAM_VERSION + " from client, got " + getVersion()
          + ".");
    }
View Full Code Here

    try {
      SimplePayloadDecoder decoder;
      try {
        decoder = new SimplePayloadDecoder(clientOracle, encodedRequest);
      } catch (ClassNotFoundException e) {
        throw new IncompatibleRemoteServiceException(
            "Client does not have a type sent by the server", e);
      }
      CommandServerSerializationStreamReader streamReader = new CommandServerSerializationStreamReader();
      if (decoder.getThrownValue() != null) {
        streamReader.prepareToRead(Collections.singletonList(decoder.getThrownValue()));
        try {
          throw new RemoteException((Throwable) streamReader.readObject());
        } catch (ClassCastException e) {
          throw new SerializationException(
              "The remote end threw something other than a Throwable", e);
        } catch (SerializationException e) {
          throw new IncompatibleRemoteServiceException(
              "The remote end threw an exception which could not be deserialized",
              e);
        }
      } else {
        streamReader.prepareToRead(decoder.getValues());
      }

      // Read the name of the RemoteService interface
      String serviceIntfName = streamReader.readString();

      if (type != null) {
        if (!implementsInterface(type, serviceIntfName)) {
          // The service does not implement the requested interface
          throw new IncompatibleRemoteServiceException(
              "Blocked attempt to access interface '" + serviceIntfName
                  + "', which is not implemented by '" + printTypeName(type)
                  + "'; this is either misconfiguration or a hack attempt");
        }
      }

      Class<?> serviceIntf;
      try {
        serviceIntf = getClassFromSerializedName(null, serviceIntfName,
            classLoader);
        if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
          // The requested interface is not a RpcService interface
          throw new IncompatibleRemoteServiceException(
              "Blocked attempt to access interface '"
                  + printTypeName(serviceIntf)
                  + "', which doesn't extend RpcService; "
                  + "this is either misconfiguration or a hack attempt");
        }
      } catch (ClassNotFoundException e) {
        throw new IncompatibleRemoteServiceException(
            "Could not locate requested interface '" + serviceIntfName
                + "' in default classloader", e);
      }

      String serviceMethodName = streamReader.readString();

      int paramCount = streamReader.readInt();
      Class<?>[] parameterTypes = new Class[paramCount];

      for (int i = 0; i < parameterTypes.length; i++) {
        String paramClassName = streamReader.readString();

        try {
          parameterTypes[i] = getClassFromSerializedName(clientOracle,
              paramClassName, classLoader);
        } catch (ClassNotFoundException e) {
          throw new IncompatibleRemoteServiceException("Parameter " + i
              + " of is of an unknown type '" + paramClassName + "'", e);
        }
      }

      try {
        Method method = serviceIntf.getMethod(serviceMethodName, parameterTypes);

        Object[] parameterValues = new Object[parameterTypes.length];
        for (int i = 0; i < parameterValues.length; i++) {
          Object o = CommandSerializationUtil.getAccessor(parameterTypes[i]).readNext(
              streamReader);
          parameterValues[i] = o;
        }

        return new RPCRequest(method, parameterValues, null, 0);

      } catch (NoSuchMethodException e) {
        throw new IncompatibleRemoteServiceException(
            formatMethodNotFoundErrorMessage(serviceIntf, serviceMethodName,
                parameterTypes));
      }
    } catch (SerializationException ex) {
      throw new IncompatibleRemoteServiceException(ex.getMessage(), ex);
    }
  }
View Full Code Here

          streamReader.readString());

      if (type != null) {
        if (!implementsInterface(type, serviceIntfName)) {
          // The service does not implement the requested interface
          throw new IncompatibleRemoteServiceException(
              "Blocked attempt to access interface '" + serviceIntfName
                  + "', which is not implemented by '" + printTypeName(type)
                  + "'; this is either misconfiguration or a hack attempt");
        }
      }

      SerializationPolicy serializationPolicy = streamReader.getSerializationPolicy();
      Class<?> serviceIntf;
      try {
        serviceIntf = getClassFromSerializedName(serviceIntfName, classLoader);
        if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
          // The requested interface is not a RemoteService interface
          throw new IncompatibleRemoteServiceException(
              "Blocked attempt to access interface '"
                  + printTypeName(serviceIntf)
                  + "', which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
        }
      } catch (ClassNotFoundException e) {
        throw new IncompatibleRemoteServiceException(
            "Could not locate requested interface '" + serviceIntfName
                + "' in default classloader", e);
      }

      String serviceMethodName = streamReader.readString();

      int paramCount = streamReader.readInt();
      if (paramCount > streamReader.getNumberOfTokens()) {
        throw new IncompatibleRemoteServiceException(
            "Invalid number of parameters");
      }
      Class<?>[] parameterTypes = new Class[paramCount];

      for (int i = 0; i < parameterTypes.length; i++) {
        String paramClassName = maybeDeobfuscate(streamReader,
            streamReader.readString());

        try {
          parameterTypes[i] = getClassFromSerializedName(paramClassName,
              classLoader);
        } catch (ClassNotFoundException e) {
          throw new IncompatibleRemoteServiceException("Parameter " + i
              + " of is of an unknown type '" + paramClassName + "'", e);
        }
      }

      try {
        Method method = serviceIntf.getMethod(serviceMethodName, parameterTypes);

        Object[] parameterValues = new Object[parameterTypes.length];
        for (int i = 0; i < parameterValues.length; i++) {
          parameterValues[i] = streamReader.deserializeValue(parameterTypes[i]);
        }

        return new RPCRequest(method, parameterValues, serializationPolicy,
            streamReader.getFlags());

      } catch (NoSuchMethodException e) {
        throw new IncompatibleRemoteServiceException(
            formatMethodNotFoundErrorMessage(serviceIntf, serviceMethodName,
                parameterTypes));
      }
    } catch (SerializationException ex) {
      throw new IncompatibleRemoteServiceException(ex.getMessage(), ex);
    }
  }
View Full Code Here

      throws SerializationException {
    int index;
    if (streamReader.hasFlags(AbstractSerializationStream.FLAG_ELIDE_TYPE_NAMES)) {
      SerializationPolicy serializationPolicy = streamReader.getSerializationPolicy();
      if (!(serializationPolicy instanceof TypeNameObfuscator)) {
        throw new IncompatibleRemoteServiceException(
            "RPC request was encoded with obfuscated type names, "
                + "but the SerializationPolicy in use does not implement "
                + TypeNameObfuscator.class.getName());
      }
View Full Code Here

    @Override
    public void endVisit(EnumValueCommand x, Context ctx) {
      String fieldName = clientOracle.getFieldId(x.getValue());
      if (fieldName == null) {
        throw new IncompatibleRemoteServiceException(
            "The client cannot accept " + x.getValue().name());
      }
      String clinitName = clientOracle.getMethodId(
          x.getValue().getDeclaringClass(), "$clinit");
      assert clinitName != null;
View Full Code Here

      byte[] currentBackRef = begin(x);
      byte[] constructorFunction = constructorFunction(x);
      String seedName = clientOracle.getSeedName(x.getTargetClass());

      if (seedName == null) {
        throw new IncompatibleRemoteServiceException(
            "The client cannot create type " + x.getTargetClass());
      }

      /*
       * If we need to maintain a backreference to the object, it's established
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.