Zend/Lucene issue

I’m having probs with Lucene (just grabbed the latest ZF), I’ve traced it a little, and it seems to be a file locking problem. $index->addDocument($doc); in the script below (more or less copy pasted from the docs) throws an exception from a destructor (ie useless). I removed an @ and vardumped the file names in the code that was causing it (constructor in Zend_Search_Lucene_Storage_File_Filesystem) to get the o/p below.

Anyone experienced this? Got any ideas on how to solve (even tmp patches?)?


require 'Zend/Search/Lucene.php';
$index = Zend_Search_Lucene::create('my-index');
$doc = new Zend_Search_Lucene_Document();
// Store document URL to identify it in the search results
$doc->addField(Zend_Search_Lucene_Field::Text('url', 'xxx'));
// Index document contents
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', 'some blah bla bl b'));
// Add document to the index
$index->addDocument($doc);


string(27) "my-index/read.lock.file
" string(25) "my-index/segments.gen
" string(28) "my-index/write.lock.file
" string(23) "my-index/segments_4
" string(25) "my-index/segments.gen
" string(23) "my-index/segments_5
" string(28) "my-index/write.lock.file
" string(25) "my-index/segments.gen
" string(23) "my-index/segments_5
" string(19) "my-index/_4.fdx
" string(19) "my-index/_4.fdt
" string(35) "my-index/optimization.lock.file
" string(19) "my-index/_4.fnm
"
Warning: fopen(my-index/_4.fnm) [function.fopen]: failed to open stream: No such file or directory in C:\\wamp\\www\	est\\Zend\\library\\Zend\\Search\\Lucene\\Storage\\File\\Filesystem.php on line 62

Fatal error: Exception thrown without a stack frame in Unknown on line 0

The above is from Win7/WAMP, but it’s the same on Ubuntu, php 5.3 in both cases.

I’d say that is indeed it, thanks rajug.

Is it because of the path given relative?

Zend_Search_Lucene::create() requires an absolute path
Pass a relative path to Zend_Search_Lucene::create(), which is the location of the Lucene index. During shutdown the destructor of a class in Zend Lucene will try to write out the index if it was modified. Since PHP resets the current working directory to / on some SAPIs (e.g. apache) writing the index will fail because the relative path now points to a different location. Thus Zend Lucene throws an Exception without a stack frame because it took place during shutdown.

I setup zend and test example search lucene. But have error follow:
Fatal error: Exception thrown without a stack frame in Unknown on line 0
Can you help me?
Thanks