You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Alexey Manulenko <ma...@rosten.elektra.ru> on 2006/08/23 14:56:07 UTC

Re: Jetspeed2 PHP Bridge under Windows

Hello,

I'll briefly explain how did I  make it to work.
I'll take the following assumtions during the following explanation:

%CATALINA_HOME% - Tomcat/Jetspeed 2.0 installation directory.
For example: C:\Apache Jetspeed 2.0 or C:\Program Files\Apache Jetspeed 2.0

%PHP_HOME% - PHP directory, where files like php.exe and the like are 
resided.
For example: C:\PHP or C:\Program Files\PHP4

You should also create some %WORK_DIR% - a temporary working directory
to follow my explanation.
For example: C:\work.

%WINDIR% is Your Windows OS installation directory.

- I am using Apache Jetspeed 2.0 Derby Embedded installation (could be
configured to use any database,
for example MySQL:
http://mail-archives.apache.org/mod_mbox/portals-jetspeed-user/200605.mbox/%3c004301c678ed$2b4d8240$954012ac@rosten.elektra.ru%3e)
- OS is WindowsXP
- PHP version is an old php-4.2.3-Win32.
- All environment variables (JAVA_HOME, CLASSPATH, PATH) should be properly 
set.
Particulary, make shure, that your %PHP_HOME% is included in PATH
variable and all JAR-s (servlet-api.jar, portlet-api-1.0.jar and the like), 
that will be required
for compilations are in your CLASSPATH.
- php-demo portlet is installed in %CATALINA_HOME%\webapps\php
directory,
- The appropriate php.war file is located in %CATALINA_HOME%\webapps\
directory.
- PHP Demo portlet doesn't work (final assumption :-)):
   When I try to include php-demo portlet in any .psml page in a way
something like:
===================p004.psml==============================
...
        <fragment id="u4-xx6034" type="portlet" name="php::php-demo">
            <property name="row" value="0"/>
            <property name="column" value="0"/>
        </fragment>
 ...
========================================================
I get an error on my portal page:

========================================================
PHP demo Portlet
Portlet is Not Available: php::php-demo
Reason: no php4 in java.library.path
========================================================

and an exception in Tomcat window and logs with following:
========================================================
java.lang.UnsatisfiedLinkError: no php4 in java.library.path
...
    at
org.apache.portals.bridges.php.PHPApplicationPortlet.doView(PHPApplicationPortlet.java:256)
...
========================================================

I performed the following steps to make the PHP Bridge and php-demo portlet 
work:

1) Move php.war file from %CATALINA_HOME%\webapps directory to your
temporary work directory %WORK_DIR%.
This will automatically undeploy the existing /php context (but don't worry
you'll get it back rather soon :)).
Then extract  the php.war file content into your temporary/work directory:
%WORK_DIR%\php.

2) Move /css, /hosts, /sql folders and test.php file form %WORK_DIR%\php
directory to %WORK_DIR%\php\WEB-INF directory.

3) You will need phpsrvlt.dll and phpsrvlt.jar files. They are located in 
/sapi subdirectory
of PHP installation.
Copy these two files to your %PHP_HOME% directory.
Copy phpsrvlt.dll to %WINDIR%/system32 directory.

4) You need to modify  %WORK_DIR%/php/WEB-INF/lib/phpportlet-1.0.jar file.
Move this file to your %WORK_DIR% directory and extract the contents to
the appropriate directory: %WORK_DIR%\phpportlet-1.0.
Go to %WORK_DIR%\phpportlet-1.0/com/itgroundwork/portlet/php directory and 
change
reflect.properties and servlet.properties files the following way:
===========reflect.properties============
library=phpsrvlt
==================================

===========servlet.properties============
library=phpsrvlt
==================================

Go back to %WORK_DIR%\phpportlet-1.0 directory and do the following in the 
command
line: "jar cvf ../phpportlet-1.0.jar ."
(do not forget the space and period at the end :))
You should get phpportlet-1.0.jar in your %WORK_DIR% directory.
%WORK_DIR%\phpportlet-1.0.jar
Copy this file to %WORK_DIR%\php\WEB-INF\lib and make the new php.war file:
type "jar cvf ../php.war ." from %WORK_DIR%\php directory.
Copy this new php.war file to Jetspeed deploy directory:
%CATALINA_HOME%/webapps/jetspeed/WEB-INF/deploy directory.
This will re-deploy your new application.

At this point things might be getting in order and PHP Bridge and php-demo
portlet can start working.

If they are not (like in my case) then most likely you could be getting
the following error at the portal page:

============================
PHP demo Portlet
  Portlet is Not Available: php::php-demo
Reason: startup
============================

And the following in Tomcat window and/or logs:
===============================================================
...
java.lang.UnsatisfiedLinkError: startup
    at com.itgroundwork.portlet.php.servlet.startup(Native Method)
    at com.itgroundwork.portlet.php.servlet.init(servlet.java:205)
    at
org.apache.portals.bridges.php.PHPApplicationPortlet.doView(PHPApplicationPortlet.java:256)
...
===============================================================

In this case you should perform some additional steps given below:

5) Copy phpsrvlt.jar to your %WORK_DIR% directory and extract the
contents of it into %WORK_DIR%\phpsrvlt directory.
Copy %WORK_DIR%/phpsrvlt/net directory and all of it's subdirectories from
%WORK_DIR%/phpsrvlt/ to %WORK_DIR%/phpportlet-1.0 directory.
You should get the following structure of your %WORK_DIR%/phpportlet-1.0
directory:
===============================================================
...
|
phpportlet-1.0
|---com
|    |------itgroundwork
|              |-----portlet
|                      |--php
|---META-INF
|---net
    |---php
===============================================================

6) Get servlet.java either from
cvs.php.net/viewvc.cgi/php4.fubar/sapi/servlet/
or from cvs.php.net/viewvc.cgi/php4.unused/sapi/servlet/.
I used the latest version 1.22 of servlet.java from php4.fubar branch.
Modify this file as follows:
- Change "enum" to "enumeration", since the former is a keyword :-)
- Add some additional lines before SAPI callbacks.
The modified file shoul be as follows:
==========================servlet.java==============================
/*
   +----------------------------------------------------------------------+
   | PHP Version 4                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2002 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.txt.                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Author: Sam Ruby (rubys@us.ibm.com)                                  |
   +----------------------------------------------------------------------+
*/

/* $Id: servlet.java,v 1.22 2003/06/23 01:27:42 imajes Exp $ */

package net.php;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;

import java.lang.reflect.Method;

public class servlet extends HttpServlet {
  char slash = System.getProperty("file.separator").charAt(0);

  HttpServletRequest  request;
  HttpServletResponse response;
  ServletInputStream  stream;

  static int startup_count = 0;

  protected boolean display_source_mode = false;
  private Method addHeader;

  // Native methods

  public native void startup();
  public native long define(String name);
  public native void send(String  requestMethod,
                          String  queryString,
                          String  pathInfo,
                          String  pathTranslated,
                          String  contentType,
                          int     contentLength,
                          String  authUser,
                          boolean display_source_mode
                         );
  public native void shutdown();

  //itgroundwork "addons"

  private String adjUri;
  private String adjQuery;
  private String authUser;
  private boolean bUseInternalPage;
  private StringBuffer phpPage;

  public void setAdjustedURI(String s)
  {
      adjUri = s;
  }

  public void setAdjustedQuery(String s)
  {
      adjQuery = s;
  }

  public void setAuthenticatedUser(String s)
  {
      authUser = s;
  }

  public void setUseInternalPage()
  {
      bUseInternalPage = true;
      phpPage = new StringBuffer();
  }

  public StringBuffer getSourcePage()
  {
      return phpPage;
  }

  // SAPI Callbacks

