Skip to content

Using reader classloader fails to load CSV file in "Batch Chunk CSV Database" sample with glassfish-embedded-arquillian profile. Maybe use TCCL instead. #269

@scottkurz

Description

@scottkurz

Pasted the last part of the stack trace below ... hit the same thing on IBM JDK 7 and Oracle JDK 7.

I noticed one of the json samples uses the TCCL to load a file. Made the change it worked for me (sorry for not including a pull request).

public class MyItemReader extends AbstractItemReader {
  ...
    public void open(Serializable checkpoint) throws Exception {
        reader = new BufferedReader(
                new InputStreamReader(
                    this
                    .getClass()
                    .getClassLoader()
                    .getResourceAsStream("/META-INF/mydata.csv")
                )
            );
    }

Console log w/ stack trace

$ mvn  -Pglassfish-embedded-arquillian,browser-firefox clean test
 .....
 ....
Caused by: java.lang.NullPointerException
        at java.io.Reader.<init>(Reader.java:78)
        at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
        at org.javaee7.batch.chunk.csv.database.MyItemReader.open(MyItemReader.java:23)
        at com.ibm.jbatch.container.artifact.proxy.ItemReaderProxy.open(ItemReaderProxy.java:54)
        ... 14 more

Oct 28, 2014 9:38:43 AM org.eclipse.persistence.session.file:/C:/cygwin/tmp/gfembed6559404755261076625tmp/applications/8b12ccc6-6e57-46b3-9104-0beddf0a6588/WEB-INF/classes/_MyPU.connection
INFO: file:/C:/cygwin/tmp/gfembed6559404755261076625tmp/applications/8b12ccc6-6e57-46b3-9104-0beddf0a6588/WEB-INF/classes/_MyPU logout successful
PlainTextActionReporterSUCCESSNo monitoring data to report.
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 11.39 sec <<< FAILURE! - in org.javaee7.batch.chunk.csv.database.BatchCSVDatabaseTest
testBatchCSVDatabase(org.javaee7.batch.chunk.csv.database.BatchCSVDatabaseTest)  Time elapsed: 2.688 sec  <<< FAILURE!
java.lang.AssertionError: expected:<7> but was:<0>
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.failNotEquals(Assert.java:743)
        at org.junit.Assert.assertEquals(Assert.java:118)
        at org.junit.Assert.assertEquals(Assert.java:555)
        at org.junit.Assert.assertEquals(Assert.java:542)
        at org.javaee7.batch.chunk.csv.database.BatchCSVDatabaseTest.testBatchCSVDatabase(BatchCSVDatabaseTest.java:108)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions