You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by jigna joshi <jj...@asite.com> on 2008/07/30 11:35:22 UTC

java.lang.NegativeArraySizeException

HI,
I am using 

poi-3.0.1-FINAL-20070705.jar, poi-contrib-3.0.1-FINAL-20070705.jar,
poi-scratchpad-3.0.1-FINAL-20070705.jar  jars for reading content of
documents..

I am getting below exception when I try to read password protected document.

java.lang.NegativeArraySizeException

12:49:45,319 INFO  [STDOUT] : 140   at
org.apache.poi.hwpf.model.FIBFieldHandler.<init>(FIBFieldHandler.java:141)

12:49:45,319 INFO  [STDOUT] : 140   at
org.apache.poi.hwpf.model.FileInformationBlock.fillVariableFields(FileInformationBlock.java:67)

12:49:45,319 INFO  [STDOUT] : 140   at
org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:177)

12:49:45,319 INFO  [STDOUT] : 140   at
org.apache.poi.hwpf.extractor.WordExtractor.<init>(WordExtractor.java:57)

12:49:45,319 INFO  [STDOUT] : 140   at
org.apache.poi.hwpf.extractor.WordExtractor.<init>(WordExtractor.java:49)

12:49:45,319 INFO  [STDOUT] : 140   at
com.asite.collab.content.util.filters.WordDocumentFilterImpl.getContentReader(WordDocumentFilterImpl.java:54)
I have also tried the same with 3.0.2 version of above jars..but getting
same exception

Please do the needful.
Thanking You.

Best Regards,
Jigna Joshi


-- 
View this message in context: http://www.nabble.com/java.lang.NegativeArraySizeException-tp18729532p18729532.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 1 Aug 2008, jigna joshi wrote:
> do you have docmentation (API) for POI3.5.1beta version..

It's all in the /docs/ directory of the download

> org.apache.xmlbeans.XmlException: error: The document is not a
> workbook@http://schemas.openxmlformats.org/spreadsheetml/2006/main: document
> element namespace mismatch expected
> "http://schemas.openxmlformats.org/spreadsheetml/2006/main" got
> "http://schemas.microsoft.com/office/excel/2006/2"

Your document isn't an office open xml file. It looks to me like it was 
generated by a beta version of office 2007, from back before the 
specification was finished, and before office implemented it properly.

Try opening it and saving it again in excel, with any luck it'll be 
upgraded to a real ooxml file

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by jigna joshi <jj...@asite.com>.
Hi
thanx for the help..now, i m able to read .docx file...
but, getting problem with xlsx file..
do you have docmentation (API) for POI3.5.1beta version..I am getting this
error
org.apache.xmlbeans.XmlException: error: The document is not a
workbook@http://schemas.openxmlformats.org/spreadsheetml/2006/main: document
element namespace mismatch expected
"http://schemas.openxmlformats.org/spreadsheetml/2006/main" got
"http://schemas.microsoft.com/office/excel/2006/2"
http://www.nabble.com/file/p18770293/xlsxReader.txt xlsxReader.txt 
-- 
View this message in context: http://www.nabble.com/java.lang.NegativeArraySizeException-tp18729532p18770293.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 31 Jul 2008, jigna joshi wrote:
> I have taken newer release of jars (poi-bin-3.5-beta1-20080718)
> but, when i try to read .docx file, it gives below exception.
>
> com.asite.collab.content.util.DocumentContentSearchException: Error indexing
> word document. The supplied data appears to be in the Office 2007+ XML. POI
> only supports OLE2 Office documents

You'll want to read the documentation for poi 3.5, you need to use a 
slightly different class for the ooxml files (same interfaces though), or 
there's a handy org.apache.poi.extractor.ExtractorFactory which'll build 
the right text extractor for you

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by jigna joshi <jj...@asite.com>.
Hi,

I have taken newer release of jars (poi-bin-3.5-beta1-20080718)
but, when i try to read .docx file, it gives below exception.

com.asite.collab.content.util.DocumentContentSearchException: Error indexing
word document. The supplied data appears to be in the Office 2007+ XML. POI
only supports OLE2 Office documents
-- 
View this message in context: http://www.nabble.com/java.lang.NegativeArraySizeException-tp18729532p18753646.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 31 Jul 2008, jigna joshi wrote:
> As i have mentioned in d earlier msg, i am getting
> org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data
> appears to be in the Office 2007+ XML. POI only supports OLE2 Office
> documents  Exception when i try to read content of .docx file...
> code to read file.....

If you give an OOXML file to POIFSFileSystem, you'll get that exception! 
Just give ExtractorFactory the file or input stream, and it'll do the 
rest.

WordExtractor DocExt = (WordExtractor)we.createExtractor(file);
fReader = new CharArrayReader(DocExt.getText().toCharArray());

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by jigna joshi <jj...@asite.com>.
Hi,
As i have mentioned in d earlier msg, i am getting 
org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data
appears to be in the Office 2007+ XML. POI only supports OLE2 Office
documents  Exception when i try to read content of .docx file...
code to read file.....
 InputStream fileInput = new BufferedInputStream(new FileInputStream(file));
          POIFSFileSystem poifsFileSystem = new POIFSFileSystem(fileInput);
           ExtractorFactory we = new ExtractorFactory();
           WordExtractor DocExt =
(WordExtractor)we.createExtractor(poifsFileSystem
            fReader = new CharArrayReader(DocExt.getText().toCharArray());       
-- 
View this message in context: http://www.nabble.com/java.lang.NegativeArraySizeException-tp18729532p18754731.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 31 Jul 2008, Andy Oliver wrote:
> So it looks to me like it is in the clear.  I'll check my old laptops 
> for the prototype code I wrote that semi-implements this.  It is against 
> a pretty out of date version (~1.x-ish) but might be relevant at least 
> for the binary formats.

Sounds good. Give me a shout if I should do any of the paperwork / filing 
with my PMC chair hat on

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Andy Oliver <ac...@gmail.com>.
Yeah.  That is a lot easier.  In the past getting it wrong involved
potential jail time.  That sounded like a bad idea to me.  :-)

This "One may not, however, knowlingly[sic] export source code to a
terrorist country, although source code may be posted on the WWW for
downloading without the poster having to check whether it is
downloaded from a terrorist country." is a key change (if true).

So it looks to me like it is in the clear.  I'll check my old laptops
for the prototype code I wrote that semi-implements this.  It is
against a pretty out of date version (~1.x-ish) but might be relevant
at least for the binary formats.

-Andy

On Thu, Jul 31, 2008 at 9:14 AM, Nick Burch <ni...@torchbox.com> wrote:
> On Thu, 31 Jul 2008, Andy Oliver wrote:
>>
>> http://rechten.uvt.nl/koops/cryptolaw/cls2.htm#us gives kind of a history
>> of this.  Because Apache servers are in the US, US law is supreme here, but
>> individuals may have other issues in their home countries.  It looks like
>> we're now in the clear to implement this, but IANAL.
>
> It's fairly easy for apache projects to do crypto stuff now. We have to
> record in the right place that we're doing it, fire off a form letter to the
> US government, update the readme and the website with some boiler plate text
> and we're done. It's all on this handy page:
>        http://www.apache.org/dev/crypto.html
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 31 Jul 2008, Andy Oliver wrote:
> http://rechten.uvt.nl/koops/cryptolaw/cls2.htm#us gives kind of a 
> history of this.  Because Apache servers are in the US, US law is 
> supreme here, but individuals may have other issues in their home 
> countries.  It looks like we're now in the clear to implement this, but 
> IANAL.

It's fairly easy for apache projects to do crypto stuff now. We have to 
record in the right place that we're doing it, fire off a form letter to 
the US government, update the readme and the website with some boiler 
plate text and we're done. It's all on this handy page:
 	http://www.apache.org/dev/crypto.html

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Andy Oliver <ac...@gmail.com>.
http://rechten.uvt.nl/koops/cryptolaw/cls2.htm#us gives kind of a
history of this.  Because Apache servers are in the US, US law is
supreme here, but individuals may have other issues in their home
countries.  It looks like we're now in the clear to implement this,
but IANAL.

