7 Replies Latest reply on Aug 14, 2009 1:17 PM by peterj

    Php on JBoss?

      Hi All,

      I am looking for a guide where i can use Php on JBoss is it possible to do with JBoss?

      Please guide :)

      Regards,
      Sachin Parnami

        • 1. Re: Php on JBoss?
          peterj

          Have a look at these:

          http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4146675#4146675
          http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4123263
          http://www.jboss.org/index.html?module=bb&op=viewtopic&t=125437

          Also, I have had some luck with deploying the Quercus module from Resin (http://www.caucho.com/resin-3.0/quercus/) to JBoss AS, but I still haven't gotten around to fixing the Quercus code to enable database access from within JBoss AS.

          • 2. Re: Php on JBoss?

            I'm glad I found this thread as I'm unable to access MySQL with Quercus even as a default datasource under JBoss AS. I'll have a look at Native and Web in the mean time.

            much thanks,
            Gary

            • 3. Re: Php on JBoss?
              peterj

              What do you mean by 'Native' and 'Web'? If you mean JBoss Web or JBoss Native, neither of those will work either.

              The issue is that Quercus translates database connection requests into a call to the corresponding JDBC driver, but then attempts to cast a Driver object to a DataSource. Works OK if the Driver object also implements the DataSource, but doesn't work so well if ti does not, and in MySQL it does not.

              When you run Quercus within Resin, there is a Resin-specific class that overrides the connection mechanism and looks up a data source from Resin's connection pool and provides that, and then the cast to a DataSource passes.

              As a quick fix kludge, I have considered replacing the connection code with a JNDI lookup of the datasource; of course I'd have to change the my PHP code to pass the datasource JNDI name to the mysql_connect() function. As more correct solution would be to provide a JBoss-specific wrapper for the connection mechanism, like what Resin supplies.

              • 4. Re: Php on JBoss?
                peterj

                Correction. I was using PostgreSQL when I ran into the issues described above. Looking at the Quercus code for MySQL it looks like it uses the DataSource class built into the MySQL JDBC driver if you do not specify another driver class. I'll have to look at this a little more to see what the issues are with MySQL.

                • 5. Re: Php on JBoss?
                  peterj

                  OK, it appears that I was using an older version of Quercus. I just now downloaded Quercus 3.2.1 from http://quercus.caucho.com/ and my PHP apps now work with both PostgreSQL and MySQL on JBoss AS 5.1.0. I still want to provide a mechanism to make use of the connection pools, though. Something for my "todo" list.

                  • 6. Re: Php on JBoss?

                    Have you tried Quercus under JBoss Web? I ask because WordPress doesn't work for me with Web's build of PHP but Quercus lists it as one of their target apps.

                    -Gary

                    • 7. Re: Php on JBoss?
                      peterj

                      I have not tried Quercus under JBoss Web. However, I am currently using Quercus under the server/web configuration of AS 5.1.0 (the web config is basically JBoss Web plus connector support). I did run into one issue. I had this in my *-ds.xml file:

                      <use-java-context>false</use-java-context>


                      This caused an error due to a missing dependency:

                      ** NOT FOUND Depends on 'jboss:service=invoker,type=jrmp' **

                      I had to remove that line from my *-ds.xml file and then add a resource-ref to my web-xml and add in a jboss-web.xml file to get the datasource to be looked up in the ENC.

                      mysql-ds.xml
                      <datasources>
                       <local-tx-datasource>
                       <jndi-name>jdbc/NorthwindDS</jndi-name>
                       <connection-url>jdbc:mysql://localhost:3306/northwind</connection-url>
                       <driver-class>com.mysql.jdbc.Driver</driver-class>
                       <user-name>northwind</user-name>
                       <password>xxxxx</password>
                       <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                       <min-pool-size>5</min-pool-size>
                       <max-pool-size>20</max-pool-size>
                       <idle-timeout-minutes>15</idle-timeout-minutes>
                       <metadata>
                       <type-mapping>mySQL</type-mapping>
                       </metadata>
                       </local-tx-datasource>
                      </datasources>


                      web.xml
                      <?xml version="1.0" encoding="utf-8"?>
                      <web-app xmlns="http://java.sun.com/xml/ns/javaee"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                       version="2.5"
                      >
                       <description>Caucho Technology's PHP Implementation</description>
                       <servlet>
                       <servlet-name>Quercus Servlet</servlet-name>
                       <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
                       <init-param>
                       <param-name>database</param-name>
                       <param-value>jdbc/NorthwindDS</param-value>
                       </init-param>
                       </servlet>
                       <servlet-mapping>
                       <servlet-name>Quercus Servlet</servlet-name>
                       <url-pattern>/index.php/*</url-pattern>
                       </servlet-mapping>
                       <welcome-file-list>
                       <welcome-file>index.php</welcome-file>
                       </welcome-file-list>
                       <resource-ref>
                       <res-ref-name>jdbc/NorthwindDS</res-ref-name>
                       <res-type>javax.sql.DataSource</res-type>
                       <res-auth>Container</res-auth>
                       <res-sharing-scope>Shareable</res-sharing-scope>
                       </resource-ref>
                      </web-app>


                      jboss-web.xml
                      <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
                      <jboss-web>
                       <resource-ref>
                       <res-ref-name>jdbc/NorthwindDS</res-ref-name>
                       <jndi-name>java:jdbc/NorthwindDS</jndi-name>
                       </resource-ref>
                      </jboss-web>