java.lang.NullPointerException in RowSetFixture.findMatchingRow

322 views
Skip to first unread message

Jessie Lin

unread,
Mar 5, 2017, 8:52:24 PM3/5/17
to dbfit
Hello everyone,

I just started trying Dbfit and now testing a Query look like below and received NullPointException.

!|Query| select cola, colb from tableA where cola = '100'|
|cola     |colb? |
|100     |value |
|100     |value |

cola is not a unique key, and we expect to see several records per value.
I also tried to put ? in cola, but either way got the same error.
Are column names here case sensitive? I did try to switch cases, but still got the same error.

the stacktrace is here
java.lang.NullPointerException at dbfit.fixture.RowSetFixture.findMatchingRow(RowSetFixture.java:120) at dbfit.fixture.RowSetFixture.doRow(RowSetFixture.java:107) at fit.Fixture.doRows(Fixture.java:162) at fit.ColumnFixture.doRows(ColumnFixture.java:19) at dbfit.fixture.RowSetFixture.doRows(RowSetFixture.java:93) at fit.Fixture.doTable(Fixture.java:156) at fitlibrary.traverse.AlienTraverseHandler.doTable(AlienTraverseHandler.java:21) at fitlibrary.traverse.workflow.DoTraverseInterpreter.interpretWholeTable(DoTraverseInterpreter.java:104) at fitlibrary.traverse.workflow.DoTraverseInterpreter.interpretWholeTable(DoTraverseInterpreter.java:89) at fitlibrary.DoFixture.interpretWholeTable(DoFixture.java:73) at fitlibrary.suite.InFlowPageRunner.run(InFlowPageRunner.java:27) at fitlibrary.DoFixture.interpretTables(DoFixture.java:42) at dbfit.DatabaseTest.interpretTables(DatabaseTest.java:26) at fit.Fixture.doTables(Fixture.java:81) at fit.FitServer.process(FitServer.java:81) at fit.FitServer.run(FitServer.java:56) at fit.FitServer.main(FitServer.java:41)

What did I do wrong?
Thank you all very much for your help!


public DataRow findMatchingRow(Parse row) throws NoMatchingRowFoundException {
Parse columns = row.parts;
Map<String, Object> keyMap = new HashMap<String, Object>();
for (int i = 0; i < keyColumns.length; i++, columns = columns.more) {
if (keyColumns[i] != null) {
try {
Object value = columnBindings[i].adapter.parse(columns.text());
keyMap.put(keyColumns[i], value);
} catch (Exception e) {
exception(columns, e);
}
}
}

return dt.findMatching(keyMap);
}

Jessie Lin

unread,
Mar 5, 2017, 9:36:26 PM3/5/17
to dbfit
Btw, on the test page, an exception shows "Could not find field: cola".
Initially I thought the keyColumns were null, but found in bindColumnHeadersToMethodsAndFields the private String[] is initialized by heads.size().

I was able to run an insert fixture test, so the environment setting is probably ok.
I did create a custom DBEnvironment on a thirdparty database. The stack trace doesn't show anything customized, so hopefully it wasn't because of  the customization :D
Thank you so much for your help!

Jessie Lin

unread,
Mar 6, 2017, 12:30:45 AM3/6/17
to dbfit
Problem solved. 
I used the original core jar and now the Query fixture is working.

Mark Matten

unread,
Mar 6, 2017, 3:57:07 AM3/6/17
to db...@googlegroups.com
Can you please include the full test page code, especially the entries preceding the Query fixture?

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "dbfit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dbfit+un...@googlegroups.com.
To post to this group, send email to db...@googlegroups.com.
Visit this group at https://groups.google.com/group/dbfit.
For more options, visit https://groups.google.com/d/optout.

Jessie Lin

unread,
Mar 6, 2017, 12:26:58 PM3/6/17
to dbfit
Hi Martin, thank you very much for your reply!

I have a SetUp page which looks like this.
dbfit.CustomtDBTest
Connectjdbc:CustomDB://server.co.com:portnumber/databasename

