分享

Spark源码编译遇到的问题解决

本帖最后由 pig2 于 2014-7-22 10:06 编辑
问题导读
1、内存不足,怎么解决?
2、Maven无法下载mqtt-client-0.4.0.pom,怎么办?
3、编译Spark的时候需要用到什么?



1、内存不够
  1. [ERROR] PermGen space -> [Help 1]
  2. [ERROR]
  3. [ERROR] To see the full stack trace of the errors,re-run Maven with the -e switch.
  4. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  5. [ERROR]
  6. [ERROR] For more information about the errors and possible solutions,
  7. please read the following articles:
  8. [ERROR] [Help 1]http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError
复制代码


上面这个错误是因为编译的时候内存不够导致的,可以在编译的时候加大内存。
  1. export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"
复制代码


2、缺少scala依赖
  1. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:
  2. run (default) on project spark-core_2.10: An Ant BuildException has occured:
  3. Please set the SCALA_HOME (or SCALA_LIBRARY_PATH if scala is on the path)
  4. environment variables and retry.
  5. [ERROR] around Ant part ...<fail message="Please set the SCALA_HOME
  6. (or SCALA_LIBRARY_PATH if scala is on the path) environment variables and retry.">
  7. @ 6:126 in /export1/spark/spark-0.9.0-incubating/core/target/antrun/build-main.xml
复制代码

上面这个错误已经写的很清楚了,因为编译Spark的时候需要用到scala,所以得去下载scala,此处编译我用的是2.10.3版本,安装如下:
  1. [wyp@master spark]$ wget http://www.scala-lang.org/files/archive/scala-2.10.3.tgz
  2. [wyp@master spark]$ tar -zxf scala-2.10.3.tgz
  3. [wyp@master spark]$ export SCALA_HOME=/export1/spark/scala-2.10.3
复制代码


3、mqtt-client-0.4.0无法下载
  1. [error] Server access Error: sun.security.validator.ValidatorException:
  2. PKIX path building failed:
  3. sun.security.provider.certpath.SunCertPathBuilderException:
  4. unable to find valid certification path to requested target
  5. url=https://repo.eclipse.org/content/repositories/paho-releases/
  6.         org/eclipse/paho/mqtt-client/0.4.0/mqtt-client-0.4.0.pom
  7. [warn]  module not found: org.eclipse.paho#mqtt-client;0.4.0
复制代码