  public String readPost(int bytes) {
    String result;

    if (!request.getMethod().equals("POST")) {
      result = request.getQueryString();
    } else {
      Enumeration enumeration = request.getParameterNames();
      String concat = "";
      result = "";

      while (enumeration.hasMoreElements()) {
        String name  = (String)enumeration.nextElement();
        String value = request.getParameter(name);

        try {
          result += concat + name + "=" + URLEncoder.encode(value, "UTF-8");
        }

        catch (Exception e) {
          e.printStackTrace(System.err);
        }

        concat = "&";
      }
    }

    if (result == null) return "";

    return result;
  }

  public String readCookies() {
     reflect.setResult(define("request"),  request);
     reflect.setResult(define("response"), response);
     reflect.setResult(define("PHP_SELF"), request.getRequestURI());

     return request.getHeader("cookie");
  }

  public void header(String data) {
    // try to send the header using the most specific servlet API
    // as possible (some servlet engines will add a content type
    // header unless the setContentType method is called).
    try {
      if (data.startsWith("Content-type: ")) {
        response.setContentType(data.substring(data.indexOf(" ") + 1));
      }

      else if (data.startsWith("Location: ")) {
        response.sendRedirect(data.substring(data.indexOf(" ") + 1));
      } else if (data.startsWith("HTTP/1")) {
       return; // this one is added from servlet container (Tomcat 4.1), we
have to check for others
      }

      else {
        int colon = data.indexOf(": ");

        if (colon > 0) {
          try {
            addHeader.invoke(response, new Object[]
              { data.substring(0, colon), data.substring(colon + 2) } );
          }

          catch (Exception e) {
            e.printStackTrace(System.err);
          }
        }

        else {
          write(data);
        }
      }
    }

    catch (IOException e) {
      e.printStackTrace(System.err);
    }
  }

  public void write(String data) {
    try {
      response.getWriter().print(data);
    }

    catch (IOException e) {
      e.printStackTrace(System.err);
    }
  }

  // Servlet interface

  public void init(ServletConfig config)
  throws ServletException {
    super.init(config);

    // first time in, initialize native code
    if (0 == startup_count++) {
      reflect.loadLibrary("servlet");
      startup();
    }

    // try to find the addHeader method (added in the servlet API 2.2)
    // otherwise settle for the setHeader method

    try {
      Class c = Class.forName("javax.servlet.http.HttpServletResponse");
      Method method[] = c.getDeclaredMethods();

      for (int i = 0; i < method.length; i++) {
        if (method[i].getName().equals("addHeader")) {
          addHeader = method[i];
          break;
        }

        if (method[i].getName().equals("setHeader")) {
          addHeader = method[i];
        }
      }
    }

    catch (Exception e) {
      e.printStackTrace(System.err);
    }
  }

  public void service(HttpServletRequest request, HttpServletResponse
response, String contextPath)
  throws ServletException {
    this.request  = request;
    this.response = response;

    send(request.getMethod(),
         request.getQueryString(),
         request.getRequestURI(),
         contextPath,
         request.getContentType(),
         request.getContentLength(),
         request.getRemoteUser(),
         display_source_mode
        );

    try {
      if (stream != null) stream.close();
    }

    catch (IOException e) {
      throw new ServletException(e.toString());
    }
  }

  public void service(HttpServletRequest request, HttpServletResponse
response)
  throws ServletException {
    String servletPath = request.getServletPath();
    String contextPath = getServletContext().getRealPath(servletPath);

    service(request, response, contextPath);
  }

  public void destroy() {
    if (0 == --startup_count) shutdown();
    super.destroy();
  }
}
===============================================================
Complie this with "javac servlet.java", making sure that all the required 
JAR-s (like
servlet-api.jar, and etc) are in your CLASSPATH directories,
get servlet.class and put it into %WORK_DIR%/phpportlet-1.0/net/php 
directory.

Go to %WORK_DIR%/phpportlet-1.0 directory and make the new 
phpportlet-1.0.jar by typing
"jar cvf ../phpportlet-1.0.jar ." in the command line.

7) Modify the %WORK_DIR%/php/WEB-INF/lib/portals-bridges-php-1.0.jar
Move this file to %WORK_DIR% directory and extract the contents to
the appropriate directory: %WORK_DIR%/portals-bridges-php-1.0.
You will need to modify the
%WORK_DIR%/portals-bridges-php-1.0/org/apache/portals/bridges/php/PHPApplicationPortlet.class 
file.
Download the latest version of PHPApplicationPortlet.java from
svn.apache.org/viewvc/portals/bridges/trunk/php/src/java/org/apache/portals/bridges/php/
Change "com.itgroundwork.portlet.php.servlet" to "net.php.servlet" on lines 
74 and 254.
The modified file should be as follows:
==========================PHPApplicationPortlet.java==========================
/*
 * Copyright 2000-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.portals.bridges.php;

import java.io.IOException;
import java.security.Principal;
import java.util.Enumeration;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;
import javax.portlet.PortletURL;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.portals.bridges.common.ScriptPostProcess;
import org.apache.portals.bridges.common.ServletContextProvider;
import org.apache.portals.bridges.php.PHPParameters;

/**
 * This portlet is executes a PHP application in a portlet.
 *
 * @author <a href="mailto:rogerrut@apache.org">Roger Ruttimann</a>
 * @version $Id$
 */

public class PHPApplicationPortlet extends GenericPortlet {

 /**
  * INIT parameters required by the PHP Portlet:application and 
ServletContextProvider
  *
     * Name of class implementing {@link PHPServletContextProvider}
     */
    public static final String PARAM_SERVLET_CONTEXT_PROVIDER = 
"ServletContextProvider";


 /**
  * Start page for this portlet it must be the path to the script (e.g 
hosts/index.php)
  */
 public static final String START_PAGE = "StartPage";


    // Local variables

 private ServletContextProvider servletContextProvider;
    private static final Log log = 
LogFactory.getLog(PHPApplicationPortlet.class);

    // Servlet INFO needed for portlet

    ServletConfigImpl servletConfig = null;

    // PHP engine
    net.php.servlet phpServletImpl = null; 
//com.itgroundwork.portlet.php.servlet phpServletImpl = null;

     // INIT Parameters
    private String startPage = null;

    // caching status
    private boolean bUseCachedParameters = false;
    private String lastContextPath = null;
    private String lastQuery = null;
    private String lastURI = null;

    //ID to identify portlet
    private String portletID = null;

    public void init(PortletConfig config) throws PortletException
    {
        super.init(config);

        // Initialize config
        servletConfig = new ServletConfigImpl(config);

        //Get the INIT PARAMETERS for this portlet. If the values are 
missing
        // throw an exception
        startPage           = config.getInitParameter(START_PAGE);
        String contextProviderClassName = 
config.getInitParameter(PARAM_SERVLET_CONTEXT_PROVIDER);

        if (startPage == null)
            throw new PortletException("Portlet " + config.getPortletName()
                    + " is incorrectly configured. Init parameter "
                    + START_PAGE + " not specified");

        if (contextProviderClassName == null)
            throw new PortletException("Portlet " + config.getPortletName()
                    + " is incorrectly configured. Init parameter "
                    + PARAM_SERVLET_CONTEXT_PROVIDER + " not specified");


        if (contextProviderClassName != null)
        {
            try
            {
                Class clazz = Class.forName(contextProviderClassName);
                if (clazz != null)
                {
                    Object obj = clazz.newInstance();
                    if (ServletContextProvider.class.isInstance(obj))
                        servletContextProvider = (ServletContextProvider) 
obj;
                    else
                        throw new PortletException("class not found");
                }
            } catch (Exception e)
            {
                if (e instanceof PortletException)
                    throw (PortletException) e;
                e.printStackTrace();
                throw new PortletException("Cannot load", e);
            }
        }
     }

