Resin (Quercus) PHP functions do not work when app is compiled

779 views Asked by At

Forgive me if I make any mistakes as this is my first time posting a question.

I'm working on a web app that uses the Resin Embedded Libraries -- It depends heavily on the PHP Engine (Quercus) that is included with Resin. After 3 days of coding I decided it was time to make my first runnable jar for testing on my web server when I came across a strange problem with Quercus -- I assume. Basic PHP Functions such as date, count and var_dump were returning as unknown functions when they were called from the PHP File I requested from the server.

But from within my IDE (Eclipse 3.8) I had no problems what so ever. So going back to the first doc I used, I made a small test app using the bare minimum code and libraries. I followed the instructions for the first tutorial at http://www.caucho.com/resin-3.1/doc/resin-embedding.xtp and I seem too get the exact problem as before.

The main code from the test app

public class Main
{
    public static void main( String[] args )
    {
        ResinEmbed resin = new ResinEmbed();

        HttpEmbed http = new HttpEmbed( 8080 );
        resin.addPort( http );

        WebAppEmbed webapp = new WebAppEmbed( "/", "/var/www" );

        resin.addWebApp( webapp );

        resin.start();
        resin.join();
    }
}

The PHP file I used for testing

<?php var_dump( "Hello World" ); echo date("Y"); ?>

The Exception

com.caucho.quercus.QuercusErrorException: 'date' is an unknown function.
        at com.caucho.quercus.env.Env.error(Env.java:6885)
        at com.caucho.quercus.env.Env.error(Env.java:6408)
        at com.caucho.quercus.expr.CallExpr.evalImpl(CallExpr.java:188)
        at com.caucho.quercus.expr.CallExpr.eval(CallExpr.java:141)
        at com.caucho.quercus.statement.EchoStatement.execute(EchoStatement.java:55)
        at com.caucho.quercus.statement.BlockStatement.execute(BlockStatement.java:105)
        at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:414)
        at com.caucho.quercus.env.Env.evalCode(Env.java:4201)

So I know my issue is not something in my code and I tried playing with project properties and different library versions with no luck. Right now, I'm using the latest version of 4.0.36 with Java version 1.7_25. I've even tried it on multiple computers (All running Linux, since thats all I use now a days). I've been up and down the internet looking for help but no existing threads seemed to even come close to my problem. Would anyone know what would cause this? I hope my question was detailed enough without being too long or too detailed.

If interested, I can also post the repository for my app but the code above gets the same problem as my app even though my app and the example above executes the code in slightly different manners.

UPDATE:

After extensively searching and testing the source for Quercus, I discovered that the problem seems related to not all the modules loading -- ie. Modules add the missing functions -- So I discovered that if I export my project with the option "Copy required libraries into a sub-folder next to the generated JAR" it works just as it does in the IDE. Now, As this is at least a temporary solution to get my project running, I would still like to know how to compile as normal without getting the problem. (58 modules loaded inside the IDE, Only 2 loaded when compiled.)

0

There are 0 answers