Mantis - Quercus
Viewing Issue Advanced Details
3876 minor always 02-04-10 15:02 02-04-10 15:35
domdorn  
ferg  
normal  
closed 4.0.4  
fixed  
none    
none 4.0.4  
0003876: java_bean and jndi_lookup don't work in glassfish v3
java_bean and jndi_lookup don't work in glassfish v3.

Also, those methods are only in full resin.jar (13M) and are highly dependent on resin app server.

this code prints the following, when having resin.jar, resin-kernel.jar and qercus.jar in /WEB-INF/lib

$arr = Array(
      "java"
    , "java_class"
    , "jndi_lookup"
    , "quercus_get_request"
    , "quercus_get_bean"
    , "quercus_get_beans"
    , "quercus_get_servlet_context"
    , "quercus_var_dump"
    , "resin_var_dump"
    , "java_bean"
    , "java_beans"

);




foreach($arr as $values)
{
    echo "function: $values: ";
    echo var_dump ( function_exists($values));
    echo "
\n";

}

result:
function: java: bool(true)
function: java_class: bool(true)
function: jndi_lookup: bool(true)
function: quercus_get_request: bool(true)
function: quercus_get_bean: bool(false)
function: quercus_get_beans: bool(false)
function: quercus_get_servlet_context: bool(true)
function: quercus_var_dump: bool(false)
function: resin_var_dump: bool(true)
function: java_bean: bool(true)
function: java_beans: bool(false)

However, lookup of java_beans registered with CDI do not work as expected:
echo "aaa";
$object = java_bean("testBean");
var_dump($object);
print_r($object);
echo "<hr/>";

echo "bbb";
$object = jndi_lookup("java:app/testBean");
var_dump($object);
print_r($object);
echo "<hr/>";
echo "ccc";
$beanManager = jndi_lookup("comp/BeanManager");
var_dump($beanManager);


echo "eeee";
$object = my_java_bean("testBean");
echo "
";
echo "var_dump: " . var_dump($object);
echo "
";
echo "print_r : " . print_r($object);
echo "
";
echo $object->getMessage();

echo "<hr/>";

prints:
aaaNULL bbbNULL cccNULL eeee
var_dump: resource(com.dominikdorn.lyrix.TestBean@18481697)
print_r : resource(com.dominikdorn.lyrix.TestBean@18481697)1
Hello World

code of my_java_bean() is:
function my_java_bean($name)
{
    $beanManager = quercus_get_servlet_context()->getAttribute("javax.enterprise.inject.spi.BeanManager");
    $beans = $beanManager->getBeans($name);
    if($beans == null || count($beans) < 1)
        return null;
    $object = $beanManager->getReference($beans[0], $beans[0]->getClass(), $beanManager->createCreationalContext($beans[0]));
    return $object;
}


I'm using latest trunk (rev. 6727)



Notes
(0004414)
ferg   
02-04-10 15:35   
Thanks for the bug report. I've removed the dependencies. The ResinModule will still remain in the resin.jar, which is fine because resin.jar can be used in other app servers.