On 7 November 2015 at 10:27, Darryl Freinkel
<dfreinkel@xxxxxxxxxxxxxxxxx> wrote:
I have resolved some issues but now have a hard halt when trying to execute
ss_open().
I am trying to get my first program to work reading a spreadsheet using
Scott's examples and guidance.
I think I have it mostly correct but I am unable to debug through the HSSFR4
service program.
It fails on the ss_open(). Here is the error.
Additional Message Information
Message ID . . . . . . : RNX0301 Severity . . . . . . . : 50
Message type . . . . . : Escape
Date sent . . . . . . : 11/07/15 Time sent . . . . . . :
08:30:27
Message . . . . : Java exception received when calling Java method.
Cause . . . . . : RPG procedure SS_OPEN in program POI36/HSSFR4 received
Java exception "java.lang.NoClassDefFoundError:
org/apache/poi/ss/usermodel/WorkbookFactory" when calling method "create"
with signature
"(Ljava.io.InputStream;)Lorg.apache.poi.ss.usermodel.Workbook;" in class
"org.apache.poi.ss.usermodel.WorkbookFactory".
Recovery . . . : Contact the person responsible for program maintenance
to determine the cause of the problem.
The Java environment has some similarities to ILE, but it really is a
different beast. CLASSPATH issues are the first hurdle that all Java
programmers need to get past. The technical description of the
CLASSPATH is easy: it's an environment variable one sets via
WRKENVVAR, ADDENVVAR, etc. Setting it is easy. Knowing what to set
it to is not.
Jar files are sort of like service programs. The following is way simplified:
Java ILE
.jar library
class service program
method sub-procedure
Now, imagine that a friend has called you up on the phone (remember
those?) and has told you that she's getting a 'Can't find
sub-procedure' error. Where do you start? It's sort of the same
problem with Java. The CLASSPATH tells the Java runtime where to find
the .jar files, and by implication, the classes within them. Isn't
theory great? Yeah, about that...
So what is it that the JRE (Java Runtime Environment) can't find?
It's looking for a method called 'create' inside a class called
'org/apache/poi/ss/usermodel/WorkbookFactory' but what .jar file is
supposed to be holding that class? It's the same problem as ILE - if
all you have is the sub-procedure name, how do you know what service
program contains it? You could brute-force search every service
program on the system, but how horrible would that be? One can start
at the Javadoc:
http://poi.apache.org/apidocs/index.html Upper left,
click on org.apache.poi.ss.usermodel Lower left click on
WorkbookFactory and there's the Javadoc the explanation of what to do
to use it. But where is this thing stored, what .jar file? The
Javadoc is no help here. Having said that, get used to reading
Javadoc - this is what Java people use to tell each other how their
stuff works.
Back to POI. The home page
http://poi.apache.org/ has a link for
components: 'The Apache POI Project provides several component modules
some of which may not be of interest to you. Use the information on
our Components page to determine which jar files to include in your
classpath.' That page shows the way they've named their .jar files.
We're looking for the .jar file which holds the POI classes. My .jar
file is called poi-3-6-20091214.jar and I've put it in
/hssfcgi/java/poi3.6 which makes the required CLASSPATH entry
'/hssfcgi/java/poi3.6/poi-3-6-20091214.jar'
It looks like you don't want to specify each and every .jar file in
your CLASSPATH, which is OK - Java 6 and up supports wildcards in the
CLASSPATH.
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html
There's no '*' in your current CLASSPATH - try this
'/Java/dom4j-1.6.1/*:/Java/poi-3.6/*:/Java/xmlbeans/*'
--buck
As an Amazon Associate we earn from qualifying purchases.