Cannot report new bugs to Bugzilla via J2Bugzilla - java

I tried searching this topic but nothing seems to cover my exact problem. I have a java and jsp program where I would like to be able to report bugs to my Bugzilla installation. I have been testing the method I created against the Bugzilla landfill first but I cant get it to work.
My problem is that I have tried all the sample code and I still end up with the same error which seems to stem from executeMethod().
Here is the sample of my jsp page which calls the method of my java class:
<jsp:useBean id="error" class="bug.TestClass" scope="session"/>
<% String result = error.reportBug("error");
out.print(result);%>
The Java method, which I have blocked out the username and password to Bugzillla landfill but I have checked and they are correct:
public static String reportBug(String bugError) {
try {
BugzillaConnector conn = new BugzillaConnector();
conn.connectTo("http://landfill.bugzilla.org/");
BugzillaMethod logIn = new LogIn ("*****#hotmail.com", "****");
conn.executeMethod(logIn);
BugFactory factory = new BugFactory();
Bug bug = factory.newBug()
.setOperatingSystem("WINDOWS")
.setPlatform("PC")
.setPriority("P1")
.setProduct("FoodReplicator")
.setComponent("Salt")
.setSummary(bugError)
.setVersion("1.0")
.setDescription("It doesn't work.")
.createBug();
ReportBug report = new ReportBug(bug);
conn.executeMethod(report);
int id = report.getID();
result += "Successful";
} catch (Exception e) {
result = e.toString();
}
return result;
}
And here is the error I am getting when I open the jsp page:
com.j2bugzilla.base.BugzillaException: An unknown error was encountered; fault code: 0
I have been working on this for days so any help would be really appreciated. Thanks

I met the same issue. Then I update j2bugzilla jar from 2.0 to 2.2.1. Then it works.

Related

GeoFireStore getLocation returns null

I tried to use GeoFireStore to set,get and query location.
I tried first to setLocation by using:
geoFirestoreRef = FirebaseFirestore.getInstance().collection("Locations");
geoFirestore = new GeoFirestore(geoFirestoreRef);
geoFirestore.setLocation( auth.getUid(), new GeoPoint(Lat_Coordinate,Lon_Coordinate) );
It all worked good and created the following in my database:
Now, I tried to getLocation to see if it is working by using:
geoFirestore.getLocation( auth.getUid(), new GeoFirestore.LocationCallback() {
#Override
public void onComplete(GeoPoint geoPoint, Exception e) {
Log.d("ERROR", "Error getting documents: " + e);
}
} );
and for some reason, it can't get anything eventho that I can see this location in my database.
I get the exception: java.lang.NullPointerException: Location doesn't exist.
Any ideas please?
Thank you
I had this issue with the library too. When looking into the source, I saw a little mistake here.
So I made a pull request with the fix. You can either use the fork link or clone the repository and fix line 192 with :
if (geoPoint != null)

Webpage collector using google bot

I'm continuing a project that has been coming for a few years at my university. One of the activities this project does is to collect some web pages using the google bot.
Due to a problem that I cannot understand, the project is not getting through this part. Already research a lot about what may be happening, if it is some part of the code that is outdated.
The code is in Java and uses Maven for project management.
I've tried to update some information from maven's "pom".
I already tried to change the part of the code that uses the bot, but nothing works.
I'm posting the part of code that isn't working as it should:
private List<JSONObject> querySearch(int numSeeds, String query) {
List<JSONObject> result = new ArrayList<>();
start=0;
do {
String url = SEARCH_URL + query.replaceAll(" ", "+") + FILE_TYPE + "html" + START + start;);
Connection conn = Jsoup.connect(url).userAgent("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)").timeout(5000);
try {
Document doc = conn.get();
result.addAll(formatter(doc);
} catch (IOException e) {
System.err.println("Could not search for seed pages in IO.");
System.err.println(e);
} catch (ParseException e) {
System.err.println("Could not search for seed pages in Parse.");
System.err.println(e);
}
start += 10;
} while (result.size() < numSeeds);
return result;
}
what some variables do:
private static final String SEARCH_URL = "https://www.google.com/search?q=";
private static final String FILE_TYPE = "&fileType=";
private static final String START = "&start=";
private QueryBuilder queryBuilder;
public GoogleAjaxSearch() {
this.queryBuilder = new QueryBuilder();
}
Until this part is ok, it connect with the bot and can get a html from google. The problem is to separate what found and take only the link, that should be between ("h3.r> a").
That it does in this part with the result.addAll(formatter(doc)
public List<JSONObject> formatter(Document doc) throws ParseException {
List<JSONObject> entries = new ArrayList<>();
Elements results = doc.select("h3.r > a");
for (Element result : results) {
//System.out.println(result.toString());
JSONObject entry = new JSONObject();
entry.put("url", (result.attr("href").substring(6, result.attr("href").indexOf("&")).substring(1)));
entry.put("anchor", result.text());
So when it gets to this part: Elements results = doc.select ("h3.r> a"), find, probably, no h3 and can't increment the "results" list by not entering the for loop. Then goes back to the querysearch function and try again, without increment the results list. And with that, entering in a infinite loop trying to get the requested data and never finding.
If anyone here can help me, I've been trying for a while and I don't know what else to do. Thanks in advance.

Handling empty R dataframe on JSP/Rserve web page

Using a JSP web page and Rserve, I am getting data from a MySQL database and using an R dataframe to store the data. This works fine and plots perfect.
However, if the db query returns nothing the dataframe is then empty and it throws an error when trying to plot.
What I want to do is redirect to another JSP page which will then display the error but I am not sure how to do this.
I have found this R code (what it does was purely for testing purposes) which tells me if the dataframe is empty or not but how can I then include Java (or something else) to redirect the page?
if (nrow(df) != 0) {
df
} else {
df <- "Empty"
df
}
Edit: I have managed to get this far:
c.eval("if(nrow(df) != 0){ print(ggplot(df, aes(x=Date, y=UID))+geom_point(shape=1)) }"
+"else { print(\"Failed\") }");
The 'failed' doesn't print (I didn't really expect it to) but as said above in the else I would like a redirect. Any thoughts about how this would be possible?
A simply try{} catch{} solved the problem! Don't know why I didn't think of that earlier.
So instead of:
c.eval("if(nrow(df) != 0){ print(ggplot(df, aes(x=Date, y=UID))+geom_point(shape=1)) } else { print(\"Failed\") }");
I have used this:
try {
c.eval("print(ggplot(df, aes(x=Date, y=UID)) + geom_point(shape=1))"); // point graph
System.out.print("Success");
} catch (Exception e) {
out.print(e.getMessage());
System.out.print("Failed");
}

Selenium webdriver IE9 event not firing

I am using nodejs, Soda with selenium
I am hitting problems trying to get the javascript to fire events like on entry of data. Script can't even get through the creation of client flow on IE. Only worried about IE 9+ btw.
Am I missing anything ? This works fine in latest FF. Below posting sample code using for FF
var soda = require('soda');
var assert = require('assert');
var browser = soda.createClient({
url: 'http://192.168.12.1/', // localhost website
port:5555,
host:'192.168.1.3', //grid ip
browser: 'firefox',
browserTimeout:5
});
var testname = 'Nits' + parseInt(Math.random() * 100000000); //create unique name for new person.
console.log('randome name: ' + testname);
browser
.chain
.session()
.setSpeed(speed)
.setTimeout(20000)
.open('/')
.and(login('dev#dev.com', 'x1212GQtpS'))
.and(killClient(killAtEnd))
.end(function(err){
console.log('done');
if(err){
console.log(err);
}else{
console.log("We're Good");
}
if (closeAtEnd){
browser.testComplete(function() {
console.log('killing browser');
});
}
});
function login(user, pass) {
return function(browser) {
browser
.click('css=a#loginButton')
.type('css=input.input-medium.email',user)
.type('css=input.input.pwd',pass)
.clickAndWait('css=a.btn.login')
.assertTextPresent('Clients',function(){ console.log('logged in ok')})
}
}
Can you be more specific about exactly where the script stops, fails, or throws an error? I suspect that IE can't handle the way you put your css selector together (i.e. the classname combinators such as 'input.input.pwd' ). I would recommend trying a different selector or rewrite/simplify your existing selector until you get it working.

JavaScript Error in BIRT

I have been assigned to clean up a project for a client that uses BIRT reporting. I have fixed most of the issues but I still have one report that is not working and is returning an error. The error is:
Row (id = 1467):
+ There are errors evaluating script "var fileName = row["Attached_File"];
params["HyperlinkParameter"].value = ImageDecoder.decodeDocs(row["Ecrash_Attach"],fileName);":
Wrapped java.lang.NullPointerException (/report/body/table[#id="61"]/detail/row[#id="70"]/cell[#id="71"]/grid[#id="1460"]/row[#id="1462"]/cell[#id="1463"]/table[#id="1464"]/detail/row[#id="1467"]/method[#name="onCreate"]#2)
I can post the full stack trace if someone wants it but for now I will omit it since it is very long.
Here is the source of the decodeDocs method:
public static String decodeDocs(byte[] source, String fileName) {
String randName = "";
byte[] docSource = null;
if ( Base64.isArrayByteBase64(source) ){
docSource = Base64.decodeBase64(source);
}
documentZipPath = writeByteStreamToFile(source);
randName = writeByteStreamToFile(docSource, fileName);
return randName;
}
I am pretty well lost on this one. The error looks to be telling me there is an error on line two of the script which is:
var fileName = row["Attached_File"];
params["HyperlinkParameter"].value = ImageDecoder.decodeDocs(row["Ecrash_Attach"],fileName);
This is written in the OnCreate method of the report. Any help, even clues would be greatly appreciated. If you would like to see the report just ask and I will post the xml for it.
A common mistake I make in BIRT is to access the value of a null report parameter.
In your case, could params["HyperlinkParameter"] be null?

Categories