Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:02:23+00:00 2026-05-24T17:02:23+00:00

I am using Quercus in Apache JMeter for simple scripting of tests. I have

  • 0

I am using Quercus in Apache JMeter for simple scripting of tests. I have a requirement to log from PHP using log4j, and on the whole this works well. So I wrote a Quercus module like this:

public class LogFunction extends AbstractQuercusModule {

    private static Logger log = Logger.getLogger(LogFunction.class);

    public void log_str(Env env, String str) {
        log.info(str);
    }
}

Now, I am testing this with the following code:

public class QuercusTest {

private static ScriptEngine engine;

static{     
    //set up Quercus
    ScriptEngineManager manager = new ScriptEngineManager();
    engine = manager.getEngineByName("php");
}

public static void main(String[] args) throws ScriptException{
    engine.eval("<?php log_str('Hello');");
}

}

This throws an exception (as I would expect) because this custom function isn’t registered.

Exception in thread "main" com.caucho.quercus.QuercusErrorException: eval::1: Fatal Error: 'log_str' is an unknown function.
    at com.caucho.quercus.env.Env.error(Env.java:6420)
    at com.caucho.quercus.env.Env.error(Env.java:6306)
    at com.caucho.quercus.env.Env.error(Env.java:5990)
    at com.caucho.quercus.expr.CallExpr.evalImpl(CallExpr.java:198)
    at com.caucho.quercus.expr.CallExpr.eval(CallExpr.java:151)
    at com.caucho.quercus.expr.Expr.evalTop(Expr.java:523)
    at com.caucho.quercus.statement.ExprStatement.execute(ExprStatement.java:67)
    at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:413)
    at com.caucho.quercus.script.QuercusScriptEngine.eval(QuercusScriptEngine.java:134)
    at com.caucho.quercus.script.QuercusScriptEngine.eval(QuercusScriptEngine.java:179)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
    at com.succeed.QuercusTest.main(QuercusTest.java:18)

However, I can’t see how to register this Quercus module with the Java scripting engine. Docs are a bit sparse… Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:02:23+00:00Added an answer on May 24, 2026 at 5:02 pm

    1.

    ScriptEngineManager manager = new ScriptEngineManager();
    engine = manager.getEngineByName("php");
    

    2.

    if( engine instanceof QuercusScriptEngine )
    {
        ((QuercusScriptEngine)engine).getQuercus().addModule(new LogFunction());
    }
    

    This works.
    (quercus-4.0.18-src + resin 4.0)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started playing with Google App Engine using php via Quercus. I'm not
I'm using quercus for appengine. I tried saving a long php string (> 1000
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I have Glassfish 3 server and have added Quercus 4.0.7 to to be able
Using PHP I'd like to compare an actual ip address to part of one,
Using a Microsoft version of SQL, here's my simple query. If I query a
Using android 2.3.3, I have a background Service which has a socket connection. There's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.