And in the test page, it's has this a Query fixture.
It seems quite straightforward configuration, did I miss something?

Jessie

Mark Matten

unread,
Mar 6, 2017, 2:30:40 PM3/6/17
to dbfit
Do you still have the problem? It sounded like you'd solved it.

Jessie Lin

unread,
Mar 6, 2017, 7:47:05 PM3/6/17
to dbfit
Hi Mark, thank you for checking in.

I thought I fixed it but now I think there is an issue introduced by the custom db fixture.
If I use the original dbfit core jar, the query fixture run ok, but in insert fixture I have the error below.

java.lang.NoSuchMethodError: dbfit.environment.CustomEnvironment.createDbParameterAccessor(Ljava/lang/String;Ldbfit/util/Direction;ILjava/lang/Class;I)Ldbfit/util/DbParameterAccessor; at dbfit.environment.CustomEnvironment.getStagingTableColumns(IgniteEnvironment.java:129) at dbfit.environment.CustomEnvironment.getAllColumns(IgniteEnvironment.java:89) at dbfit.api.DbTable.(DbTable.java:24) at dbfit.fixture.Insert.getTargetDbObject(Insert.java:32) at dbfit.fixture.DbObjectExecutionFixture.doRows(DbObjectExecutionFixture.java:61) at fit.Fixture.doTable(Fixture.java:156) at fit.Fixture.interpretFollowingTables(Fixture.java:121) at fit.Fixture.interpretTables(Fixture.java:107) at fit.Fixture.doTables(Fixture.java:81) at fit.FitServer.process(FitServer.java:81) at fit.FitServer.run(FitServer.java:56) at fit.FitServer.main(FitServer.java:41)
After building both projects, and putting the new dbfit core jar as well as the custom environment jar in,
The Insert Fixture works but the Query fixture gives the NullPointException.

Btw, not sure if it's related to the issue.Although I'm connection to the same the Custom db server, the insert fixture uses on database, and query uses another.
I've been using flow mode, and put two connections there.
I've also tried standalone mode. Use DB Environment, connect, insert and close. Then put DB Environment, connect, query and close
Still the same issue.

Also, I use a windows laptop and got a lot of CRLF errors when build, so I temporarily turn the style check off.

Sounds like an interesting and puzzling issue...

Jessie Lin

unread,
Mar 6, 2017, 7:51:19 PM3/6/17
to dbfit
The test page looks like this

|Import|
|dbfit.fixture|

|Database Environment|custom|
|Connect|jdbc:custom://<host>:<port>/<db1name>|

!|Insert|table1|
|col1|col2|
|val1|val2|

!|Database Environment|
|close|

|Database Environment|custom|
|Connect|jdbc:custom://<host>:<port>/<db2name>|

!|Query|select col1, col2 from table2 where col1 = 10|
|col1|col2|
|val1|val2|

!|Database Environment|
|close|

Martin Landvoigt

unread,
Mar 7, 2017, 11:48:31 AM3/7/17
to dbfit
Am Dienstag, 7. März 2017 01:51:19 UTC+1 schrieb Jessie Lin:

!|Query|select col1, col2 from table2 where col1 = 10|
|col1|col2|
|val1|val2|


This does not work as col1 and col2 are output params.

They must be marked with ?:

!|Query|select col1, col2 from table2 where col1 = 10|
|col1?|col2?|
|val1|val2|

 

Jessie Lin

unread,
Mar 7, 2017, 1:06:55 PM3/7/17
to dbfit
Hi Martin, thank you for helping!
I tried to put ? on column header, still the same NullPointException, but the message becomes : Could not find method:
Before it says Could not find field:


!|Query|select col1, col2 from table2 where col1 = 10|
|col1?|col2?|
|val1|val2|

If I search the error message in the code, would that be a way to find out more?

Best,
Jessie

Mark Matten

unread,
Mar 7, 2017, 4:06:35 PM3/7/17
to dbfit
It's probably worth trying to set up remote debugging so you can trace code, set breakpoints, etc.

