From: <php...@li...> - 2012-07-11 22:53:04
|
Hello, I am trying to use the bridge to connect to an EJB module, which exposes a standard bean interface, but i have difficulties using the context lookup in the php to get hold on my implemented service. I have an remote interface IPHPBackend, which is implemented by one service class (stateless bean) I can clearly see the enterprise bean in netbeans, and in the glassfish Modules and components list after deployement, as PHPBackend. When deploying glassfish tells me: NFO: EJB5181:Portable JNDI names for EJB PHPBackend: [java:global/FspBackendEE-ejb/PHPBackend, java:global/FspBackendEE-ejb/PHPBackend!fsp.service.IPHPBackend] INFO: EJB5182:Glassfish-specific (Non-portable) JNDI names for EJB PHPBackend: [fsp.service.IPHPBackend#fsp.service.IPHPBackend, fsp.service.IPHPBackend] I have also deployed the java bridge war, so now i have two applications deployed, my ejb module + the bridge. Now, i have written a short test application, as you can see i tried a lot of options, but i allways get something like: Array ( [javax.naming.Context.PROVIDER_URL] => iiop://localhost:3700 [javax.naming.Context.INITIAL_CONTEXT_FACTORY] => com.sun.enterprise.naming.SerialInitContextFactory ) Exception: [[o:NamingException]:"javax.naming.NamingException: Lookup failed for 'java:global/FspBackendEE-ejb/fsp.service.PHPBackend' in SerialContext[myEnv={javax.naming.Context.INITIAL_CONTEXT_FACTORY=com.sun.en terprise.naming.SerialInitContextFactory, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContext Factory, javax.naming.Context.PROVIDER_URL=iiop://localhost:3700, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFa ctoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: fsp.service.PHPBackend not found]" at: #-13 com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518) #-12 com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) #-11 javax.naming.InitialContext.lookup(InitialContext.java:392) #-10 javax.naming.InitialContext.lookup(InitialContext.java:392) #-9 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) #-8 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) #-7 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) #-6 java.lang.reflect.Method.invoke(Method.java:597) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1044) #-4 php.java.bridge.Request.handleRequest(Request.java:417) #-3 php.java.bridge.Request.handleRequests(Request.java:500) #-2 php.java.bridge.http.ContextRunner.run(ContextRunner.java:145) #-1 php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:60) #0 http://localhost:8080/JavaBridge/java/Java.inc(232): java_ExceptionProxyFactory->getProxy(3, NULL, 'T', true) #1 http://localhost:8080/JavaBridge/java/Java.inc(360): java_Arg->getResult(true) #2 http://localhost:8080/JavaBridge/java/Java.inc(366): java_Client->getWrappedResult(true) #3 http://localhost:8080/JavaBridge/java/Java.inc(560): java_Client->getResult() #4 http://localhost:8080/JavaBridge/java/Java.inc(1752): java_Client->invokeMethod(2, 'getCause', Array) #5 http://localhost:8080/JavaBridge/java/Java.inc(2062): java_JavaProxy->__call('getCause', Array) #6 C:\work\projects\temp\test2.php(31): java_exception->__call('getCause', Array) #7 C:\work\projects\temp\test2.php(31): java_InternalException->getCause() #8 {main}] in file: http://localhost:8080/JavaBridge/java/Java.inc line:195 My test code would be: <?php define("JAVA_PREFER_VALUES", true); $HOST="localhost"; require_once("http://localhost:8080/JavaBridge/java/Java.inc"); try { $config = array("java.naming.factory.initial"=> "com.sun.jndi.cosnaming.CNCtxFactory", "java.naming.provider.url"=> "iiop://$HOST:3700"); $providerUrl = "iiop://$HOST:3700"; $namingFactory = "com.sun.enterprise.naming.SerialInitContextFactory"; $envt = array( "javax.naming.Context.PROVIDER_URL" => $providerUrl, "javax.naming.Context.INITIAL_CONTEXT_FACTORY" => $namingFactory,); $initial = new javax_naming_InitialContext($envt); $phpBackend = $initial->lookup('java:global/FspBackendEE-ejb/fsp.service.PHPBackend'); //$phpBackend = new java("fsp.service.LPHPBackend"); echo $phpBackend->getAvailableFunds(42); assert (is_null(java_last_exception_get())); } catch(JavaException $ex) { $cause = $ex->getCause(); echo "Exception: $cause <br>\nin file: {$ex->getFile()}<br>\nline:{$ex->getLine()}\n"; } >From JSP everything works, i can lookup my service easly. Thanks for looking anyway, it's a long first post, but i looked everywere on the net and i can't find a soluion. Thanks! Adrian |