public void testThrowException() {
   try {
     throw new CaptchaException();
   } catch (CaptchaException expected) {
     // expected
   } catch (UnsupportedClassVersionError error) {
     fail(error.toString());
   }
 }
  public BuilderResult buildPackage(
      String packageUUID,
      boolean force,
      String buildMode,
      String statusOperator,
      String statusDescriptionValue,
      boolean enableStatusSelector,
      String categoryOperator,
      String category,
      boolean enableCategorySelector,
      String customSelectorName)
      throws SerializationException {

    PackageItem item = rulesRepository.loadPackageByUUID(packageUUID);
    try {
      return buildPackage(
          item,
          force,
          createConfiguration(
              buildMode,
              statusOperator,
              statusDescriptionValue,
              enableStatusSelector,
              categoryOperator,
              category,
              enableCategorySelector,
              customSelectorName));
    } catch (NoClassDefFoundError e) {
      throw new DetailedSerializationException(
          "Unable to find a class that was needed when building the package  ["
              + e.getMessage()
              + "]",
          "Perhaps you are missing them from the model jars, or from the BRMS itself (lib directory).");
    } catch (UnsupportedClassVersionError e) {
      throw new DetailedSerializationException(
          "Can not build the package. One or more of the classes that are needed were compiled with an unsupported Java version.",
          "For example the pojo classes were compiled with Java 1.6 and Guvnor is running on Java 1.5. ["
              + e.getMessage()
              + "]");
    }
  }
  public static void main(String[] args) throws Exception {
    try {
      String v = System.getProperty("java.class.version");
      if (v != null) {
        try {
          if (Float.parseFloat(v) < 51.0f) throw new UnsupportedClassVersionError(v);
        } catch (NumberFormatException e) {
          // err on the safe side and keep on going
        }
      }

      ColorFormatter.install();

      _main(args);
    } catch (UnsupportedClassVersionError e) {
      System.err.println(
          "Jenkins requires Java7 or later, but you are running "
              + System.getProperty("java.runtime.version")
              + " from "
              + System.getProperty("java.home"));
      e.printStackTrace();
    }
  }
Exemple #4
0
 private Status handleUnsupportedClassVersion(UnsupportedClassVersionError ucve) {
   config
       .getError()
       .println("Error: Some library (perhaps JRuby) was built with a later JVM version.");
   config
       .getError()
       .println(
           "Please use libraries built with the version you intend to use or an earlier one.");
   if (config.isVerbose()) {
     config.getError().println("Exception trace follows:");
     ucve.printStackTrace();
   } else {
     config.getError().println("Specify -w for full UnsupportedClassVersionError stack trace");
   }
   return new Status(1);
 }
Exemple #5
0
  public int run(String[] args) {
    try {
      config.processArguments(args);
      return run();
    } catch (MainExitException mee) {
      if (!mee.isAborted()) {
        config.getOutput().println(mee.getMessage());
        if (mee.isUsageError()) {
          printUsage();
        }
      }
      return mee.getStatus();
    } catch (OutOfMemoryError oome) {
      // produce a nicer error since Rubyists aren't used to seeing this
      System.gc();

      String memoryMax = SafePropertyAccessor.getProperty("jruby.memory.max");
      String message = "";
      if (memoryMax != null) {
        message = " of " + memoryMax;
      }
      config
          .getError()
          .println("Error: Your application used more memory than the safety cap" + message + ".");
      config.getError().println("Specify -J-Xmx####m to increase it (#### = cap size in MB).");

      if (config.getVerbose()) {
        config.getError().println("Exception trace follows:");
        oome.printStackTrace();
      } else {
        config.getError().println("Specify -w for full OutOfMemoryError stack trace");
      }
      return 1;
    } catch (StackOverflowError soe) {
      // produce a nicer error since Rubyists aren't used to seeing this
      System.gc();

      String stackMax = SafePropertyAccessor.getProperty("jruby.stack.max");
      String message = "";
      if (stackMax != null) {
        message = " of " + stackMax;
      }
      config
          .getError()
          .println(
              "Error: Your application used more stack memory than the safety cap" + message + ".");
      config.getError().println("Specify -J-Xss####k to increase it (#### = cap size in KB).");

      if (config.getVerbose()) {
        config.getError().println("Exception trace follows:");
        soe.printStackTrace();
      } else {
        config.getError().println("Specify -w for full StackOverflowError stack trace");
      }
      return 1;
    } catch (UnsupportedClassVersionError ucve) {
      config
          .getError()
          .println("Error: Some library (perhaps JRuby) was built with a later JVM version.");
      config
          .getError()
          .println(
              "Please use libraries built with the version you intend to use or an earlier one.");

      if (config.getVerbose()) {
        config.getError().println("Exception trace follows:");
        ucve.printStackTrace();
      } else {
        config.getError().println("Specify -w for full UnsupportedClassVersionError stack trace");
      }
      return 1;
    } catch (ThreadKill kill) {
      return 0;
    }
  }