JBehave
  1. JBehave
  2. JBEHAVE-840

Unable to read excel from classpath using jxl

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 3.6.8
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Windows 7, Java 1.6, JBehave 3.6.8, JXL 2.6.12
    • Number of attachments :
      0

      Description

      I am unable to read excel using jxl from classpath however the same code is working fine with standalone code.
      Excel is placed in src/main/resources/test.xls

      Workbook workbook = null; InputStream stream =this.getClass().getClassLoader().getResourceAsStream("test.xls"); workbook = Workbook.getWorkbook(stream); Sheet sheet = workbook.getSheet(0); Cell a1 = sheet.getCell(0,0);

      However if I use the file system path as
      workbook = Workbook.getWorkbook(new File("src/main/resources/test.xls "));
      I am able to read in jbehave.

      Is this an issue with Jbehave since standalone code works in both the ways.

        Activity

        Hide
        Brian Repko added a comment -

        Ajay - please use the mailing lists prior to logging a bug.

        My guess is that this is not a bug.
        If the file is in src/main/resources, then it is not on your classpath unless resources are copied over.
        Is it in target/classes? That is where your classpath is looking.

        If you are still having problems, then please attach a small project that duplicates the issue.

        Show
        Brian Repko added a comment - Ajay - please use the mailing lists prior to logging a bug. My guess is that this is not a bug. If the file is in src/main/resources, then it is not on your classpath unless resources are copied over. Is it in target/classes? That is where your classpath is looking. If you are still having problems, then please attach a small project that duplicates the issue.
        Hide
        Ajay Singh added a comment -

        Hi,
        Resolved the issue.
        Root cause: xls file was getting corrupted when copied to target/classes folder during build using maven [mvn clean install]

        Resolution : Added the following plug in pom.xml

        <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <configuration>
        <encoding>UTF-8</encoding>
        <nonFilteredFileExtensions>
        <nonFilteredFileExtension>xls</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
        </configuration>
        </plugin>

        Show
        Ajay Singh added a comment - Hi, Resolved the issue. Root cause: xls file was getting corrupted when copied to target/classes folder during build using maven [mvn clean install] Resolution : Added the following plug in pom.xml <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <configuration> <encoding>UTF-8</encoding> <nonFilteredFileExtensions> <nonFilteredFileExtension>xls</nonFilteredFileExtension> </nonFilteredFileExtensions> </configuration> </plugin>
        Hide
        Ajay Singh added a comment -

        Root cause: xls was getting corrupted during maven build

        Resolution : Added the following plug in pom.xml

        <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <configuration>
        <encoding>UTF-8</encoding>
        <nonFilteredFileExtensions>
        <nonFilteredFileExtension>xls</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
        </configuration>
        </plugin>

        Show
        Ajay Singh added a comment - Root cause: xls was getting corrupted during maven build Resolution : Added the following plug in pom.xml <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <configuration> <encoding>UTF-8</encoding> <nonFilteredFileExtensions> <nonFilteredFileExtension>xls</nonFilteredFileExtension> </nonFilteredFileExtensions> </configuration> </plugin>
        Ajay Singh made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Not A Bug [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Ajay Singh
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1 day
              1d
              Remaining:
              Remaining Estimate - 1 day
              1d
              Logged:
              Time Spent - Not Specified
              Not Specified