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 |
From: <php...@li...> - 2012-07-11 23:06:56
|
Hello again :), I finnaly solved the issue, what worked was a custom jndi name, like this: @Stateless(name="PHPBackend") @EJB(name="java:global/ImplementedPHPBackend", beanInterface=IPHPBackend.class) public class PHPBackend implements IPHPBackend { But i would really love if anyone has a clue on why it didn't worked on my standard approach, as it is not very nice to be forced to define a name for each class. Cheers, Adrian -----Original Message----- From: php...@li... [mailto:php...@li...] Sent: Thursday, July 12, 2012 12:53 AM To: php...@li... Subject: [Php-java-bridge-users] Glassfish JNDI Issue 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 ---------------------------------------------------------------------------- -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2012-07-16 20:04:41
|
Can you create a simple JSP in the same app and call your external name from there? If that works, you've found a bug. If not, well, try the internal name... Code executed from the bridge runs in a different thread context. But this should be an implementation detail. |
From: <php...@li...> - 2012-07-16 20:09:38
|
Well, i allready did that and in the JSP page every JNDI works, no problems there. Only in the php side i could't get it to work without a custom JNDI. -----Original Message----- From: php...@li... [mailto:php...@li...] Sent: Monday, July 16, 2012 10:05 PM To: php...@li... Subject: Re: [Php-java-bridge-users] Glassfish JNDI Issue Can you create a simple JSP in the same app and call your external name from there? If that works, you've found a bug. If not, well, try the internal name... Code executed from the bridge runs in a different thread context. But this should be an implementation detail. ---------------------------------------------------------------------------- -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |