Getting add failed with exit code: 127 while executing add file for SCM Manager - apache

I am using SCM Manager for HG version control. And I am trying to add an existing sc.txt file to HG repo using Java API provided by maven-scm-provider-hg dependency.
Method to add the file to HG repo:
public void add(ScmRepository scmRepository, ScmFileSet fileSet, String message,
boolean binary) {
try {
AddScmResult rs = scmManager.add(scmRepository, fileSet, message);
System.out.println("Result : " + rs.getAddedFiles());
} catch (Exception e) {
System.out.println("Execption occured while adding new file " + e);
}
}
Method to get the ScmRepository:
public ScmRepository getScmRepository(String scmUrl) throws Exception {
ScmRepository repository;
try {
repository = getScmManager().makeScmRepository(scmUrl);
System.out.println("Repo " + repository.getProviderRepository().getUser() + " Path : "
+ repository.getProvider());
return repository;
} catch (NoSuchScmProviderException ex) {
throw new Exception("Could not find a provider.", ex);
} catch (ScmRepositoryException ex) {
throw new Exception("Error while connecting to the repository", ex);
}
}
MainApp.java
ScmRepository repo = scmClient.getScmRepository("scm:hg:/Users/john/work/hgtest/v1");
ScmFileSet fileSet = new ScmFileSet(new File("/Users/john/work/hgtest/v1"),
new File("sc.txt"));
scmClient.add(repo, fileSet, "This is first file checking", false);
This is what error I get when I execute the code:
Adding new file to hg.....
EXECUTING: /bin/sh -c cd /Users/diwakar/work/hgtest/v2 && hg add --verbose sc.txt
[ERROR]
EXECUTION FAILED
Execution of cmd : add failed with exit code: 127.
Working directory was:
/Users/diwakar/work/hgtest/v2
Your Hg installation seems to be valid and complete.
Hg version: NA (OK)
Result : []
Done.....
POM.xml:
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-hg</artifactId>
<version>1.8</version>
</dependency>

Related

how to jdbc to hive using java on ubuntu?

Ubuntu 16.04.1 LTS
hadoop 3.3.1
Hive 2.3.9
I have a java file:
public class HiveCreateDb {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException {
// Register driver and create driver instance
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
// get connection
Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
Statement stmt = con.createStatement();
stmt.executeQuery("CREATE DATABASE userdb");
System.out.println("Database userdb created successfully.");
con.close();
}
}
I put this java file on ubuntu folder,and then run
javac HiveCreateDb.java
HiveCreateDb.java:14: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
Class.forName(driverName);
^
1 error
I have downloaded hive-jdbc-3.1.2.jar,where shall I put this jar?
javac -classpath jars/hive-jdbc-2.3.9.jar source/HiveCreateDb.java

Jenkins ignores the exit code 1 from Gradle run task

Jenkins 2.89.3
Gradle 3.5
I'm running a build using a pipeline:
node {
try {
stage('Fetch code') {
echo 'Pulling the Code...'
checkout scm: [$class : 'GitSCM',
branches : [[name: '*/$GIT_CLOUD_BRANCH']],
browser : [$class: 'GitLab', repoUrl: cloudRepo, version: gitlabVersion],
doGenerateSubmoduleConfigurations: false,
submoduleCfg : [],
userRemoteConfigs : scm.userRemoteConfigs]
}
wrap([$class: 'Xvfb', screen: '1920x1080x24']) {
dir('BUILD') {
stage('Clean DB and old reports') {
sh '''chmod +x cleanup_old_reports.sh
./cleanup_old_reports.sh $PWD/../../builds $BUILD_NUMBER'''
}
stage('Build the application') {
sh '''chmod +x application.sh
./application.sh -P${PROJECT}'''
}
stage('Run tests') {
sh 'gradle clean run -P${PROJECT} -P${RUN_TYPE}'
}
}
}
stage('Generate reports') {
allure([includeProperties: false,
jdk : '',
properties : [],
reportBuildPolicy: 'ALWAYS',
results : [[path: 'ExaTAGS/TagsRunner/allure-results']]])
archive 'catalina.log'
}
} catch (Exception ex) {
currentBuild.result = "FAILURE"
println "in catch currentBuild.result: " + currentBuild.result
throw ex
} finally {
notifyBuild(currentBuild.result)
}
}
The stage 'Run tests' executes a gradle task RUN. In a case if there are any failed tests the main method of test runner throws an exception and RUN task returns exit code 1.
But despite this stage is marked as FAILED, the whole build is SUCCESSFUL:
I believe that RUN task actually does not throw an exception, cause I do not see the output I make in catch block in the pipeline script. But it really returns exit code different from 0, why does Jenkins ignore it? And what is the appropriate way to force Jenkins fail the whole build if there are any of failed stages?
UPDATE
build.gradle file:
group 'project'
version '1.0'
apply plugin: 'application'
def aspectjVersion = "1.8.7"
mainClassName = 'tags.runner.TestManager'
applicationDefaultJvmArgs = ["-javaagent:APP_HOME_PLACEHOLDER/lib/aspectjweaver-${aspectjVersion}.jar"]
dependencies {
compile "org.aspectj:aspectjweaver:${aspectjVersion}"
}
def weaver = configurations.compile.find { it.name.contains("aspectjweaver") }
run {
doFirst {
jvmArgs = jvmArgs << "-javaagent:$weaver"
if (project.hasProperty('cloud')) {
args("cloud")
}
}
}
And the main method of TestManager.
runTests() throws the TestException if the count of failed tests is more than 0:
class TestManager {
static void main(String[] args) {
try {
runTests()
} catch (TestException ex) {
throw ex
} catch (Exception e) {
e.printStackTrace()
System.in.read()
}
}
}

