|
From: <php...@li...> - 2009-11-25 07:26:41
|
Hi all,
I've set up the PHPJavaBridge standalone as a windows service to
implement lucene search capabilities in my PHP application.
After having started the Bridge with SERVLET_LOCAL:8080 the very first
call to my script fails.
Here's what I can see in my SOAP Client:
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Broken local connection handle fwrite() [<a
href='function.fwrite'>function.fwrite</a>]: send of 6 bytes failed
with errno=10054 Eine vorhandene Verbindung wurde vom Remotehost
geschlossen.</faultstring>
Which means an existing connection has been closed by the remote host.
Every additional call is made with success, only the the first time
fails. I assume the call to java_autoload(..) fails the first time.
here's my PHP function that encapsulates lucene searching:
++++++++++++++++++++++++++++++++++++++++++++++
public function SearchIndex ($maxrows, $searchstring) {
/**
* @desc Search in a lucene index
*
*/
try {
require_once ($this->javabridge_root."/Java.inc");
java_autoload("lucene-core-2.9.1.jar;lucene-analyzers-2.9.1.jar");
$analyzer = new
Java('org.apache.lucene.analysis.standard.StandardAnalyzer');
$indexer = new
Java('org.apache.lucene.search.IndexSearcher',$this->indexfilename);
//Lese alle indizierten Felder aus dem Index aus
$Felder_ind =
java('org.apache.lucene.index.IndexReader$FieldOption')->INDEXED;
$IndexReader =
java('org.apache.lucene.index.IndexReader')->open($this->indexfilename);
$AlleSuchfelder=java_values($IndexReader->getFieldNames($Felder_ind)->toArray());
$IndexReader->close();
//Eine Suche über alle im Index vorhandenen Suchfelder
$parser = new
Java('org.apache.lucene.queryParser.MultiFieldQueryParser',
$AlleSuchfelder,$analyzer);
}
catch (Exception $e) {
throw new Exception(utf8_encode($e));
}
$hits = array();
try {
if ($searchstring) {
$sortfield= new
Java('org.apache.lucene.search.SortField','releasedate',3, true);
$sorter= new
Java('org.apache.lucene.search.Sort',$sortfield );
//$sorter->setSort($sortfield);
$query = $parser->parse($searchstring);
$hits = $indexer->search($query,$sorter );
$num=java_values($hits->length());
//printf("3) Hits: %d\n", $num);
if ($num < $maxrows) {
$maxrows = $num;
}
$soapreturn = array();
for ($i = 0; $i < $maxrows; $i++) {
$found = $hits->doc($i);
$si = new SOAPSearchResult();
$si->wiretextId =
utf8_encode($found->get('wiretextid'));
$soapreturn[] = $si;
}
}
}
catch (Exception $e) {
throw new Exception(utf8_encode($e));
}
if(SF_ENVIRONMENT == 'soap') return $soapreturn;
}
:
|
|
From: <php...@li...> - 2009-11-25 08:49:36
|
Hi,
can you please fetch Java.inc directly from the back end (require_once("
http://localhost:8080/JavaBridge/java/Java.inc") to make sure that your back
end version matches the version of the Java.inc library?
BTW: Why don't you install tomcat to run java as a service?
Regards,
Jost Boekemeier
25.11.2009 08:26 schrieb am <php...@li...>:
Hi all,
I've set up the PHPJavaBridge standalone as a windows service to
implement lucene search capabilities in my PHP application.
After having started the Bridge with SERVLET_LOCAL:8080 the very first
call to my script fails.
Here's what I can see in my SOAP Client:
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Broken local connection handle fwrite() [<a
href='function.fwrite'>function.fwrite</a>]: send of 6 bytes failed
with errno=10054 Eine vorhandene Verbindung wurde vom Remotehost
geschlossen.</faultstring>
Which means an existing connection has been closed by the remote host.
Every additional call is made with success, only the the first time
fails. I assume the call to java_autoload(..) fails the first time.
here's my PHP function that encapsulates lucene searching:
++++++++++++++++++++++++++++++++++++++++++++++
public function SearchIndex ($maxrows, $searchstring) {
/**
* @desc Search in a lucene index
*
*/
try {
require_once ($this->javabridge_root."/Java.inc");
java_autoload("lucene-core-2.9.1.jar;lucene-analyzers-2.9.1.jar");
$analyzer = new
Java('org.apache.lucene.analysis.standard.StandardAnalyzer');
$indexer = new
Java('org.apache.lucene.search.IndexSearcher',$this->indexfilename);
//Lese alle indizierten Felder aus dem Index aus
$Felder_ind =
java('org.apache.lucene.index.IndexReader$FieldOption')->INDEXED;
$IndexReader =
java('org.apache.lucene.index.IndexReader')->open($this->indexfilename);
$AlleSuchfelder=java_values($IndexReader->getFieldNames($Felder_ind)->toArray());
$IndexReader->close();
//Eine Suche über alle im Index vorhandenen Suchfelder
$parser = new
Java('org.apache.lucene.queryParser.MultiFieldQueryParser',
$AlleSuchfelder,$analyzer);
}
catch (Exception $e) {
throw new Exception(utf8_encode($e));
}
$hits = array();
try {
if ($searchstring) {
$sortfield= new
Java('org.apache.lucene.search.SortField','releasedate',3, true);
$sorter= new
Java('org.apache.lucene.search.Sort',$sortfield );
//$sorter->setSort($sortfield);
$query = $parser->parse($searchstring);
$hits = $indexer->search($query,$sorter );
$num=java_values($hits->length());
//printf("3) Hits: %d\n", $num);
if ($num < $maxrows) {
$maxrows = $num;
}
$soapreturn = array();
for ($i = 0; $i < $maxrows; $i++) {
$found = $hits->doc($i);
$si = new SOAPSearchResult();
$si->wiretextId =
utf8_encode($found->get('wiretextid'));
$soapreturn[] = $si;
}
}
}
catch (Exception $e) {
throw new Exception(utf8_encode($e));
}
if(SF_ENVIRONMENT == 'soap') return $soapreturn;
}
:
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
php-java-bridge-users mailing list
php...@li...
https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
|
|
From: <php...@li...> - 2009-11-25 14:09:59
|
Thank you, Jost.
What do you mean by "fetch directly from the backend"? What's the
backend here?
I'm using a symfony PHP framework and can configure the path to the
PHPjavaBridge installation in a variable very easily.
That's the $this->javabridge_root variable. It contains a path to my bridge.
The java.inc is located in that directory.
I'm not allowed to use a tomcat although I'd like to have it.
Jost Boekemeier wrote:
Hi,
can you please fetch Java.inc directly from the back end (require_once("
http://localhost:8080/JavaBridge/java/Java.inc"
<http://localhost:8080/JavaBridge/java/Java.inc>) to make sure that your
back
end version matches the version of the Java.inc library?
BTW: Why don't you install tomcat to run java as a service?
Regards,
Jost Boekemeier
Thorsten Kummer schrieb:
> Hi all,
>
> I've set up the PHPJavaBridge standalone as a windows service to
> implement lucene search capabilities in my PHP application.
> After having started the Bridge with SERVLET_LOCAL:8080 the very first
> call to my script fails.
> Here's what I can see in my SOAP Client:
>
> <faultcode>SOAP-ENV:Server</faultcode>
> <faultstring>Broken local connection handle fwrite() [<a
> href='function.fwrite'>function.fwrite</a>]: send of 6 bytes failed
> with errno=10054 Eine vorhandene Verbindung wurde vom Remotehost
> geschlossen.</faultstring>
>
> Which means an existing connection has been closed by the remote host.
> Every additional call is made with success, only the the first time
> fails. I assume the call to java_autoload(..) fails the first time.
>
> here's my PHP function that encapsulates lucene searching:
> ++++++++++++++++++++++++++++++++++++++++++++++
> public function SearchIndex ($maxrows, $searchstring) {
> /**
> * @desc Search in a lucene index
> * */
> try {
> require_once ($this->javabridge_root."/Java.inc");
> java_autoload("lucene-core-2.9.1.jar;lucene-analyzers-2.9.1.jar");
>
> $analyzer = new
> Java('org.apache.lucene.analysis.standard.StandardAnalyzer');
> $indexer = new
> Java('org.apache.lucene.search.IndexSearcher',$this->indexfilename);
>
> //Lese alle indizierten Felder aus dem Index aus
> $Felder_ind =
> java('org.apache.lucene.index.IndexReader$FieldOption')->INDEXED;
> $IndexReader =
> java('org.apache.lucene.index.IndexReader')->open($this->indexfilename);
>
> $AlleSuchfelder=java_values($IndexReader->getFieldNames($Felder_ind)->toArray());
>
> $IndexReader->close();
>
> //Eine Suche über alle im Index vorhandenen Suchfelder
> $parser = new
> Java('org.apache.lucene.queryParser.MultiFieldQueryParser',
> $AlleSuchfelder,$analyzer);
> } catch (Exception $e) {
> throw new Exception(utf8_encode($e));
> }
> $hits = array(); try {
> if ($searchstring) {
> $sortfield= new
> Java('org.apache.lucene.search.SortField','releasedate',3, true);
> $sorter= new
> Java('org.apache.lucene.search.Sort',$sortfield );
> //$sorter->setSort($sortfield);
> $query = $parser->parse($searchstring);
> $hits = $indexer->search($query,$sorter );
> $num=java_values($hits->length());
>
> //printf("3) Hits: %d\n", $num);
> if ($num < $maxrows) {
> $maxrows = $num;
> }
> $soapreturn = array();
> for ($i = 0; $i < $maxrows; $i++) {
> $found = $hits->doc($i);
> $si = new SOAPSearchResult();
> $si->wiretextId =
> utf8_encode($found->get('wiretextid'));
> $soapreturn[] = $si;
> }
> }
> }
> catch (Exception $e) {
> throw new Exception(utf8_encode($e));
> }
> if(SF_ENVIRONMENT == 'soap') return $soapreturn;
> }
>
> :
>
>
>
|
|
From: <php...@li...> - 2009-11-25 14:28:36
|
> What do you mean by "fetch directly from the backend"?
Use the require command I have given. Please fetch Java.inc directly
from the back end, use
<?php require_once("http://localhost:8080/JavaBridge/java/Java.inc");
...
?>
Or make sure that the version of your Java.inc matches the version of
your back end.
> What's the backend here?
The PHP/Java Bridge application.
> can configure the path to the
> PHPjavaBridge installation in a variable
Which seems to be the problem here. You have probably confused the
versions. Or the Java daemon you have written crashes immediately.
> I'm not allowed to use a tomcat although I'd like to have it.
Interesting. I thought you were running the back end as a daemon.
Regards,
Jost Boekemeier
|