Hello group,
I have created a number of jar files for our XI environment with success, but have always chosen to hard-code the parameters (env/user/pass) in the .java file rather than try to pass them in the command line, but I am growing tired of touching my code as it moves through DEV/TEST/PROD
I started playing with the apache commons cli and my test runs fine in the JDK and on my desktop, however when I try to publish the app to XI it runs to success with a java error
Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.commons.cli.Options
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:68)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:129)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1328)
at com.crystaldecisions.sdk.plugin.desktop.program.internal.ProgramWrapper.main(ProgramWrapper.java:162)
Has anyone seen this before? Is the IProgramBase interface not playing well with apache.commons.cli? That seems to be the only difference in my testing.
My sample code below (I have created another class for the CLIValidation, but added a chunk here for simplicity):
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.plugin.desktop.program.IProgramBase;
public class test implements IProgramBase{
public static void main (String[] args) {
try {
SharedCode(args);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public void run(IEnterpriseSession enterpriseSession, IInfoStore infoStore, java.lang.String[] args) {
try {
SharedCode(args);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static void SharedCode(String[] args) {
//if (CLICheck.main(args)==0){ //The command line arguments were handed to the application correctly.
try {
Options opt = new Options();
opt.addOption("h",false, "Print help for this application");
opt.addOption("s",true, "System");
opt.addOption("u",true, "Username");
opt.addOption("p", true, "Password");
opt.addOption("a", true, "Authentication Type (secEnterprise/secLDAP)");
opt.addOption("j", true, "Java Application");
BasicParser parser = new BasicParser();
CommandLine cl;
cl = parser.parse(opt, args);
System.out.println("Hello");
//}
}
catch(ParseException e) {
e.printStackTrace();
}
}
}
cpare (BOB member since 2008-10-06)