2 Replies Latest reply on Nov 6, 2005 4:39 PM by David Webster

    Failed EJB3 JNDI lookup.

    David Webster Newbie

      This used to work just fine but I am suddenly getting a very odd NoSuchMethodException:

      java.lang.NoSuchMethodException: $Proxy76.getValidTerrainTypes(void)

      $Proxy76 is supposed to be TerrainEJB (an EJB3 bean that returns valid terrain types for a mapping application).

      This is caused by a SWT based client trying invokde the remote EJB3 interface method via a Servlet in a mapping ear application deployed to a JBOSS4.0.3SP1 server.

      Here is snippet from the bean:

      @Remote
      public interface TerrainEJB {

      public ArrayList getValidTerrainTypes();
      }


      The TerrainEJBBean has the actual method. It returns an ArrayList.

      The client is an SWT GUI that invokes a Servlet on the JBOSS AS which in turn does the usual JNDI lookup stuff(hard coded strings are actually variables containing the strings...shown for clarity of the problem):

      InitialContext vCtx = new InitialContext();
      Object vObj = vCtx.lookup("constants.ejb.TerrainEJB");

      return(vObj.getClass().getMethod( "getValidTerrainTypes"
      ,Class[0](void) ).invoke( vObj
      ,null
      ));

      Which results in the error.


      JBOSS initialization of the .ear containing the EJB3 beans shows this:

      13:20:59,000 INFO [SessionFactoryImpl] Checking 0 named queries
      13:20:59,000 INFO [Ejb3Deployment] Create EntityManager with JNDI name: MapEdit
      13:20:59,015 INFO [JaccHelper] JACC Policy Configuration for deployment has been put in service
      13:20:59,015 INFO [Ejb3Deployment] EJB3 deployment time took: 1828
      13:20:59,109 INFO [ProxyDeployer] no declared remote bindings for : constants.ejb.TerrainEJBBean
      13:20:59,125 INFO [ProxyDeployer] there is remote interfaces for constants.ejb.TerrainEJBBean
      13:20:59,125 INFO [ProxyDeployer] default remote binding has jndiName of constants.ejb.TerrainEJB

      The second ProxyDeployer message looks suspicious...

      This code is a veritable copy of some JBOSS example code, LightMinds appletService example (which now suffers from the same error!).







        • 1. Re: Failed EJB3 JNDI lookup.
          David Webster Newbie

          Actually, it is the FIRST ProxyDeployer message that looks supicious, the one about no declared remote bindings....

          • 2. Re: Failed EJB3 JNDI lookup.
            David Webster Newbie

            Answering my question, but I've got it working now. Things are a bit pickier now in the way one passes a method call via the Proxy now. The code I was using before to call a method taking no parameters was :

            InitialContext ctx = new InitialContext();
            Object obj = ctx.lookup(invokeObj.getClassName());

            return(obj.getClass().getMethod("methodName",class[0]{void.class}).invoke(obj,Object[] {}));

            For whatever reason that seemed to work, but the class[0]{void.class} is bad unless the method declaration in the EJB is explicitly methodName(void);?? How odd is that? So if you have methodName() remove the void.class from the getMethod call and leave it just {}. Duh.... The ProxyDeployer can now find the method.