users@glassfish.java.net

Websphere 5.x to Glassfish App Conversion

From: <glassfish_at_javadesktop.org>
Date: Thu, 06 Nov 2008 09:46:36 PST

I am working on converting a Websphere 5.x application over to a Glassfish (v2) EJB Container, using Eclipse Ganymede as the interrim development environment. This application uses 3 EJB objects, connects to a couple of databases and a number of JSP pages served by the container. I have resolved quite a number of conversion issues and have the application in a somewhat runnable condition. But, I can't seem to get the beans to init. I have worked out the root issue is a place where a couple very Websphere references are hard-coded...

I have a BeanHandler class that was specifically coded with a couple of specific websphere classes: a JNDI cache object and a WsnInitialContextFactory reference.

The JNDI cache reference is to
"com.ibm.websphere.naming.jndicache.cacheobject"

The DEFAULT_CONTEXT_FACTORY property is set to
"com.ibm.websphere.naming.WsnInitialContextFactory"

Here is a code sampling of the BeanHandler class
<code>
public class BaseBeanHandler
{
   //JNDI context property names
   protected static final String PROP_JNDI_CACHE = "com.ibm.websphere.naming.jndicache.cacheobject";
   protected static final String PROP_PROVIDER_URL = Context.PROVIDER_URL;
   protected static final String PROP_CONTEXT_FACTORY = Context.INITIAL_CONTEXT_FACTORY;

   //Default property values
   protected static final String DEFAULT_JNDI_CACHE = "cleared";
   protected static final String DEFAULT_CONTEXT_FACTORY = "com.ibm.websphere.naming.WsnInitialContextFactory";

   //member variables
   protected String m_JNDIUrl;
   protected String m_EJBName;
   protected Context m_Context;

   //constructor
   protected BaseBeanHandler(String jndiURL, String ejbName)
   {
      m_JNDIUrl = jndiURL;
      m_EJBName = ejbName;
      m_Context = null;
   }
/* .
    . some omitted code
    . /*
   protected String getHandlerName()
   {
      String fullName = this.getClass().getName();
      String handlerName = fullName.substring(fullName.lastIndexOf(".")+1);
      return handlerName;
   }

   protected Object getBean(Class homeClass)
      throws Exception
   {
      Object bean = null;
      Method create = null;

      try
      {
         create = homeClass.getMethod("create", new Class[0]);
      }
      catch(Exception e)
      {
         throw e;
      }

      try
      {
         Object home = PortableRemoteObject.narrow(getJNDIContext().lookup(m_EJBName), hmoeClass);
         bean = create.invoke(home, new Class[0]);
      }
      catch(Exception e)
      {
         bean = null;
         closeJNDIContext();
      }

      if(bean == null)
      {
         try
         {
            System.out.println(getHandlerName()+".getBean() - bean is null, retrying");
            Object home = PortableRemoteObject.narrow(getJNDIContext().lookup(m_EJBName), homeClass);
            bean = create.invoke(home, new Class[0]);
          }
          catch(Exception e)
          {
             bean = null;
             closeJNDIContext();
             throw e;
          }
      }
      return bean;
   }

   protected void closeJNDIContext()
   {
      synchronized(this)
      {
         if(m_Context != null)
         {
            try
            {
               m_Context.close();
            }
            catch(Exception e)
            {
               System.out.println(getHandlerName()+".closeJNDIContext() - Exception: "+e);
            }
            m_Context = null;
         }
      }
   }

   protected Context getJNDIContext()
      throws NamingException
   {
      synchronized(this)
      {
         if(m_Context != null) return m_Context;
         System.out.println(getHandlerName()+".getJNDIContext() - context is null, establishing new Context");
         Properties p = new Properties();
         p.put(PROP_JNDI_CACHE, DEFAULT_JNDI_CACHE);
         p.put(PROP_PROVIDER_URL, m_JNDIUrl);
         p.put(PROP_CONTEXT_FACTORY, DEFAULT_CONTEXT_FACTORY);
         m_Context = new InitialContext(p);

         if(m_Context != null)
         {
            System.out.println(getHandlerName()+".getJNDIContext() - non-null context established");
         }
         return m_Context;
      }
   }

</code>

Investigating the Glassfish model, I can't find any reference to a naming cache object and if I try using Suns'reference to a contextFactory, "com.sun.jndi.cosnaming.CNCtxFactory" and totally ignore the cache object (commenting out the cache property setter in getJNDIContext()) I do not get the connection. for example, in my code I have a Bean called CWMManager which has a CWMManagerBeanHandler that extends the base class that runs perfectly within Websphere, but has the following entry in the log file after a JDBC connection is established: <code>

[#|2008-11-05T17:13:25.169-0600|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;|PWC1412: WebModule[/app/cbci] ServletContext.log():CBCServlet: JDBCConnPool.releaseConnection() - Pool connections: Max = 5, available = 1, used = 0|#]

[#|2008-11-05T17:13:25.294-0600|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;|
CWMManagerBeanHandler.getJNDIContext() - context is null, establishing new context|#]

[#|2008-11-05T17:13:26.810-0600|WARNING|sun-appserver9.1|javax.enterprise.resource.corba._DEFAULT_.rpc.transport|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;IIOP_CLEAR_TEXT;localhost;2809;_RequestID=922361d5-094e-4a19-a68c-5556b8b893da;|"IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 2809"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2172)
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2193)
.
. {many lines of error precedences}
.

[#|2008-11-05T17:13:26.810-0600|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;|
CWMManagerBeanHandler.getBean() - bean is null, retrying|#]

[#|2008-11-05T17:13:26.810-0600|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;|
CWMManagerBeanHandler.getJNDIContext() - context is null, establishing new context|#]

[#|2008-11-05T17:13:27.904-0600|WARNING|sun-appserver9.1|javax.enterprise.resource.corba._DEFAULT_.rpc.transport|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;IIOP_CLEAR_TEXT;localhost;2809;_RequestID=922361d5-094e-4a19-a68c-5556b8b893da;|"IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 2809"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2172)
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2193)
.
. {many lines of error precedences}
.

[#|2008-11-05T17:13:27.904-0600|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;|
CWMManagerBeanHandler.save() - Elapsed time = 00:00:02.610 - Exception: javax.naming.CommunicationException: Cannot connect to ORB [Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No]|#]

[#|2008-11-05T17:13:27.904-0600|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8081-1;|
javax.naming.CommunicationException: Cannot connect to ORB [Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No]
        at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:362)
        at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(CNCtx.java:289)
        at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:245)
.
. {many lines of error precedences}
.
</code> And on and on until a time-out threshold is reached.

The question I have after pulling many hours of research into this and still no resolution, what would be a reasonable substitute for the webshpere classes or anyone have an idea what should be replacement code for the base handler?

Thanks, Da Lizard
[Message sent by forum member 'loungelizard' (loungelizard)]

http://forums.java.net/jive/thread.jspa?messageID=315299