How can I get username and name of active local changes from git project in IntelliJ plugin

I would like to create a plugin that would use a username and name of active local changes in git project. Can I get this information from action or context?
I found a solution.
For git username:
private static String getGitUsername() {
try {
Process process = Runtime.getRuntime().exec("git config user.name");
process.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
return reader.readLine();
} catch (Exception e) {
return DEFAULT_USER;
}
}
For name of active local changes:
private static String getChangeListName(Project project) {
return ChangeListManager.getInstance(project).getDefaultListName();
}

Unable to cleanup Infinispan DefaultCacheManager in state FAILED

I am getting this Exception when trying to restart CacheManager, that failed to start.
Caused by: org.infinispan.jmx.JmxDomainConflictException: ISPN000034: There's already a JMX MBean instance type=CacheManager,name="DefaultCacheManager" already registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element
at org.infinispan.jmx.JmxUtil.buildJmxDomain(JmxUtil.java:53)
I think it's a bug, but am I correct?
The version used is 9.0.0.Final.
EDIT
The error can be seen using this code snippet.
import org.infinispan.configuration.cache.*;
import org.infinispan.configuration.global.*;
import org.infinispan.manager.*;
class Main {
public static void main(String[] args) {
System.out.println("Starting");
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
global.transport()
.clusterName("discover-service-poc")
.initialClusterSize(3);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build(), false);
try {
System.out.println("Starting cacheManger first time.");
cacheManager.start();
} catch (Exception e) {
e.printStackTrace();
cacheManager.stop();
}
try {
System.out.println("Starting cacheManger second time.");
System.out.println("startAllowed: " + cacheManager.getStatus().startAllowed());
cacheManager.start();
System.out.println("Nothing happening because in failed state");
System.out.println("startAllowed: " + cacheManager.getStatus().startAllowed());
} catch (Exception e) {
e.printStackTrace();
cacheManager.stop();
}
cacheManager = new DefaultCacheManager(global.build(), builder.build(), false);
cacheManager.start();
}
}

Passing java.security.auth.login.config to Mobilefirst Patform Server

How can we pass following parameter to Mobilefirst Development Server?
-Djava.security.auth.login.config=login.config
I have tried adding it to jvm.options file, and it seems it is passed as parameter without effect.
Following is the code I am trying to execute, and sample of login.config file.
Java code to execute in login module or adapter.
LoginContext context = new LoginContext("SampleClient", new CallbackHandler() {
#Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
NameCallback callBack = (NameCallback) callbacks[0];
callBack.setName("EXAMPLE.COM");
}
});
login.config
SampleClient {
com.sun.security.auth.module.Krb5LoginModule required
default_realm=EXAMPLE.COM;
};
Adding following code before login worked.
try {
Configuration config = Configuration.getConfiguration();
config.getAppConfigurationEntry("SampleClient");
URIParameter uriParameter = new URIParameter(new java.net.URI("file:///path_to_your_file/login.conf"));
Configuration instance = Configuration.getInstance("JavaLoginConfig", uriParameter);
Configuration.setConfiguration(instance);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}