gpt4 book ai didi

java - 在 OpenShift 上部署时出错

转载 作者:行者123 更新时间:2023-11-30 07:02:09 25 4
gpt4 key购买 nike

我尝试使用 java 创建一个 REST Web 服务,并使用 OpenShift 服务来测试服务器。

在 OpenShift 中,我选择 Tomcat 7 (JBoss EWS 2.0) 作为 Web 服务器。

当我尝试将文件推送到服务器时,在 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(":");
}
}

我想知道,因为当我在我的电脑中使用命令 mvncompile 时没有错误,并且项目完全编译(没有任何错误)。

错误中有一个链接 -> https://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 我不明白它想表达的是哪一点。

顺便说一句,我使用 netbeans 作为 IDE,但它没有识别出我的代码中的任何错误。

请帮助我。

最佳答案

首先,我要感谢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更改为:

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(":");
}
}

最后我看到了这个:https://stackoverflow.com/a/32748828/6442877当我搜索 Wildfly 时,我决定在功能中使用它。

关于java - 在 OpenShift 上部署时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40741024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com