Menu ▾ ▴

#2 Command line give NullPointerException in compareCSVWriteResult

1.0
closed
nobody
None
2017-11-25
2017-11-13
No

When I run the command line utility from Linux (with any argument) I get a null pointer exception. I get the same if I use a command file as well.

~ > java -jar ./CSVComparator/CSVComparatorCLI_java8.jar -config.loglevel.console=ALL -config.loglevel.file=OFF –older.file=./temp/compareold/CompFile.tab -older.delimiter=',' -older.label=old –younger.file=./temp/comparenew/CompFile.tab -younger.delimiter=',' -younger.label=new -column.identifier=ID,ID -result.file=./temp/compareout.txt -result.delimiter=';' -result.comparediff=false -result.comparediff%=false -result.comparestring=true
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at com.csvapi.compare.CSVAPICompare.compareCSVWriteResult(CSVAPICompare.java:48)
at com.csvcomparator.cli.main.CSVComparatorCLI.main(CSVComparatorCLI.java:55)
... 5 more
~ > ll ./temp/comparenew/CompFile.tab
-rwxr-xr-x 1 nobody nobody 84 Nov 11 22:03 ./temp/comparenew/CompFile.tab
~ > ll ./temp/compareold/CompFile.tab
-rwxr-xr-x 1 nobody nobody 94 Nov 11 22:04 ./temp/compareold/CompFile.tab
~ > ll ./temp/compareout.txt
-rw-r--r-- 1 nobody nobody 0 Nov 11 22:48 ./temp/compareout.txt</init>

~ > ll csvapi.log
-rw-r--r-- 1 nobody nobody 0 Nov 12 10:04 csvapi.log

java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

~/temp > echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-oracle-1.8.0.45-1jpp.2.el7_1.x86_64/jre

I have tried three different versions of Java 8 with the same result. Any ideas? Thanks!

Related

Tickets: #2