Have a look at the instructions about Eclipse / FitNesse debugging:
https://github.com/dbfit/dbfit/blob/master/CONTRIBUTING.md

Mark Matten

unread,
Mar 7, 2017, 4:13:15 PM3/7/17
to dbfit
Regarding the CRLF issue, you can probably set up your editor / IDE to have LF line endings and your git configuration to check out files with LF line endings too if you wanted to enable the checkstyle checks in the build.

Jessie Lin

unread,
Mar 7, 2017, 4:41:56 PM3/7/17
to dbfit
Thank you Mark! I'll give it a shot.

Yavor Nikolov

unread,
Mar 7, 2017, 4:45:08 PM3/7/17
to dbfit
Hi Jessie,

* You need at least one key column (without a ?)
* It's expected the set of all the key columns to form a unique combination. (If that's not true - you may add a distinct clause to your query or you may add some auto-generated row number /it's database specific how to do that/)

You can try with either:

!|Query|select col1, col2 from table2 where col1 = 10|
|col1|col2|
|123 |abc |

or

!|Query|select col1, col2 from table2 where col1 = 10|
|col2|
|abc |



If things are still failing - it's possible that to be due to your custom environment. Please share the error message and exception stack for the queries above.

Are column names here case sensitive?
In general they're not case sensitive (which has pros and cons). Your custom environment implementation is supposed to return normalised names - as per NameNormaliser.normaliseName which as of now is lowercase.

It's possible to enable some debug logging (e.g. to dump the column names returned by your database environment.getAllColumns):

!|set option|debuglog|true|

And a logger usage example you may find in Query.java and DatabaseTest.java

Best Regards,
Yavor


--
You received this message because you are subscribed to the Google Groups "dbfit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dbfit+unsubscribe@googlegroups.com.

Jessie Lin

unread,
Mar 7, 2017, 5:27:34 PM3/7/17
to dbfit
Hi Yavor,

Thank you for helping out!

It makes sense to have at least one key column. The result set are unique.
I tried both ways, but things look the same. Here's the exception stack. 

java.lang.NullPointerException at dbfit.fixture.RowSetFixture.findMatchingRow(RowSetFixture.java:120) at dbfit.fixture.RowSetFixture.doRow(RowSetFixture.java:107) at fit.Fixture.doRows(Fixture.java:162) at fit.ColumnFixture.doRows(ColumnFixture.java:19) at dbfit.fixture.RowSetFixture.doRows(RowSetFixture.java:93) at fit.Fixture.doTable(Fixture.java:156) at fit.Fixture.interpretFollowingTables(Fixture.java:121) at fit.Fixture.interpretTables(Fixture.java:107) at fit.Fixture.doTables(Fixture.java:81) at fit.FitServer.process(FitServer.java:81) at fit.FitServer.run(FitServer.java:56) at fit.FitServer.main(FitServer.java:41)

For !|set option|debuglog|true|
where shall I put it? I put it after DBEnvironment and before Query. But it doesn't seem to be working.

Thank you for advising!

Jessie
To unsubscribe from this group and stop receiving emails from it, send an email to dbfit+un...@googlegroups.com.

Jessie Lin

unread,
Mar 7, 2017, 5:28:44 PM3/7/17
to dbfit
Hi Mark, got the CRLR thing working finally. Thank you!
Off to getting remote debug set up. I guess I need Eclipse, IntelliJ wouldn't work, would it?

Jessie Lin

unread,
Mar 8, 2017, 1:16:42 AM3/8/17
to dbfit
Hello Mark, Yavor, and Martin, thank you ALL very much.

With remote debug finally I got the bottom of it and the issue is now fixed.
The issue was caused by dependencies.
I created a custom db environment, and should copy all the updated jars, which are core and fitnesse.
The fitness server I downloaded had an older version of fitness(20150424) standalone jar than the development(20161106).

Now everything works well. 

Best,
Jessie

On Sunday, March 5, 2017 at 5:52:24 PM UTC-8, Jessie Lin wrote:
Reply all
Reply to author
Forward
0 new messages