Hi

I don't know if this problem has already been addressed by someone
else, but when I started looking at migrating my Wicket application
from Glassfish to OpenEjb, the injection magic failed.

I have hacked my way around that issue with the below code.

It would need some TLC to be suitable for inclusion in the project.
Maybe just make a new JavaEEComponentInjector clone class with the
added magic, or extend the existing class to allow lookup properties
to be provided!?!?!

Anyway, use it as you see fit.

Cheers,
Jesper Skov


--- 
../../../../wicket-contrib-javaee-orig/org/wicketstuff/javaee/JavaEEBeanLocator.java
        2008-01-14
19:05:06.000000000 +0100
+++ JavaEEBeanLocator.java      2010-07-14 22:13:58.000000000 +0200
@@ -16,14 +16,19 @@
  */
 package org.wicketstuff.javaee;

+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;

 import org.apache.wicket.proxy.IProxyTargetLocator;
 import org.apache.wicket.util.lang.Objects;

 import org.wicketstuff.javaee.naming.IJndiNamingStrategy;

+import java.util.Properties;
+
 /**
  * Implementation of {...@link IProxyTargetLocator} to locate ejbs using Java 
EE 5
  * resource injection. To use this technique in a Wicket Page, annotate a
@@ -138,7 +143,16 @@
         InitialContext ic;
         try
         {
-            ic = new InitialContext();
+           Properties properties = new Properties();
+           properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.openejb.client.LocalInitialContextFactory");
+            ic = new InitialContext(properties);
+
+           try {
+               return ic.lookup(name + "Local");
+           } catch (Exception e) {
+               System.out.println("Lookup by Local name failed");
+           }
+
             return ic.lookup(lookupName);
         } catch (NamingException e)
         {

Reply via email to