I am creating a custom renameParticpant to rename an Eclipse project's launch configuration files, and to change the APPNAME variable in the Makefile. The Makefile side works 100% of the time, but attempting to rename the launch configs causes the following error to occur:
<FATALERROR
FATALERROR: No input element provided
Context: <Unspecified context>
code: none
Data: null
>
This error occurs when the changes are being validated at the following line in org.eclipse.ltk.core.refactoring.PerformChangeOperation [line: 248].
fValidationStatus= fChange.isValid(new SubProgressMonitor(monitor, 1));
Below is a screenshot of the variable view. I suspect that my compositeChange is not in the correct format or is missing some information, however; the error dialogue and logs don't give any helpful information.
Debugger variable view of fChanges
The following is relevant code snippets:
// This one sparks joy (it works great, 100% success)
final HashMap<IFile, TextFileChange> textChanges = new HashMap<IFile, TextFileChange>();
// Stuff gets put inside
textChanges.put(makefile, changeAppname);
// This one does not spark joy (it runs, but results in an invalid Change)
final HashMap<IFile, RenameResourceChange> renameChanges = new HashMap<IFile, RenameResourceChange>();
// Stuff gets put inside
RenameResourceChange renameChange = new RenameResourceChange(
launch.getFile().getProjectRelativePath(), newLaunchName);
renameChanges.put(launch.getFile(), renameChange);
// This is where they get added to the hashmap.
CompositeChange result;
if (textChanges.isEmpty() && renameChanges.isEmpty()) {
result = null;
} else {
result = new CompositeChange(
String.format("Rename project references and dependencies for %1$s", proj.getName()));
for (Iterator<TextFileChange> iter = textChanges.values().iterator(); iter.hasNext();) {
result.add(iter.next());
}
for (Iterator<RenameResourceChange> iter = renameChanges.values().iterator(); iter.hasNext();) {
result.add(iter.next());
}
}
return result;
I looked into adding or generating a changeDescriptor, however that seems like the wrong approach.
Related
I am exporting a .jar file from a GUI built in Netbeans IDE. It works fine within Netbeans but once it is exported, some logic in the code does not execute properly.
I have tried debugging by running test cases displaying which items are passing through the if clauses. It seems to work well in IDE but not when it is run through .jar file.
for(Chamber chamber: chs)
{
if(!scheduledTools.containsKey(chamber))//unscheduled chambers
{
JOptionPane.showMessageDialog(this, chamber.getName()+": is unscheduled");
model.addElement(chamber.getName());
}
else//scheduled
{
if((scheduledTools.get(chamber).size()/range) > .25)
{
System.out.println("Range: " +range+" Scheduled: " +scheduledTools.get(chamber).size());
System.out.println("Cannot use this chambers:" +chamber.getName());
JOptionPane.showMessageDialog(this, chamber.getName()+": Cannot use this chamber");
}
else{
System.out.println("Scheduled but can use"+chamber.getName());
altModel.addElement(chamber.getName());
}
}
}
alternateChambers.setModel(altModel);alternateChambers.setSelectedIndex(0);
suggestedChambers.setModel(model);suggestedChambers.setSelectedIndex(0);
if(altModel.size()>1){JOptionPane.showMessageDialog(this, "Scheduled but can use these chambers:"+altModel);}
After making the necessary queries in seekDates method below:
private void seekDates(ResultSet rs) throws SQLException
{
ArrayList<String> entries;
//get how many dates we have so we can update progressbar
int results = 0;
setProgress(results);
if(rs.last()){results=rs.getRow();rs.beforeFirst();}
// processing returned data and printing into console
while(rs.next()) {
String scheduledChamber = rs.getString(2);
for(Chamber chamber : chambers){
//if the scheduled tool is a thermal chamber
//chambers get listed so far
if(!scheduledChamber.trim().toLowerCase().contains(chamber.getName().toLowerCase()))
{}//print chambers im not saving
else{
if(scheduledTools.containsKey(chamber))
{
//if key already used, just grab the list and add date
entries = scheduledTools.get(chamber);
entries.add(rs.getString(1).split(" ")[0]);
}
else
{
//if chamber hasnt been saved, add chamber and date
entries = new ArrayList<String>();
entries.add(rs.getString(1).split(" ")[0]);
scheduledTools.put(chamber, entries);
}
//System.out.println("Just saved this chamber:" +scheduledChamber+" with this date:" +scheduledTools.get(chamber));
}
;
}
publish(rs.getRow());
Thread.yield();
setProgress(100*(rs.getRow()/results));
}
}
The GUI should display the chambers found in the queries in one text field while displaying the rest of the chambers in another text field.
When I run this in the IDE. I get the correct outcome but once I compile using the package-for-store option in the build.xml file, the outcome then just lists all of the chambers in one text field.
In the .jar file, it seems that all of the chambers only satisfy the first if clause and none of the others.
Hi I am getting a strange error when I am running my JavaFX application from a JAR. When I attempt to use a drop area in my app that I added, I get a strange error. This is what I get when run from CMD (java.lang.reflect.InvocationTargetException). On the GUI the drop operation just gets stuck and doesn't complete.
I know that the code works, because when I run it from my IDE it works fine.
Any help would be great.
public void onDragDrop(DragEvent event){
files = new ArrayList<>();
Dragboard db = event.getDragboard();
boolean success = false;
if(db.hasFiles()){
//Do something with file.
List<File> temp_files = db.getFiles();
for(File f : temp_files){
if(FilenameUtils.getExtension(f.getPath()).equals("ovpn")){
files.add(f);
}
}
lbl_dragger.setText("Files Dropped: " + files.size());
success = true;
}
event.setDropCompleted(success);
event.consume();
}
UPDATE: Upon further testing, it seems that the error is actually coming from the line below:
if(FilenameUtils.getExtension(f.getPath()).equals("ovpn")){
files.add(f);
}
There seems to be some kind of error with the library I was using (ApacheCommons). As a workaround (unless this question gets an answer) using a simple (but less accurate) method will be suitable. See below if you too are stuck on this:
if(f.getAbsolutePath().contains(".ovpn")){
files.add(f);
}
So when an error occurred during runtime, the log always show a link to the specific error and you can click on it to be taken there directly.
I'm looking to exploit this function for my own use (since finding where the log is generated across multiple files can be a pain). Of course you can just put the source in the log key but if I'm able to link it just the way Android Studio / Intellij IDEAS does it with the error output, that would be MASSIVELY helpful. Thanks.
The following code will be a work-around to print the logged function name and line number (in Java):
private static String _FUNC_() {
int STACK_LEVEL = 2;
StackTraceElement traceElement = ((new Exception()).getStackTrace())[STACK_LEVEL];
StringBuilder sb = new StringBuilder();
sb.append("<");
String className = traceElement.getClassName();
className = className.substring(className.lastIndexOf(".") + 1);
sb.append(className);
sb.append(":");
sb.append(traceElement.getMethodName());
sb.append(":");
sb.append(traceElement.getLineNumber());
sb.append("> ");
return sb.toString();
}
I have a simple block of code, that return false
PromoDebit promoDebit = new PromoDebit();
promoDebit.promoCode=promoCode;
promoDebit.userId=userId;
promoDebit.countUsages=countUsages;
promoDebit.endDate=endDate;
promoDebit.startDate=startDate;
promoDebit.status=1;
promoDebit.calcValue=Float.parseFloat(p.getProperty("promoPercent"));
if(promoDebit.save(flush: true)){
log.info "GOOD!"
} else {
log.info "BAD!"
}
How can I get more info about GORM.save fail? Stdrout log show nothning even if I turn on logSql in DataSource.groovy
First ,make sure that your Log4j is configured correctly.
Here http://grails.org/doc/2.3.1/guide/conf.html#logging
And ,If you wan to know more detail info on GORM.save fail like
PromoDebit promoDebit = new PromoDebit();
promoDebit.promoCode=promoCode;
promoDebit.userId=userId;
promoDebit.countUsages=countUsages;
promoDebit.endDate=endDate;
promoDebit.startDate=startDate;
promoDebit.status=1;
promoDebit.calcValue=Float.parseFloat(p.getProperty("promoPercent"));
Then ,
if (!promoDebit.save()) {
log.warn myDomainObj.errors.allErrors.join(' \n')
//each error is an instance of org.springframework.validation.FieldError
}
And , I like this one
if (!promoDebit.save()) {
promoDebit.errors.each {
println it
}
}
If you want to throw an exception for EVERY domain classes, then simply set grails.gorm.failOnError to true in grails-app/conf/Config.groovy
or Simply
promoDebit.save(failOnError:true)
Cheers!
log.warn "error occurred by saving: $promoDebit.errors"
you will see the validation failures in the log. If some SQL-constraint gets broken you will get a full-blown Exception like DataIntegrityException
Busy trying to Call RPG function from Java and got this example from JamesA. But now I am having trouble, here is my code:
AS400 system = new AS400("MachineName");
ProgramCall program = new ProgramCall(system);
try
{
// Initialise the name of the program to run.
String programName = "/QSYS.LIB/LIBNAME.LIB/FUNNAME.PGM";
// Set up the 3 parameters.
ProgramParameter[] parameterList = new ProgramParameter[2];
// First parameter is to input a name.
AS400Text OperationsItemId = new AS400Text(20);
parameterList[0] = new ProgramParameter(OperationsItemId.toBytes("TestID"));
AS400Text CaseMarkingValue = new AS400Text(20);
parameterList[1] = new ProgramParameter(CaseMarkingValue.toBytes("TestData"));
// Set the program name and parameter list.
program.setProgram(programName, parameterList);
// Run the program.
if (program.run() != true)
{
// Report failure.
System.out.println("Program failed!");
// Show the messages.
AS400Message[] messagelist = program.getMessageList();
for (int i = 0; i < messagelist.length; ++i)
{
// Show each message.
System.out.println(messagelist[i]);
}
}
// Else no error, get output data.
else
{
AS400Text text = new AS400Text(50);
System.out.println(text.toObject(parameterList[1].getOutputData()));
System.out.println(text.toObject(parameterList[2].getOutputData()));
}
}
catch (Exception e)
{
//System.out.println("Program " + program.getProgram() + " issued an exception!");
e.printStackTrace();
}
// Done with the system.
system.disconnectAllServices();
The application Hangs at this lineif (program.run() != true), and I wait for about 10 minutes and then I terminate the application.
Any idea what I am doing wrong?
Edit
Here is the message on the job log:
Client request - run program QSYS/QWCRTVCA.
Client request - run program LIBNAME/FUNNAME.
File P6CASEL2 in library *LIBL not found or inline data file missing.
Error message CPF4101 appeared during OPEN.
Cannot resolve to object YOBPSSR. Type and Subtype X'0201' Authority
FUNNAME insert a row into table P6CASEPF through a view called P6CASEL2. P6CASEL2 is in a different library lets say LIBNAME2. Is there away to maybe set the JobDescription?
Are you sure FUNNAME.PGM is terminating and not hung with a MSGW? Check QSYSOPR for any messages.
Class ProgramCall:
NOTE: When the program runs within the host server job, the library list will be the initial library list specified in the job description in the user profile.
So I saw that my problem is that my library list is not setup, and for some reason, the user we are using, does not have a Job Description. So to over come this I added the following code before calling the program.run()
CommandCall command = new CommandCall(system);
command.run("ADDLIBLE LIB(LIBNAME)");
command.run("ADDLIBLE LIB(LIBNAME2)");
This simply add this LIBNAME, and LIBNAME2 to the user's library list.
Oh yes, the problem is Library list not set ... take a look at this discussion on Midrange.com, there are different work-around ...
http://archive.midrange.com/java400-l/200909/msg00032.html
...
Depe