Hi Everybody,
I have written a java static method that extracts records from a database, creates objects (InvalidDespatchRecord) for them and places the objects into a Vector to return:
publicstatic Vector getRejectedLines() throws SQLException
{
Vector lines = null;
Connection connection = DBConnector.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try[SIZE=2]{
ps = connection.prepareStatement(sqlGetRejectedLines);
[/size]int[SIZE=2] i=1;
rs = ps.executeQuery();
lines = [/size]new Vector();
whileSIZE=2 {
i = 1;
InvalidDespatchRecord line = [/size]new InvalidDespatchRecord();
line.setPudo(rs.getString(i++));
line.setStockCode(rs.getString(i++));
line.setSerialNumber(rs.getString(i++));
line.setQuantity(rs.getInt(i++));
line.setId(rs.getString(i++));
line.setError(rs.getString(i++));
line.setFileRef(rs.getString(i++));
lines.add(line);
}
connection.commit();
}
catch (SQLException e) {
connection.rollback();
throw e;
}
finally{
if (ps != null[SIZE=2]) {
ps.close();
}
[/size]if (rs != null) {
rs.close();
}
}
return[SIZE=2] lines;
}
I can call this method from a Java test harness (outside of wm) and store the result like this:
Vector postErrors = new Vector();
[SIZE=2][SIZE=2]postErrors = DespatchFilesDB.getRejectedLines();
This works fine…however when I call the same method from within a Java service in wm (while enclosing with Try/Catch), I get a null pointer exception which I then throw as a Service Exception:
Vector postError = new Vector();
try{
//Get post processing rejections
postError = DespatchFilesDB.getRejectedLines();
}
catch (Exception e)
{
throw new ServiceException("Problem checking if rejection lines exist: " + e);
}
Why would the call from the test harness work fine, but the call from within webMethods fail? The data they use is exactly the same, ie, the rejected lines in the database table are the same when both are called. None of the values for the rejected lines are null.
As I cant step through the Java code from within webMethods to pinpoint the failure in the method, and because the test harness itself (where I can step through) works fine, Im at a lost as to how to proceed.
Im wary that this might be something very simple so please excuse me if it is!
Any ideas would be very much appreciated.
Thanks,
Ozz
[/size][/SIZE][/SIZE]