    /**
     * processAction()
     * Checks action initiated by the php portlet (invoking other php 
scripts)
     * @param actionRequest
     * @param actionResponse
     * @throws PortletException
     * @throws IOException
     */
    public void processAction(ActionRequest actionRequest, ActionResponse 
actionResponse) throws PortletException, IOException
 {
     String phpParameter = 
actionRequest.getParameter(PHPParameters.ACTION_PARAMETER_PHP);
      /*
      * If the phpParameter is not empty create a PHPParameters object and 
attach it to the session
      */
     if ( phpParameter != null && phpParameter.length() > 0)
     {
      // Perl Parameter Object
      PHPParameters phpScript = new PHPParameters();

      // Separate the values before and after the Query Mark ?
      int ixQuery = phpParameter.indexOf('?');
      if ( ixQuery != -1)
      {
       phpScript.setScriptName(phpParameter.substring(0,ixQuery));

       String queryArguments = phpParameter.substring(ixQuery+1);
       System.out.println("ProcessRequest -- Script " + 
phpParameter.substring(0,ixQuery) + " Query string " + queryArguments);

       int ixQuerySeparator = queryArguments.indexOf('&');
       while ( ixQuerySeparator != -1)
       {
        phpScript.addQueryArgument(queryArguments.substring(0, 
ixQuerySeparator));
        queryArguments = queryArguments.substring(ixQuerySeparator+1);
        ixQuerySeparator = queryArguments.indexOf('&');
       }

       phpScript.addQueryArgument(queryArguments);

       // Add the PerlParameters to the session
       actionRequest.getPortletSession().setAttribute(PHPParameters.PHP_PARAMETER, 
phpScript, PortletSession.APPLICATION_SCOPE);
      }
      else
      {
       // No query string just the script name
       phpScript.setScriptName(phpParameter);

       // Get all the parameters from the request and add them as query 
arguments
       Enumeration names = actionRequest.getParameterNames();
       String name, value;
       while (names.hasMoreElements())
       {
        name = (String)names.nextElement();
        // ACTION_PARAMETER_PHP already processed just ignore it
        if (name.compareToIgnoreCase(PHPParameters.ACTION_PARAMETER_PHP) != 
0)
        {
         value = actionRequest.getParameter(name);

            phpScript.addQueryArgument(name + "=" + value);
        }
       }
       // Add the PerlParameters to the session
       actionRequest.getPortletSession().setAttribute(PHPParameters.PHP_PARAMETER, 
phpScript, PortletSession.APPLICATION_SCOPE);
       }
     }
 }

    /**
     * doView
     * Renders a PHP file in the portlet.
     * The script parameters are in a PHPParameters object that is passed in 
the session
     */

