2016-11-22 15 views
1

私はJavaでウェブサービスを作ろうとしていますが、私はOpenShiftサーバをテストするサービスを利用しています。OpenShiftにデプロイ中にエラーが発生しました

OpenShift WebサーバーとしてTomcat 7(JBoss EWS 2.0)を選択しました。

私は、サーバーへの私のファイルをプッシュするトリングだ、Mavenのビルド時に、それは私にこれらのエラーを与える:

remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project operatorrail: Compilation failure: Compilation failure: 
remote: [ERROR] /var/lib/openshift/583387240c1e66c33cXXXXX/app-root/runtime/repo/src/main/java/RestApi/Tools/tools.java:[5,16] error: cannot find symbol 
remote: [ERROR] package java.util 
remote: [ERROR] /var/lib/openshift/583387240c1e66c33cXXXXX/app-root/runtime/repo/src/main/java/RestApi/Tools/tools.java:[35,25] error: cannot find symbol 
remote: [ERROR] -> [Help 1] 
remote: [ERROR] 
remote: [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
remote: [ERROR] Re-run Maven using the -X switch to enable full debug logging. 
remote: [ERROR] 
remote: [ERROR] For more information about the errors and possible solutions, please read the following articles: 
remote: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 
remote: An error occurred executing 'gear postreceive' (exit code: 1) 
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/583387240c1e66c33cXXXXXX/jbossews 
remote: 
remote: For more details about the problem, try running the command again with the '--trace' option. 
To ssh://XXXXXX-seyedaliroshan.rhcloud.com/~/git/restoprator.git/ 
    2233024..a2c2911 master -> master 

エラーが私のtools.javaファイルについてあるように思えます。

はそうここに私のtools.javaファイルのコードです:

package RestApi.Tools; 

import java.security.MessageDigest; 
import java.security.NoSuchAlgorithmException; 
import java.util.Base64; 

/** 
* @file tools.java 
* @brief this file contains some hasher like MD5. 
* 
* @author Seyed Ali Roshan 
*/ 
public class tools { 

    public String md5(String text) throws NoSuchAlgorithmException { 
     MessageDigest md = MessageDigest.getInstance("MD5"); 
     md.update(text.getBytes()); 

     byte byteData[] = md.digest(); 


     StringBuilder hexString = new StringBuilder(); 
     for (int i=0;i<byteData.length;i++) { 
      String hex=Integer.toHexString(0xff & byteData[i]); 
      if(hex.length()==1) hexString.append('0'); 
      hexString.append(hex); 
     } 
     return hexString.toString(); 
    } 

    public String[] conventToUserPass(String text) { 
     String patternText = "(?i)Basic "; 
     String hashedString = text.replaceFirst(patternText, ""); 

     byte[] unhased = Base64.getDecoder().decode(text); 
     String finalText = new String(unhased); 

     return finalText.split(":"); 
    } 
} 

私は自分のPCでコマンドmvn compileを使用するときにエラーがないとプロジェクトが(エラーなし)完全にコンパイルので、私は疑問に思います。

にはエラーがあります - >https://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 私はそれが何を言っているのか分かりませんでした。

私はIDEとしてnetbeansを使用していますが、私のコードでは何のエラーも認識していません。

私を助けてください。

+0

* Java 8のみである* java.util.Base64 *が原因である可能性があります。 OpenShiftインスタンスがその言語レベルをサポートしているかどうかを確認してください。 – Tome

答えて

1

最初は、Tomeに感謝します。

問題はjava.util.Base64(Java 8のみ)です。

カートリッジのJDKのデフォルトバージョンを1.8.0に変更しようとしました(デフォルトではこれがあります)。

私はこのチュートリアルJDK 8 support at DIY cartridge in OpenShiftを使用しましたが、私にとっては十分ではありません。

<properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.compiler.source>1.6</maven.compiler.source> 
     <maven.compiler.target>1.6</maven.compiler.target> 
</properties> 

に:

は、私はまた、変更

<properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 
</properties> 

が、それは他のいくつかのエラーを引き起こします。

私は十分な時間を持っていなかったのでそう、私はちょうどに私のtools.javaを変更:https://stackoverflow.com/a/32748828/6442877 と私はwildflyについて検索したとき、私が使用することを決定した。最後に

package RestApi.Tools; 

import java.security.MessageDigest; 
import java.security.NoSuchAlgorithmException; 
import org.glassfish.jersey.internal.util.Base64; 


/** 
* @file tools.java 
* @brief this file contains some hasher like MD5. 
* for decoding base 64 we had to use an library because java.util.Base64 
* is for jdk 8 and our server working with jdk 7. 
* 
* @author Seyed Ali Roshan 
*/ 
public class tools { 

    public String md5(String text) throws NoSuchAlgorithmException { 
     MessageDigest md = MessageDigest.getInstance("MD5"); 
     md.update(text.getBytes()); 

     byte byteData[] = md.digest(); 


     StringBuilder hexString = new StringBuilder(); 
     for (int i=0;i<byteData.length;i++) { 
      String hex=Integer.toHexString(0xff & byteData[i]); 
      if(hex.length()==1) hexString.append('0'); 
      hexString.append(hex); 
     } 
     return hexString.toString(); 
    } 

    public String[] conventToUserPass(String text) { 
     String patternText = "(?i)Basic "; 
     String hashedString = text.replaceFirst(patternText, ""); 

     byte[] unhased = Base64.decode(hashedString.getBytes()); 
     String finalText = new String(unhased); 

     return finalText.split(":"); 
    } 
} 

私はこれを見ましたそれは特徴です。

関連する問題