2 Replies Latest reply: Dec 16, 2011 8:29 AM by 905309 RSS

    Help with NameNotFoundException using EJB's after AppServer Upgrade

    905309
      Hello Everyone!
      I am looking for some much needed help on a problem I've been having and have tried to remedy for awhile now.
      First some background... Our organization was previously using an older AppServer with JDeveloper 10.1.3. In the coming months we will be upgrading to JDeveloper 11g and WebLogic server 11g. So it has been my task to ensure that our application works with the forthcoming technologies.

      My main issue with the upgrade has been when I have tried to lookup an EJB. It seems that the application can no longer find the EJB I am searching for, hence the name not found exception below. Mind you this was working perfectly fine with the older JDeveloper and WebLogic.

      I'm not sure what could be causing this as I've seem to checked everything and am completely stumped. I have looked on the WebLogic Administration console to make sure that the EJB's have the correct lookup name. I have included some relevant code below that may give someone a better idea of what is going on. Please ask questions or for additional code if needed. As always, thank you for the help.

      EXCEPTION:
      javax.naming.NameNotFoundException: Unable to resolve 'CoSerFormManager'. Resolved ''; remaining name 'CoSerFormManager'
      at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
      at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:252)
      at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
      at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
      at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
      at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at gov.nysed.sams.ui.ServiceLocator.getService(ServiceLocator.java:28)
      at gov.nysed.sams.ui.delegate.CoSerFormManagerDelegate.<init>(CoSerFormManagerDelegate.java:31)
      at gov.nysed.sams.timer.CoSerNoticeTimer.run(CoSerNoticeTimer.java:35)
      at java.lang.Thread.run(Thread.java:619)
      gov.nysed.sams.exception.SAMSInternalException: Error running suspense transfer timer thread: Unable to locate the service object for CoSerFormManager: Unable to resolve 'CoSerFormManager'. Resolved '': Unable to resolve 'CoSerFormManager'. Resolved ''
      at gov.nysed.sams.timer.CoSerNoticeTimer.run(CoSerNoticeTimer.java:68)
      at java.lang.Thread.run(Thread.java:619)

      Example EJB JAR Entry
      <session>
      <description>Session Bean (Stateless)</description>
      <display-name>CoSerFormManager</display-name>
      <ejb-name>CoSerFormManager</ejb-name>
      <home>gov.nysed.sams.remote.home.CoSerFormManagerHome</home>
      <remote>gov.nysed.sams.remote.CoSerFormManager</remote>
      <ejb-class>gov.nysed.sams.server.session.CoSerFormManagerBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>
      <resource-ref>
      <res-ref-name>jdbc/SAMSDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      </session>

      Code being used to execute the EJB lookup
      public static Object getService(String serviceName, Class serviceClass) {

      Object remote = null;

      try {
      if (cache.containsKey(serviceName)) {
      remote = cache.get(serviceName);
      } else {
      setInitialContext();
      Object lookup = context.lookup(serviceName);*//THIS IS THE LINE WHERE THE EXCEPTION OCCURS*
      cache.put(serviceName, remote);
      }
      } catch (Exception ex) {
      throw new SAMSInternalException(ex, "Unable to locate the service object for " + serviceName + ": "
      + ex.getMessage());
      }

      return remote;
      }


      Information from the Administration Console:
      Name: AccessManager
      Type: stateless
      Transaction Type: Bean
      EJB Class Name: gov.nysed.sams.server.session.AccessManagerBean

      I am using the "Name" portion of this to do the EJB lookup. [Object lookup = context.lookup("CoSerFormManager");]

      Edited by: drg1022 on Dec 15, 2011 11:08 AM
        • 1. Re: Help with NameNotFoundException using EJB's after AppServer Upgrade
          gimbal2
          Answer to your thread in the Java ejb programming section:

          drg1022 wrote:
          I'm pretty sure I am looking at the admin console correctly...
          In the Admin Console it gives the following information

          Name: AccessManager
          Type: stateless
          Transaction Type: Bean
          EJB Class Name: gov.nysed.sams.server.session.AccessManagerBean

          I am using the "Name" portion of this to do the EJB lookup. (Object lookup = context.lookup("AccessManager");
          I think here is where it breaks. The name of EJB is unrelated to the -JNDI NAME- which is the one you need. There are two different names too: the local JNDI name and the remote JNDI name.
          • 2. Re: Help with NameNotFoundException using EJB's after AppServer Upgrade
            905309
            Do you know where I find either of the JNDI names? I can see under the "deployments" section of the "default-server" that my application is deployed, but when I view the JNDI tree for the server, I don't see anything related to my application.