    public void doView(RenderRequest request, RenderResponse response)
    throws PortletException, IOException
 {
     /*
      *  Extract the PHPParameter object from the session. If this is not 
provided use the values for startPage and application from the INIT 
Parameters
      */
     String reqQuery;
     String phpScript;

     PHPParameters phpParam = null;
     try
  {
      phpParam = 
(PHPParameters)request.getPortletSession().getAttribute(PHPParameters.PHP_PARAMETER, 
PortletSession.APPLICATION_SCOPE);
  }
     catch (Exception e )
  {
      phpParam = null;
  }

     if (phpParam != null)
     {
      // We got real parameters
      bUseCachedParameters = false;
      reqQuery = phpParam.getQueryString();
      phpScript = phpParam.getScriptName();
     }
     else
     {
      /*
       * No parameters were send to this page. Either it is the initial 
invocation (use init param) or
       * iit was a refresh (use cached arguments)
       *
       * Setting the bUseCacheParameters means that nothing was provided 
from outside
       */
      bUseCachedParameters = true;
      reqQuery = "";
      phpScript = this.startPage;
     }

       //ServletContext  servletContext = 
servletContextProvider.getServletContext(this);
     HttpServletRequest httpRequest  = 
servletContextProvider.getHttpServletRequest(this, request);
     HttpServletResponse httpResponse = 
servletContextProvider.getHttpServletResponse(this, response);

     //initialize PHP engine
     if ( phpServletImpl == null)
     {
      try
   {
      phpServletImpl = new net.php.servlet(); //phpServletImpl = new 
com.itgroundwork.portlet.php.servlet();
      if (phpServletImpl != null )
       phpServletImpl.init(servletConfig);
   }
      catch(ServletException se)
   {
       httpResponse.getWriter().println("<p><b>Initializationof PHP servlet 
failed!</b> Error: " + se.getMessage() + "</p>");
   }
     }


     // Make sure we have an user
       String userName = "anon"; //default not logged in
     Principal userPrincipal = request.getUserPrincipal();
     if (userPrincipal != null )
      userName = userPrincipal.getName();

        boolean bShowInfoPage = false;
        String cookieValue = null;

         // Build the context path
        String contextPath =  request.getContextPath();
        PortletContext portletApplication = getPortletContext();
        String path = portletApplication.getRealPath("/WEB-INF");
        String rootContextPath = path + "/";

        /*
         * At this point we have all the information to run the PHP servlet:
         *   rootContextPath contains the file path to the 
PortletApplication root (e.g /home/user/tomcat/webapps/MyApplication/ )
         *   phpScript    php script to execute. Includes the full path to 
the application (e.g hosts/index.php)
         *   reqQuery    Query arguments passed to the scripts
         */

        // Run parameters
        String runURI, runQuery, runContext;

        // First time call or invoked from another portlet
        if ( bUseCachedParameters == true)
        {
         //If it is the first call create an URI
         if ( lastURI == null || lastURI.length() == 0)
         {
          // Build the URI with the start page and the context
          lastURI = contextPath + "/" + phpScript;
          lastContextPath = rootContextPath + phpScript;
         }

         // Assign run values
         runURI = lastURI;
         runQuery = lastQuery;
         runContext = lastContextPath;
        }
        else
        {
   // New request for this portlet render it for the new content
   String adjURI = contextPath + "/" + phpScript;

   String phpContext = rootContextPath + phpScript;

   // Assign run values
         runURI = adjURI;
         runQuery = reqQuery;
         runContext = phpContext;
        }

  // Invoke the PHP servlet and run it
  try
  {
   if (phpServletImpl != null )
   {
        if (runQuery == null )
         runQuery = "";

        //  Call into the php library.
        // Cache the page in the servlet and don't write the output to the 
response since some post processing
        // is needed before the page can be send back to the client
        phpServletImpl.setUseInternalPage();

        // Set the servlet parameters
     phpServletImpl.setAdjustedURI(runURI);
     phpServletImpl.setAuthenticatedUser(userName);
     phpServletImpl.setAdjustedQuery(runQuery);

     // execute the PHP script
     phpServletImpl.service(httpRequest, httpResponse, runContext);

     //Save last executed request info so that we remember when it was last 
called
     lastQuery = runQuery;
     lastContextPath = runContext;
     lastURI = runURI;

     //PostProcess:
     // replace all relative links with actions

     //Any HREFs and Form actions should be extended with the ActionURL
     PortletURL actionURL = response.createActionURL();

     // Get the buffered page from the PHP servlet
     StringBuffer page = phpServletImpl.getSourcePage();

     // Call into the PostProcess object which is the same for PERL and 
other script engine
     // supported in the future.
     ScriptPostProcess processor = new ScriptPostProcess();
     processor.setInitalPage(page);
     processor.postProcessPage(actionURL, 
PHPParameters.ACTION_PARAMETER_PHP);
     String finalPage = processor.getFinalizedPage();

           //Write the page to the HttpResponse
     httpResponse.getWriter().println(finalPage);
   }
   else
   {
            httpResponse.getWriter().println("<br/><b>Error in PHP servlet. 
Couldn't create instance of com.itgroundwork.portlet.php.servlet. Make sure 
the jar is included in the same app as the portas-bridges-php jar 
file</b>" );
   }
  }
  catch( ServletException se)
  {
   httpResponse.getWriter().println("<P><B>Error in PHP servlet.Servlet 
Exception: " + se.getMessage() + "</B>RunQuery=" + runQuery+ " RunContext=" 
+ runContext + " RunURI=" + runURI + " </P><BR>");
   throw new PortletException(se);
  }
  catch (IOException e)
  {
   httpResponse.getWriter().println("<P><B>Error in PHP servlet. IO 
Exception " + e.getMessage() + "</B>RunQuery=" + runQuery+ " RunContext=" + 
runContext + "Run URI=" + runURI + "</P><BR>");
  }
 }
}
=======================================================================
Complie this with "javac PHPApplicationPortlet.java", making sure that all 
the required JAR-s (like
servlet-api.jar, portlet-api-1.0.jar and etc) are in your CLASSPATH 
directories,
get PHPApplicationPortlet.class and put it into 
%WORK_DIR%/portals-bridges-php-1.0/org/apache/portals/bridges/php
subdirectory.

Go to %WORK_DIR%/portals-bridges-php-1.0 directory and make the new 
portals-bridges-php-1.0.jar by typing
"jar cvf ../portals-bridges-php-1.0.jar ." in the command line.

8) Copy the two new files portals-bridges-php-1.0.jar and 
phpportlet-1.0.jar, that you've just created
from %WORK_DIR% directory to %WORK_DIR%\php\WEB-INF\lib directory.

Make the new php.war by typing in the command line from %WORK_DIR%\php 
directory:
"jar cvf ../php.war ."

9) Copy the new php.war file from your temporary %WORK_DIR% directory to
%CATALINA_HOME%/webapps/jetspeed/WEB-INF/deploy

