[Building Sakai] How to Using POI library in Sakai project?

Adrian Fish a.fish at lancaster.ac.uk
Tue Mar 6 02:56:24 PST 2012


Hi Bao,

Have you tried running the jar -tf command on the POI jars? You need to 
make sure that the class is in one of the jars that you have in your pom 
file. That would explain the missing class straight away.

 From your home directory, do this:

jar -tf .m2/repository/poi/poi/3.7-20101029/poi-3.7-20101029.jar | grep DirectoryNode
jar -tf .m2/repository/poi/poi/ooxml-3.7-20101029/poi-ooxml-3.7-20101029.jar | grep DirectoryNode
jar -tf .m2/repository/poi/poi/scratchpad-3.7-20101029/poi-scratchpad-3.7-20101029.jar | grep DirectoryNode

If the class is not in any of the jar files, then you have a problem!

Cheers,
Adrian.

On 06/03/2012 03:01, baotram wrote:
> Hi Adrian!
>   three jars file in my local maven repository:
>    .m2/repository/poi/poi/3.7-20101029/poi-3.7-20101029.jar
>   .m2/repository/poi/poi/ooxml-3.7-20101029/poi-ooxml-3.7-20101029.jar
> .m2/repository/poi/poi/scratchpad-3.7-20101029/poi-scratchpad-3.7-20101029.jar
>
> I add dependency in pom.xml  right or wrong??:
>
> <dependency>
>        <groupId>poi</groupId>
>        <artifactId>poi</artifactId>
>          <version>3.7-20101029</version>
> </dependency>
>   <dependency>
>           <groupId>poi</groupId>
>           <artifactId>poi</artifactId>
>           <version>ooxml-3.7-20101029</version>
>   </dependency>
>   <dependency>
>          <groupId>poi</groupId>
>          <artifactId>poi</artifactId>
>          <version>scratchpad-3.7-20101029</version>
>   </dependency>
>
> Please help me about that error.
> Thanks for your helping!
> BaoTram.
>
> Adrian Fish wrote:
>> Hi Bao,
>>
>> Find the jars in your local maven repository and run jar -tf against
>> them to list the classes.
>>
>> A command like this ...
>>
>> jar -tf poi-3.7-20101029.jar | grep DirectoryNode
>>
>> .. will tell you if that class is in the jar.
>>
>> That's the first thing I'd try as you may not be pulling in the correct
>> POI jar.
>>
>> Your local maven repo is usually under<HOMEDIR</.m2/repository
>>
>> Cheers,
>> Adrian.
>>
>> On 05/03/2012 09:01, Tram Bao wrote:
>>> Dear all,
>>> I've use POI library in my project. POI library consist 3 package:
>>> poi-3.7-20101029.jar; poi-ooxml-3.7-20101029.jar;
>>> poi-scratchpad-3.7-20101029.jar
>>> I add dependency in pom.xml:
>>>
>>> <dependency>
>>> <groupId>poi</groupId>
>>> <artifactId>poi</artifactId>
>>> <version>3.7-20101029</version>
>>> </dependency>
>>> <dependency>
>>> <groupId>poi</groupId>
>>> <artifactId>poi</artifactId>
>>> <version>ooxml-3.7-20101029</version>
>>> </dependency>
>>> <dependency>
>>> <groupId>poi</groupId>
>>> <artifactId>poi</artifactId>
>>> <version>scratchpad-3.7-20101029</version>
>>> </dependency>
>>> but when I build project, it build failure:
>>>                                cannot access
>>> org.apache.poi.poifs.filesystem.DirectoryNode
>>>                                          class file for
>>> org.apache.poi.poifs.filesystem.DirectoryNode not found
>>>                                                          HWPFDocument
>>> doc=new HWPFDocument(fis);
>>>
>>> This is my function:
>>>
>>> public String ReadDocToByte(String link)
>>>      {
>>>
>>>          //link="F:\\test.doc";
>>>          byte []fileData=new byte[]{};
>>>
>>>          WordExtractor ex=null;
>>>          try
>>>          {
>>>
>>>              FileInputStream fis=new FileInputStream(link);
>>>              HWPFDocument doc=new HWPFDocument(fis);
>>>
>>>              fileData=doc.getDataStream();
>>>
>>>          }
>>>
>>>          catch (FileNotFoundException e)
>>>          {
>>>
>>>              e.printStackTrace();
>>>          }
>>>          catch (IOException e)
>>>          {
>>>
>>>              e.printStackTrace();
>>>          }
>>>          return fileData.toString();
>>>      }
>>>
>>>
>>> This function is used to read a doc file.
>>>
>>> Please help me fix that error.
>>> Thanks all,
>>> BaoTram.
>>>
>>>
>>> _______________________________________________
>>> sakai-dev mailing list
>>> sakai-dev at collab.sakaiproject.org
>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>>
>>> TO UNSUBSCRIBE: send email to
>>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>>> "unsubscribe"
>> -- 
>> ==================================
>> Adrian Fish
>> Software Engineer
>> B66 Management School
>> Lancaster University
>> Lancaster
>> LA1 4YW
>>
>> http://www.sakaiproject.org
>> http://confluence.sakaiproject.org/display/YAFT/Yaft
>> http://confluence.sakaiproject.org/display/CLOG/Home
>> http://confluence.sakaiproject.org/display/BBB/Home
>>
>>
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>
>> TO UNSUBSCRIBE: send email to
>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>> "unsubscribe"
>>

-- 
==================================
Adrian Fish
Software Engineer
B66 Management School
Lancaster University
Lancaster
LA1 4YW

http://www.sakaiproject.org
http://confluence.sakaiproject.org/display/YAFT/Yaft
http://confluence.sakaiproject.org/display/CLOG/Home
http://confluence.sakaiproject.org/display/BBB/Home



More information about the sakai-dev mailing list