Discussion

  • Martin Le Brun

    Martin Le Brun - 2017-11-13

    FYI, the below gives the same error, so it seems not to be due to the file or other config parameters.

    java -jar ./CSVComparator/CSVComparatorCLI_java8.jar -config.loglevel.console=OFF -config.loglevel.file=OFF

     
  • xresch

    xresch - 2017-11-13

    Hi Martin,

    this is thrown by the following line in the code:
    //-------------------------------------
    // Compare if both file exists and are readable
    //-------------------------------------
    if(new File(olderFile).canRead() && new File(youngerFile).canRead()){

    Just to be sure that everything is okay with the paths, can you try to copy the .jar and the files you want to compare all in the same directory and try it again?

    Cheers
    xresch

     
    • Martin Le Brun

      Martin Le Brun - 2017-11-14

      Hi xresch

      Both files are readable from the same bash command line as the utility:

      ~ > if [[ -r ./temp/comparenew/CompFile.tab ]] ; then echo "File is
      readable"; else "file is not readable"; fi;
      File is readable
      ~ > if [[ -r ./temp/compareold/CompFile.tab ]] ; then echo "File is
      readable"; else "file is not readable"; fi;
      File is readable

      Martin.

      On Mon, Nov 13, 2017 at 5:09 PM, xresch xresch@users.sf.net wrote:

      Hi Martin,

      this is thrown by the following line in the code:
      //-------------------------------------
      // Compare if both file exists and are readable
      //-------------------------------------
      if(new File(olderFile).canRead() && new File(youngerFile).canRead()){

      Just to be sure that everything is okay with the paths, can you try to
      copy the .jar and the files you want to compare all in the same directory
      and try it again?

      Cheers
      xresch


      Status: open
      Milestone: 1.0
      Created: Mon Nov 13, 2017 05:19 PM UTC by Martin Le Brun
      Last Updated: Mon Nov 13, 2017 05:50 PM UTC
      Owner: nobody

      When I run the command line utility from Linux (with any argument) I get a
      null pointer exception. I get the same if I use a command file as well.

      ~ > java -jar ./CSVComparator/CSVComparatorCLI_java8.jar
      -config.loglevel.console=ALL -config.loglevel.file=OFF
      –older.file=./temp/compareold/CompFile.tab -older.delimiter=','
      -older.label=old –younger.file=./temp/comparenew/CompFile.tab
      -younger.delimiter=',' -younger.label=new -column.identifier=ID,ID
      -result.file=./temp/compareout.txt -result.delimiter=';'
      -result.comparediff=false -result.comparediff%=false
      -result.comparestring=true
      Exception in thread "main" java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(
      NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.
      main(JarRsrcLoader.java:58)
      Caused by: java.lang.NullPointerException
      at java.io.File.<init>(File.java:277)
      at com.csvapi.compare.CSVAPICompare.compareCSVWriteResult(
      CSVAPICompare.java:48)
      at com.csvcomparator.cli.main.CSVComparatorCLI.main(
      CSVComparatorCLI.java:55)
      ... 5 more
      ~ > ll ./temp/comparenew/CompFile.tab
      -rwxr-xr-x 1 nobody nobody 84 Nov 11 22:03 ./temp/comparenew/CompFile.tab
      ~ > ll ./temp/compareold/CompFile.tab
      -rwxr-xr-x 1 nobody nobody 94 Nov 11 22:04 ./temp/compareold/CompFile.tab
      ~ > ll ./temp/compareout.txt
      -rw-r--r-- 1 nobody nobody 0 Nov 11 22:48 ./temp/compareout.txt</init>

      ~ > ll csvapi.log
      -rw-r--r-- 1 nobody nobody 0 Nov 12 10:04 csvapi.log

      java -version
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      ~/temp > echo $JAVA_HOME
      /usr/lib/jvm/java-1.8.0-oracle-1.8.0.45-1jpp.2.el7_1.x86_64/jre

      I have tried three different versions of Java 8 with the same result. Any
      ideas? Thanks!


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/csvcomparator/tickets/2/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Tickets: #2

      • Martin Le Brun

        Martin Le Brun - 2017-11-14

        I also ran a basic java program and it can read the file too

        ~ > java Test
        canRead ./temp/comparenew/CompFile.tab
        ID,Data 1,Data 2
        1,ABC,123
        2,DEF,456
        3,HIJ,789
        4,KJM,012
        7,RST,678
        5,OPQ,345
        8,UVW,910

        See attached for the program

        On Mon, Nov 13, 2017 at 7:05 PM, Martin Le Brun martinlebrun3141@gmail.com
        wrote:

        Hi xresch

        Both files are readable from the same bash command line as the utility:

        ~ > if [[ -r ./temp/comparenew/CompFile.tab ]] ; then echo "File is
        readable"; else "file is not readable"; fi;
        File is readable
        ~ > if [[ -r ./temp/compareold/CompFile.tab ]] ; then echo "File is
        readable"; else "file is not readable"; fi;
        File is readable

        Martin.

        On Mon, Nov 13, 2017 at 5:09 PM, xresch xresch@users.sf.net wrote:

        Hi Martin,

        this is thrown by the following line in the code:
        //-------------------------------------
        // Compare if both file exists and are readable
        //-------------------------------------
        if(new File(olderFile).canRead() && new File(youngerFile).canRead()){

        Just to be sure that everything is okay with the paths, can you try to
        copy the .jar and the files you want to compare all in the same directory
        and try it again?

        Cheers
        xresch


        Status: open
        Milestone: 1.0
        Created: Mon Nov 13, 2017 05:19 PM UTC by Martin Le Brun
        Last Updated: Mon Nov 13, 2017 05:50 PM UTC
        Owner: nobody

        When I run the command line utility from Linux (with any argument) I get
        a null pointer exception. I get the same if I use a command file as well.

        ~ > java -jar ./CSVComparator/CSVComparatorCLI_java8.jar
        -config.loglevel.console=ALL -config.loglevel.file=OFF
        –older.file=./temp/compareold/CompFile.tab -older.delimiter=','
        -older.label=old –younger.file=./temp/comparenew/CompFile.tab
        -younger.delimiter=',' -younger.label=new -column.identifier=ID,ID
        -result.file=./temp/compareout.txt -result.delimiter=';'
        -result.comparediff=false -result.comparediff%=false
        -result.comparestring=true
        Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
        ssorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
        thodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(
        JarRsrcLoader.java:58)
        Caused by: java.lang.NullPointerException
        at java.io.File.<init>(File.java:277)
        at com.csvapi.compare.CSVAPICompare.compareCSVWriteResult(CSVAP
        ICompare.java:48)
        at com.csvcomparator.cli.main.CSVComparatorCLI.main(CSVComparat
        orCLI.java:55)
        ... 5 more
        ~ > ll ./temp/comparenew/CompFile.tab
        -rwxr-xr-x 1 nobody nobody 84 Nov 11 22:03 ./temp/comparenew/CompFile.tab
        ~ > ll ./temp/compareold/CompFile.tab
        -rwxr-xr-x 1 nobody nobody 94 Nov 11 22:04 ./temp/compareold/CompFile.tab
        ~ > ll ./temp/compareout.txt
        -rw-r--r-- 1 nobody nobody 0 Nov 11 22:48 ./temp/compareout.txt</init>

        ~ > ll csvapi.log
        -rw-r--r-- 1 nobody nobody 0 Nov 12 10:04 csvapi.log

        java -version
        java version "1.8.0_45"
        Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
        Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

        ~/temp > echo $JAVA_HOME
        /usr/lib/jvm/java-1.8.0-oracle-1.8.0.45-1jpp.2.el7_1.x86_64/jre

        I have tried three different versions of Java 8 with the same result. Any
        ideas? Thanks!


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/csvcomparator/tickets/2/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

         

        Related

        Tickets: #2

        • Martin Le Brun

          Martin Le Brun - 2017-11-14

          I can reproduce the exception with

          import java.io.*;

          public class Test {
          public static void main(String [] args) {

              // The name of the file to open.
              String olderFile = null;
          
              if (new File(olderFile).canRead()) {
                  System.out.println("canRead " + olderFile);
              } else {
                  System.