Question

It turns out to be pretty easy to get php running in my glassfish application. I've downloaded Quercus 4.0.18 from here: http://caucho.com/download/quercus-4.0.18.war, unpacked the war file and copied the 4 jar files from the WEB-INF/lib to my glassfish/domains/domain1/lib directory.

With the addition of a couple of lines to web.xml I have been able to serve a hello world php file:

<servlet>
        <servlet-name>Quercus Servlet</servlet-name>
        <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Quercus Servlet</servlet-name>
        <url-pattern>*.php</url-pattern>
</servlet-mapping>

My question is what do I need to add to the pom.xml in order to add the required dependencies to my maven project and avoid messing about with unpacking war files etc...? I've not been using maven for long and am generally boggle eyed at anything other than the simplest configuration, so the simpler the answer the better for me.

Thanks.

Was it helpful?

Solution

It is a simple matter of your Maven project expressing a dependency on the 4 JARs that you manually copied into the WEB-INF/lib. Say the 4 JARs that you copied were

  • quercus-A-4.18.jar
  • quercus-B-4.18.jar
  • quercus-C-4.18.jar and
  • quercus-D-4.18.jar

In the dependencies section of your POM you would then add a dependency on these JARs. Something like:

<dependency>
  <groupId>com.caucho.quercus</groupId>    <-- Confirm the correct value
  <artitfactId>quercus-A<artifactId>       <-- Replace with artifacts A - D.
  <version>4.18</version>
</dependency>

What you need to do is locate a Maven repository (at Caucho maybe) that hosts these 4 JARs. If this repository isn't already in your POM (or your settings.xml) you would add it:(From docs)

<repositories>
  <repository>
    <id>Quercus</id>
    <name>Quercus Maven repository</name>
    <url>http://url.to.top.level.of.this.repository</url>
    <layout>default</layout>
  </repository>
</repositories>

On the other hand say a public repository is not available. Then -- as a last resort -- you can place these 4 JARs in your local repository (the one your home directory). This is a workaround if you are the only developer. If you are working with a team that will also need these JARs or you have a continuous integration server that is going to do a build you will want to host a repository on a shared (networked) location.

Of course if you go the route of hosting these JARs you are responsible for keeping them up-to-date.

OTHER TIPS

Caucho has its own maven repository. They explain how to use it on their Wiki.

For the releases, just add this to your pom.xml.

<repositories>
    <repository>
        <id>caucho</id>
        <name>caucho public repo</name>
        <url>http://caucho.com/m2/</url>
    </repository>
</repositories>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top