<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Boss Thinking &#187; apache</title>
	<atom:link href="http://blog.bossyang.com/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bossyang.com</link>
	<description>photo, technology &#38; life</description>
	<lastBuildDate>Sat, 04 Feb 2012 01:44:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Integrating BIRT with PHP</title>
		<link>http://blog.bossyang.com/integrating-birt-with-php.html</link>
		<comments>http://blog.bossyang.com/integrating-birt-with-php.html#comments</comments>
		<pubDate>Tue, 26 Jan 2010 07:48:50 +0000</pubDate>
		<dc:creator>Boss Yang</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[BIRT]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://blog.bossyang.com/?p=124</guid>
		<description><![CDATA[BIRT(Business Intelligence and Reporting Tools)是以Eclipse為基礎的開源報表系統，可整合Java/J2EE應用程式。目前的版本2.5，穩定通用的版本為2.3.2，已經比我剛開始用的時候又進展了許多。 當時研究BIRT是希望解決PHP應用程式的報表輸出(而且要免費)，在藍鯨平台架構下，使用程式產出報表輸出較不直覺，希望透過整合第三方報表工具來加速開發。坦白說一般企業內寫得報表不怎美觀，MIS人員既要維護又要開發，樣式美化這件事心有餘力不足呀！ 在BIRT 2.1版時，整合PHP使用的是網址列(BIRT Viewer URLs)的方式，也就是將BIRT Viewer佈署到Tomcat之類的應用伺服器，PHP程式將報表檢視網址嵌進來或是轉址即可，可說是相當簡單。如果要傳遞參數，同樣需要透過網址，換句話說是GET。 然而新的方法使用PHP/Java Bridge，可以讓PHP直接呼叫Java類別庫，將輸出直接送回php所在頁面，可以擁有較多的控制。只不過安裝指引實在有點過於簡單，特別是FastCGI的部份，只能說我對PHP運行環境還是一知半解。 我的環境： Windows XP Professional SP3 Apache 2.2.14 PHP 5.3.1 VC9 Thread Safe Tomcat 5.5.28 Microsoft Visual C++ 2008 Redistributable &#8211; x86 9.0.30729.17 光是Apache與PHP的組合就已經讓我反覆試了很久，PHP 5.3.1下載時特別注意VC9是使用Visual Studio 2008編譯而成，因此作業系統要記得安裝Microsoft 2008 &#8230; <a href="http://blog.bossyang.com/integrating-birt-with-php.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="BIRT Project" href="http://eclipse.org/birt/phoenix/" target="_blank"></a><a href="http://blog.bossyang.com/wp-content/uploads/2010/01/phpjava_bridge_birtexample.png"><img class="alignleft size-thumbnail wp-image-119" title="phpjava_bridge_birtexample" src="http://blog.bossyang.com/wp-content/uploads/2010/01/phpjava_bridge_birtexample-150x150.png" alt="" width="150" height="150" /></a></p>
<p>BIRT(Business Intelligence and Reporting Tools)是以Eclipse為基礎的開源報表系統，可整合Java/J2EE應用程式。目前的版本2.5，穩定通用的版本為2.3.2，已經比我剛開始用的時候又進展了許多。</p>
<p>當時研究BIRT是希望解決PHP應用程式的報表輸出(而且要免費)，在<a title="Open BlueWhale" href="http://openbw.org" target="_blank">藍鯨平台</a>架構下，使用程式產出報表輸出較不直覺，希望透過整合第三方報表工具來加速開發。坦白說一般企業內寫得報表不怎美觀，MIS人員既要維護又要開發，樣式美化這件事心有餘力不足呀！</p>
<p>在BIRT 2.1版時，整合PHP使用的是網址列(BIRT Viewer URLs)的方式，也就是將BIRT Viewer佈署到Tomcat之類的應用伺服器，PHP程式將報表檢視網址嵌進來或是轉址即可，可說是相當簡單。如果要傳遞參數，同樣需要透過網址，換句話說是GET。</p>
<p>然而新的方法使用<a title="PHP/Java Bridge" href="http://php-java-bridge.sourceforge.net/pjb/" target="_blank">PHP/Java Bridge</a>，可以讓PHP直接呼叫Java類別庫，將輸出直接送回php所在頁面，可以擁有較多的控制。只不過<a title="PHP/Java Bridge Installation Guide" href="http://php-java-bridge.sourceforge.net/pjb/installation.php" target="_blank">安裝指引</a>實在有點過於簡單，特別是FastCGI的部份，只能說我對PHP運行環境還是一知半解。</p>
<p>我的環境：</p>
<ul>
<li>
<div>Windows XP Professional SP3</div>
</li>
<li>
<div>Apache 2.2.14</div>
</li>
<li>
<div><acronym title="Hypertext Preprocessor">PHP</acronym> 5.3.1 VC9 Thread Safe</div>
</li>
<li>
<div>Tomcat 5.5.28</div>
</li>
<li>
<div>Microsoft Visual C++ 2008 Redistributable &#8211; x86 9.0.30729.17</div>
</li>
</ul>
<p><span id="more-124"></span>光是Apache與PHP的組合就已經讓我反覆試了很久，<a title="PHP for Windows: download" href="http://windows.php.net/download/" target="_blank">PHP 5.3.1下載</a>時特別注意VC9是使用Visual Studio 2008編譯而成，因此作業系統要記得安裝Microsoft 2008 C++ Runtime，奇怪的是，一旦已經先安裝了C++ Runtime再安裝VC6版本就無法正常啟動Apache。最後我還是沒有將Apache設定為CGI模式，那樣PHP必須使用VC9 Non Thread Safe版本，但至少已經可以在php網頁中呼叫BIRT報表了！</p>
<p>由於我是windows環境，因此下載 php-java-bridge_5.5.4.1_documentation.zip，解開後的檔案結構如下，將JavaBridge.war丟到Tomcat目錄中的webapps就會自動解開，解開的JavaBridge資料夾複製到Apache文件目錄下即可，值得注意的是JavaBridge.war內含了一個PHP CGI運行環境(JavaBridge\WEB-INF\cgi)，如果執行test.php，你會發現php版本為5.2.1。<a href="http://blog.bossyang.com/wp-content/uploads/2010/01/phpjava_bridge_cgi_version.png"><img class="alignright size-full wp-image-108" title="phpjava_bridge_cgi_version" src="http://blog.bossyang.com/wp-content/uploads/2010/01/phpjava_bridge_cgi_version.png" alt="JavaBridge PHP CGI version" width="150" height="150" /></a></p>
<ul>
<li>documentation (+)</li>
<li>MONO+NET.STATNALONE (+)</li>
<li>JavaBridge.war</li>
</ul>
<p>瀏覽 http://localhost:8080/JavaBridge 與 http://localhost/JavaBridge，如果沒有錯誤丟出，就表示安裝成功。特別是Report Generator，可以知道Viewer是否安裝正確。這同時隱含JavaBridge.war包含了BIRT runtime類別庫。</p>
<div id="attachment_118" class="wp-caption alignnone" style="width: 160px"><a href="http://blog.bossyang.com/wp-content/uploads/2010/01/phpjava_bridge_example_page1.png"><img class="size-thumbnail wp-image-118" title="phpjava_bridge_example_page" src="http://blog.bossyang.com/wp-content/uploads/2010/01/phpjava_bridge_example_page1-150x150.png" alt="birt example" width="150" height="150" /></a><p class="wp-caption-text">BIRT example</p></div>
<p>實際的撰寫範例在此暫時不多敘述，theserverside上的文件已經寫得很清楚，如果缺少報表範例檔，可以在<a title="BIRT Solution Reports" href="http://eclipse.org/birt/phoenix/examples/solution/" target="_self">官網</a>下載。</p>
<h3><strong>reference</strong></h3>
<ul>
<li>http://www.theserverside.com/tt/articles/article.tss?l=IntegratingBIRTwithPHP</li>
<li>http://eclipse.org/birt/phoenix/deploy/usingPHP.php</li>
<li>http://eclipse.org/birt/phoenix/examples/solution/</li>
</ul>
<h3>Error Message</h3>
<blockquote>
<pre>javax.servlet.ServletException: PHP FastCGI server failed, switching off FastCGI SAPI.
php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.execute(FastCGIServlet.java:417)
php.java.servlet.CGIServlet.handle(CGIServlet.java:401)
php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:427)
php.java.servlet.CGIServlet.doGet(CGIServlet.java:474)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

php.java.servlet.fastcgi.ConnectException
	php.java.servlet.fastcgi.NPChannelFactory.doConnect(NPChannelFactory.java:50)
	php.java.servlet.fastcgi.NPChannelFactory.connect(NPChannelFactory.java:54)
	php.java.servlet.fastcgi.FastCGIServlet$1.connect(FastCGIServlet.java:159)
	php.java.servlet.fastcgi.ConnectionPool$Connection.reopen(ConnectionPool.java:101)
	php.java.servlet.fastcgi.ConnectionPool.openConnection(ConnectionPool.java:200)
	php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.parseBody(FastCGIServlet.java:445)
	php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.doExecute(FastCGIServlet.java:402)
	php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.execute(FastCGIServlet.java:410)
	php.java.servlet.CGIServlet.handle(CGIServlet.java:401)
	php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:427)
	php.java.servlet.CGIServlet.doGet(CGIServlet.java:474)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.io.FileNotFoundException: \\.\pipe\C:\Application\Tomcat55\temp\JavaBridge1726915862995039812.socket (所有的管道例項都在使用中。)
java.io.RandomAccessFile.open(Native Method)
java.io.RandomAccessFile.&lt;init&gt;(Unknown Source)
java.io.RandomAccessFile.&lt;init&gt;(Unknown Source)
php.java.servlet.fastcgi.NPChannelFactory.doConnect(NPChannelFactory.java:48)
php.java.servlet.fastcgi.NPChannelFactory.connect(NPChannelFactory.java:54)
php.java.servlet.fastcgi.FastCGIServlet$1.connect(FastCGIServlet.java:159)
php.java.servlet.fastcgi.ConnectionPool$Connection.reopen(ConnectionPool.java:101)
php.java.servlet.fastcgi.ConnectionPool.openConnection(ConnectionPool.java:200)
php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.parseBody(FastCGIServlet.java:445)
php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.doExecute(FastCGIServlet.java:402)
php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.execute(FastCGIServlet.java:410)
php.java.servlet.CGIServlet.handle(CGIServlet.java:401)
php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:427)
php.java.servlet.CGIServlet.doGet(CGIServlet.java:474)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.bossyang.com/integrating-birt-with-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

