You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Serge Fonville <se...@gmail.com> on 2008/09/29 18:00:36 UTC

Tomcat outputs php to stderr

Hi,
I am developing a ticket system which should use servlets to connect to the
various resources.
Currently I am a php developer and busy to learn JSP/TLD/Servlets
I installed Tomcat 6.0.18 with PHP 5.2.6 on Windows Vista Business (the
production server will be running either Gentoo or CentOS).

Installation went fine, no errors. just one thing I couldn't resolve.
All output generated by php goes directly to the stderr log file instead of
the browser (JSP and servlets work fine)

I used
http://blog.taragana.com/index.php/archive/running-php-5x-on-windows-using-tomcat-4x-or-5x/
 and http://wiki.apache.org/tomcat/UsingPhp to configure the two.

I started reading about listeners, log4j and servlet mappings.
This seemed over the top to me, so I decided to just ask the  question here.

Any help is greatly appreciated

Re: Tomcat outputs php to stderr

Posted by Konstantin Kolinko <kn...@gmail.com>.
How did you install your PHP 5.2.6?

Following the instructions from that "blog.taragana.com" page that
you mentioned, I should have found php5servlet.dll and phpsrvlt.jar
in pecl-5.2.6-Win32.zip.

Those files were there in 5.0.2, but they are absent in 5.2.6.

Also, I cannot find the sources for the servlet in the official 5.0.2
sources .tar.gz file, but some are available here:

http://cvsweb.php.net/viewvc.cgi/pecl/servlet/

Thus far:
1. How you installed them? Maybe there is some version mismatch.
2. Maybe there is some reason why those files are no more bundled
with 5.2.6.
3. If those are the sources - The servlet calls into native servlet.c,
and the rest is php-specific.

>From the sources (servlet.java, rev.1.21):
1. The code is experimental / alpha, so you should be prepared.
2. The servlet seems to be not thread-safe. It stores request, response
in its local fields.

IIRC, "implements javax.servlet.SingleThreadModel" must be added
to such a servlet to avoid concurrent calls (as mentioned in SRV.2.2
chapter of the Java Servlets spec 2.5)
.
Another way would be to mark the service() method of the servlet as
"synchronized" one.

It is hard to believe, that no one noticed these issues, but maybe
those are wrong sources, or I am missing something, or nobody
is using them and thus no one cares. All that is OK for experimental
code.

3. The writing of result is done in method servlet.write(String),
try {
response.getWriter().print(data);
} catch (IOException e) {
 e.printStackTrace(System.err);
}

If you are seeing the output text (as you mentioned), and not exceptions
and their stack traces, then maybe php just does not call this method
and writes all output to the stderr handle?  If so, then may be there were
some changes in the bridge / sapi of PHP, and the code / binaries are
not compatible...


All the above was just out of my curiosity, trying to find the
sources...

Best regards,
Konstantin Kolinko

2008/9/30 Serge Fonville <se...@gmail.com>:
> Thank you so far, I will definitely look into Quercus.
>
> Still, I would like to understand why output is sent to stderr and if it can
> be solved (I recall running PHP and tomcat in the past) without problems
>
>
> On Tue, Sep 30, 2008 at 12:04 AM, Johnny Kewl <jo...@kewlstuff.co.za> wrote:
>
>>
>> ----- Original Message ----- From: "Serge Fonville" <
>> serge.fonville@gmail.com>
>> To: <us...@tomcat.apache.org>
>> Sent: Monday, September 29, 2008 6:00 PM
>> Subject: Tomcat outputs php to stderr
>>
>>
>>
>> Hi,
>>> I am developing a ticket system which should use servlets to connect to
>>> the
>>> various resources.
>>> Currently I am a php developer and busy to learn JSP/TLD/Servlets
>>> I installed Tomcat 6.0.18 with PHP 5.2.6 on Windows Vista Business (the
>>> production server will be running either Gentoo or CentOS).
>>>
>>> Installation went fine, no errors. just one thing I couldn't resolve.
>>> All output generated by php goes directly to the stderr log file instead
>>> of
>>> the browser (JSP and servlets work fine)
>>>
>>> I used
>>>
>>> http://blog.taragana.com/index.php/archive/running-php-5x-on-windows-using-tomcat-4x-or-5x/
>>> and http://wiki.apache.org/tomcat/UsingPhp to configure the two.
>>>
>>> I started reading about listeners, log4j and servlet mappings.
>>> This seemed over the top to me, so I decided to just ask the  question
>>> here.
>>>
>>> Any help is greatly appreciated
>>>
>>
>> Dont do it this way... run PHP on Apache httpd... its the PHP container...
>> and do your servlet stuff in TC... its a good servlet container.
>> Then put Apache httpd in front of TC... read up on the JK connector... and
>> then to the browser its *one system*....
>> Thats how they do it ;)
>>
>> If you insist on wanting the Java PHP layer... Resin is probably the
>> best... they not calling into a PHP engine, they rewrote it in Java...
>> whether they up to date with all modules is the question?
>>
>> Anyway... just trying to show you that you dont have to change a thing...
>> join em ;)
>>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat outputs php to stderr

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
----- Original Message ----- 
From: "Serge Fonville" <se...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, September 30, 2008 1:08 PM
Subject: Re: Tomcat outputs php to stderr


> Thank you so far, I will definitely look into Quercus.
>
> Still, I would like to understand why output is sent to stderr and if it 
> can
> be solved (I recall running PHP and tomcat in the past) without problems

You probably in the wrong mailing list... should be asking the guys that 
made this third party stuff...
But I had a little look look and I cant event find the PECL servlet in the 
current PHP stuff...

This custom servlet, is calling JNI, thats talking to PHP... and it seems 
PHP has no interest, Tomcat guys are into servlets, so I'd say its broken... 
unless you backup to an earlier era...

