XSSFWorkbook cannot be resolved to a type

Hi,

I am working on a java code which updates the excel file.

Code is not getting compiled i am getting below error.
XSSFWorkbook cannot be resolved to a type and The import org.apache.poi cannot be resolved

Code is
try {
FileInputStream excelFile = new FileInputStream(new File(inputFile));
Workbook workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(8); // Get Second Worksheet

 so on ..........

I am placed the below jars in package/code/jars folder.
poi-3.17.jar
poi-ooxml-3.17.jar
poi-ooxml-schemas-3.17.jar
xmlbeans-2.6.0.jar

Please suggest solution.

Thanks,
Kavitha

Looks like you are missing out this “Adding Classes to the Service Development Project” Refer Service Development Guide.

Hi Kavitha ,

You need to import these jar or lib files in build path of your project to get your code compiled . Go to Package explorer view in designer → Right click on your project in which your java code which updates the excel file resides and click on build path → Go to libs tab → add external jars and add above all jar files which you placed in “package/code/jars folder” .

Once designer loads all built in classes in project space this code will get compiled .

Thanks
Shrikant

Hi,

when not using Local Service Development and working remotely on the IS, the package needs to be reloaded once after placing the jars to make them available to the class loader.

After making and reverting a small change to the service, it will compile upon next save.

Regards,
Holger

Hi,

I am also facing the same issue. I would like to add that, this error occurred after a week of successful execution of the same service.
Also note that, for the initial 2 occurrences of this error, I did the following steps which helped to solve the issue:
1. I imported these jar files again to build path (even though it was already existing)
2. Recompiled the java service again

On later occurrences of the error, this work round didn’t help. But a server restart helped.

Again today the same issue occurred.
Can some one help with a permanent fix for this issue as the error is occurring very frequently.

Error Details are :
Unresolved compilation problems:
XSSFWorkbook cannot be resolved to a type
XSSFWorkbook cannot be resolved to a type
Sheet cannot be resolved to a type
Row cannot be resolved to a type

Any lead will be a help.

Thanks
Nithya

Nithya, as holger pointed out above. you need to make sure your apache POI jar is available in server classpath. having jar in your eclipse path alone will not suffice. it has to be in IS or package class path too.

i also faced same issue. i have placed the jars under the path “\code\jars” and restarted IS.

1 Like