On Thu, Jul 31, 2008 at 8:22 AM, Andy Oliver <ac...@gmail.com> wrote:
> To be clear we didn't include Password protection not because we
> didn't figure out how to reverse engineer (I did) it but because I
> didn't want to navigate the legal issues.  Meaning there is a whole
> set of US and International regimes involved in encryption.  At the
> time these were ever worse than they are now.  I didn't want to figure
> it all out just to provide "fool me, lie to me" security.
>
> On Thu, Jul 31, 2008 at 8:08 AM, Nick Burch <ni...@torchbox.com> wrote:
>> On Thu, 31 Jul 2008, jigna joshi wrote:
>>>
>>> thanx for d reply
>>> in the new release, the EncryptedDocumentException would be thrown that it
>>> is written..
>>> but, is there a fix for reading password protected file or just i have to
>>> ignore that file..
>>
>> Reading password protected files is not supported. The documentation has
>> finally been released by Microsoft (back in June), so if someone wanted to
>> add support it wouldn't be impossible. You'd probably be looking at several
>> weeks of coding per file format
>>
>>> one more thing, POI doesnt support reading of .docx file...are u thinking
>>> of any fix for this?
>>
>> You want POI 3.5 for ooxml support, including .docx files. It's in beta, or
>> in a different svn branch
>>
>> Nick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
>> For additional commands, e-mail: dev-help@poi.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Andy Oliver <ac...@gmail.com>.
To be clear we didn't include Password protection not because we
didn't figure out how to reverse engineer (I did) it but because I
didn't want to navigate the legal issues.  Meaning there is a whole
set of US and International regimes involved in encryption.  At the
time these were ever worse than they are now.  I didn't want to figure
it all out just to provide "fool me, lie to me" security.

On Thu, Jul 31, 2008 at 8:08 AM, Nick Burch <ni...@torchbox.com> wrote:
> On Thu, 31 Jul 2008, jigna joshi wrote:
>>
>> thanx for d reply
>> in the new release, the EncryptedDocumentException would be thrown that it
>> is written..
>> but, is there a fix for reading password protected file or just i have to
>> ignore that file..
>
> Reading password protected files is not supported. The documentation has
> finally been released by Microsoft (back in June), so if someone wanted to
> add support it wouldn't be impossible. You'd probably be looking at several
> weeks of coding per file format
>
>> one more thing, POI doesnt support reading of .docx file...are u thinking
>> of any fix for this?
>
> You want POI 3.5 for ooxml support, including .docx files. It's in beta, or
> in a different svn branch
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 31 Jul 2008, jigna joshi wrote:
> thanx for d reply
> in the new release, the EncryptedDocumentException would be thrown that it
> is written..
> but, is there a fix for reading password protected file or just i have to
> ignore that file..

Reading password protected files is not supported. The documentation has 
finally been released by Microsoft (back in June), so if someone wanted to 
add support it wouldn't be impossible. You'd probably be looking at 
several weeks of coding per file format

> one more thing, POI doesnt support reading of .docx file...are u 
> thinking of any fix for this?

You want POI 3.5 for ooxml support, including .docx files. It's in beta, 
or in a different svn branch

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by jigna joshi <jj...@asite.com>.

Hi,
thanx for d reply
in the new release, the EncryptedDocumentException would be thrown that it
is written..
but, is there a fix for reading password protected file or just i have to
ignore that file..

one more thing, POI doesnt support reading of .docx file...are u thinking of
any fix for this?

-- 
View this message in context: http://www.nabble.com/java.lang.NegativeArraySizeException-tp18729532p18753050.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: java.lang.NegativeArraySizeException

Posted by Nick Burch <ni...@torchbox.com>.
On Wed, 30 Jul 2008, jigna joshi wrote:
> poi-3.0.1-FINAL-20070705.jar, poi-contrib-3.0.1-FINAL-20070705.jar,
> poi-scratchpad-3.0.1-FINAL-20070705.jar  jars for reading content of
> documents..
>
> I am getting below exception when I try to read password protected 
> document.

We added detection of password protected word documents to svn trunk about 
a week ago. If you try with a recent nightly build / svn checkout, you'll 
get the much more helpful org.apache.poi.EncryptedDocumentException

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org