这个错误是Maven无法下载mqtt-client-0.4.0.pom,因为他用到的是HTTPS协议。解决这个错误可以通过添加对repo.eclipse.org的信任从而解决这个问题。那如何解决呢?下载InstallCert.java类:
  1. /**
  2. * http://blogs.sun.com/andreas/resource/InstallCert.java
  3. * Use:
  4. * java InstallCert hostname
  5. * Example:
  6. *% java InstallCert ecc.fedora.redhat.com
  7. */
  8. import javax.net.ssl.*;
  9. import java.io.*;
  10. import java.security.KeyStore;
  11. import java.security.MessageDigest;
  12. import java.security.cert.CertificateException;
  13. import java.security.cert.X509Certificate;
  14. /**
  15. * Class used to add the server's certificate to the KeyStore
  16. * with your trusted certificates.
  17. */
  18. public class InstallCert {
  19.     public static void main(String[] args) throws Exception {
  20.         String host;
  21.         int port;
  22.         char[] passphrase;
  23.         if ((args.length == 1) || (args.length == 2)) {
  24.             String[] c = args[0].split(":");
  25.             host = c[0];
  26.             port = (c.length == 1) ? 443 : Integer.parseInt(c[1]);
  27.             String p = (args.length == 1) ? "changeit" : args[1];
  28.             passphrase = p.toCharArray();
  29.         } else {
  30.             System.out.println("Usage: java InstallCert <host>[:port"+
  31.                                "[passphrase]");
  32.             return;
  33.         }
  34.         File file = new File("jssecacerts");
  35.         if (file.isFile() == false) {
  36.             char SEP = File.separatorChar;
  37.             File dir = new File(System.getProperty("java.home") + SEP
  38.                     + "lib" + SEP + "security");
  39.             file = new File(dir, "jssecacerts");
  40.             if (file.isFile() == false) {
  41.                 file = new File(dir, "cacerts");
  42.             }
  43.         }
  44.         System.out.println("Loading KeyStore " + file + "...");
  45.         InputStream in = new FileInputStream(file);
  46.         KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
  47.         ks.load(in, passphrase);
  48.         in.close();
  49.         SSLContext context = SSLContext.getInstance("TLS");
  50.         TrustManagerFactory tmf =
  51.                 TrustManagerFactory.getInstance(
  52.                                 TrustManagerFactory.getDefaultAlgorithm());
  53.         tmf.init(ks);
  54.         X509TrustManager defaultTrustManager =
  55.                               (X509TrustManager) tmf.getTrustManagers()[0];
  56.         SavingTrustManager tm = new SavingTrustManager(defaultTrustManager);
  57.         context.init(null, new TrustManager[]{tm}, null);
  58.         SSLSocketFactory factory = context.getSocketFactory();
  59.         System.out.println("Opening connection to " + host + ":" + port + "...");
  60.         SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
  61.         socket.setSoTimeout(10000);
  62.         try {
  63.             System.out.println("Starting SSL handshake...");
  64.             socket.startHandshake();
  65.             socket.close();
  66.             System.out.println();
  67.             System.out.println("No errors, certificate is already trusted");
  68.         } catch (SSLException e) {
  69.             System.out.println();
  70.             e.printStackTrace(System.out);
  71.         }
  72.         X509Certificate[] chain = tm.chain;
  73.         if (chain == null) {
  74.             System.out.println("Could not obtain server certificate chain");
  75.             return;
  76.         }
  77.         BufferedReader reader =
  78.                 new BufferedReader(new InputStreamReader(System.in));
  79.         System.out.println();
  80.         System.out.println("Server sent " + chain.length + " certificate(s):");
  81.         System.out.println();
  82.         MessageDigest sha1 = MessageDigest.getInstance("SHA1");
  83.         MessageDigest md5 = MessageDigest.getInstance("MD5");
  84.         for (int i = 0; i < chain.length; i++) {
  85.             X509Certificate cert = chain[i];
  86.             System.out.println
  87.                     (" " + (i + 1) + " Subject " + cert.getSubjectDN());
  88.             System.out.println("   Issuer  " + cert.getIssuerDN());
  89.             sha1.update(cert.getEncoded());
  90.             System.out.println("   sha1    " + toHexString(sha1.digest()));
  91.             md5.update(cert.getEncoded());
  92.             System.out.println("   md5     " + toHexString(md5.digest()));
  93.             System.out.println();
  94.         }
  95.         System.out.println("Enter certificate to add to trusted keystore or"+
  96.                            " 'q' to quit: [1]");
  97.         String line = reader.readLine().trim();
  98.         int k;
  99.         try {
  100.             k = (line.length() == 0) ? 0 : Integer.parseInt(line) - 1;
  101.         } catch (NumberFormatException e) {
  102.             System.out.println("KeyStore not changed");
  103.             return;
  104.         }
  105.         X509Certificate cert = chain[k];
  106.         String alias = host + "-" + (k + 1);
  107.         ks.setCertificateEntry(alias, cert);
  108.         OutputStream out = new FileOutputStream("jssecacerts");
  109.         ks.store(out, passphrase);
  110.         out.close();
  111.         System.out.println();
  112.         System.out.println(cert);
  113.         System.out.println();
  114.         System.out.println
  115.                 ("Added certificate to keystore 'jssecacerts' using alias '"
  116.                         + alias + "'");
  117.     }
  118.     private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray();
  119.     private static String toHexString(byte[] bytes) {
  120.         StringBuilder sb = new StringBuilder(bytes.length * 3);
  121.         for (int b : bytes) {
  122.             b &= 0xff;
  123.             sb.append(HEXDIGITS[b >> 4]);
  124.             sb.append(HEXDIGITS[b & 15]);
  125.             sb.append(' ');
  126.         }
  127.         return sb.toString();
  128.     }
  129.     private static class SavingTrustManager implements X509TrustManager {
  130.         private final X509TrustManager tm;
  131.         private X509Certificate[] chain;
  132.         SavingTrustManager(X509TrustManager tm) {
  133.             this.tm = tm;
  134.         }
  135.         public X509Certificate[] getAcceptedIssuers() {
  136.          
  137.         throw new UnsupportedOperationException();
  138.         }
  139.         public void checkClientTrusted(X509Certificate[] chain, String authType)
  140.                 throws CertificateException {
  141.             throw new UnsupportedOperationException();
  142.         }
  143.         public void checkServerTrusted(X509Certificate[] chain, String authType)
  144.                 throws CertificateException {
  145.             this.chain = chain;
  146.             tm.checkServerTrusted(chain, authType);
  147.         }
  148.     }
  149. }
复制代码

编译上面的类:
  1. $ javac InstallCert.java
  2. $ java InstallCert repo.eclipse.org
复制代码


这样会在当前目录下面生成名为jssecacerts的文件,将这个文件拷贝到你java安装目录的$JAVA_HOME/lib/security/下面,然后上述问题即可解决。



参考:http://www.tuicool.com/articles/NBVvai

没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条