My guess, the JNI is failing... the stream is getting dumped to standard 
err...

I found this page, where some guy has tried to fix it on his lonesome...
http://chen-lahav-software-thoughts.blogspot.com/

Good luck... looks like no one cares (;

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat outputs php to stderr

Posted by Serge Fonville <se...@gmail.com>.
Thank you so far, I will definitely look into Quercus.

Still, I would like to understand why output is sent to stderr and if it can
be solved (I recall running PHP and tomcat in the past) without problems


On Tue, Sep 30, 2008 at 12:04 AM, Johnny Kewl <jo...@kewlstuff.co.za> wrote:

>
> ----- Original Message ----- From: "Serge Fonville" <
> serge.fonville@gmail.com>
> To: <us...@tomcat.apache.org>
> Sent: Monday, September 29, 2008 6:00 PM
> Subject: Tomcat outputs php to stderr
>
>
>
> Hi,
>> I am developing a ticket system which should use servlets to connect to
>> the
>> various resources.
>> Currently I am a php developer and busy to learn JSP/TLD/Servlets
>> I installed Tomcat 6.0.18 with PHP 5.2.6 on Windows Vista Business (the
>> production server will be running either Gentoo or CentOS).
>>
>> Installation went fine, no errors. just one thing I couldn't resolve.
>> All output generated by php goes directly to the stderr log file instead
>> of
>> the browser (JSP and servlets work fine)
>>
>> I used
>>
>> http://blog.taragana.com/index.php/archive/running-php-5x-on-windows-using-tomcat-4x-or-5x/
>> and http://wiki.apache.org/tomcat/UsingPhp to configure the two.
>>
>> I started reading about listeners, log4j and servlet mappings.
>> This seemed over the top to me, so I decided to just ask the  question
>> here.
>>
>> Any help is greatly appreciated
>>
>
>
> Dont do it this way... run PHP on Apache httpd... its the PHP container...
> and do your servlet stuff in TC... its a good servlet container.
> Then put Apache httpd in front of TC... read up on the JK connector... and
> then to the browser its *one system*....
> Thats how they do it ;)
>
> If you insist on wanting the Java PHP layer... Resin is probably the
> best... they not calling into a PHP engine, they rewrote it in Java...
> whether they up to date with all modules is the question?
>
> Anyway... just trying to show you that you dont have to change a thing...
> join em ;)
>
> Have fun..
>
> ---------------------------------------------------------------------------
> HARBOR : http://www.kewlstuff.co.za/index.htm
> The most powerful application server on earth.
> The only real POJO Application Server.
> See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
> ---------------------------------------------------------------------------
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat outputs php to stderr

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
----- Original Message ----- 
From: "Serge Fonville" <se...@gmail.com>
To: <us...@tomcat.apache.org>
Sent: Monday, September 29, 2008 6:00 PM
Subject: Tomcat outputs php to stderr


> Hi,
> I am developing a ticket system which should use servlets to connect to 
> the
> various resources.
> Currently I am a php developer and busy to learn JSP/TLD/Servlets
> I installed Tomcat 6.0.18 with PHP 5.2.6 on Windows Vista Business (the
> production server will be running either Gentoo or CentOS).
>
> Installation went fine, no errors. just one thing I couldn't resolve.
> All output generated by php goes directly to the stderr log file instead 
> of
> the browser (JSP and servlets work fine)
>
> I used
> http://blog.taragana.com/index.php/archive/running-php-5x-on-windows-using-tomcat-4x-or-5x/
> and http://wiki.apache.org/tomcat/UsingPhp to configure the two.
>
> I started reading about listeners, log4j and servlet mappings.
> This seemed over the top to me, so I decided to just ask the  question 
> here.
>
> Any help is greatly appreciated


Dont do it this way... run PHP on Apache httpd... its the PHP container... 
and do your servlet stuff in TC... its a good servlet container.
Then put Apache httpd in front of TC... read up on the JK connector... and 
then to the browser its *one system*....
Thats how they do it ;)

If you insist on wanting the Java PHP layer... Resin is probably the best... 
they not calling into a PHP engine, they rewrote it in Java... whether they 
up to date with all modules is the question?

Anyway... just trying to show you that you dont have to change a thing... 
join em ;)

Have fun..

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
--------------------------------------------------------------------------- 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat outputs php to stderr

Posted by Gabe Wong <ga...@ngasi.com>.
Hi Serge,
Besides using PHP/Apache, the next best thing is Quercus. More info 
could be found here:
http://quercus.caucho.com/
Regards
Serge Fonville wrote:
> Hi,
> I am developing a ticket system which should use servlets to connect to the
> various resources.
> Currently I am a php developer and busy to learn JSP/TLD/Servlets
> I installed Tomcat 6.0.18 with PHP 5.2.6 on Windows Vista Business (the
> production server will be running either Gentoo or CentOS).
>
> Installation went fine, no errors. just one thing I couldn't resolve.
> All output generated by php goes directly to the stderr log file instead of
> the browser (JSP and servlets work fine)
>
> I used
> http://blog.taragana.com/index.php/archive/running-php-5x-on-windows-using-tomcat-4x-or-5x/
>  and http://wiki.apache.org/tomcat/UsingPhp to configure the two.
>
> I started reading about listeners, log4j and servlet mappings.
> This seemed over the top to me, so I decided to just ask the  question here.
>
> Any help is greatly appreciated
>
>   


-- 
Regards

Gabe Wong
NGASI AppServer Manager
JAVA AUTOMATION and SaaS Enablement for Cloud Computing
http://www.ngasi.com
NEW! FREE Developer account for Hosted version on Amazon EC2


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org