10) You can now place your .php files that are needed to be displayed into
%CATALINA_HOME%/webapps/php/WEB-INF directory.
The starting page is specified in the following section of
%CATALINA_HOME%/webapps/php/WEB-INF/portlet.xml file:
===============================portlet.xml===================================
...
    <init-param>
      <name>StartPage</name>
      <value>hosts/index.php</value>
    </init-param>
...
=========================================================================

Hope this helps. :-)

I haven't tried this with PHP5, but these aren't seem to be a problem:
http://blog.taragana.com/index.php/archive/jsp-servlet-php-integration-options/
http://blog.taragana.com/index.php/archive/running-php-5x-on-windows-using-tomcat-4x-or-5x/

Keep in mind that there are still some major drawbacks of using the PHP 
bridge with Jetspeed 2 and with
integrating Java with PHP in general. Stability is one of them is. I've got 
a simple "Telephone Book" PHP application,
which selects records from database via ODBC... The portal just crashes 
without any warnings and logging when
I try to get too much records too frequently...
If you can do something with it please let me know :-)

Best regards,
Alexey

----- Original Message ----- 
From: "Roberto Pagani" <r....@inwind.it>
To: "manl" <ma...@rosten.elektra.ru>
Sent: Tuesday, August 22, 2006 5:10 PM
Subject: Jetspeed2 PHP Bridge under Windows


Hi Alexey
I'm very intrested to find a solution to setup jetspeed2 php bridge under
Windows systems.
Could you give me more information about Your solution?

Thank You in advance.

Best Regards,

Roberto Pagani
Student at Department of Computer Engineering
University of Parma
Italy





Hello all,

I finally figured out how to make the Subject work on Windows system for
PHP4...
I have noticed that Jira issues PB-18
http://issues.apache.org/jira/browse/PB-18 is still UNRESOLVED...
I found out how to solve this problem without downloading any packages from
itgroungwork and without waiting
until www.itgroundwork.org/developer/download server to be "alive"...
If someone need the solution I can post it here.
Does anybody need it?

Thank you in advance.

Best regards,
Alexey




___________________________________________________________________
Mutui a tassi scontati da 30 banche. Richiedi online e risparmia.. Servizio
gratuito.
http://click.libero.it/mutuionline2





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org