2 Replies Latest reply on Apr 4, 2006 11:34 AM by tom.elrod

    EJB3 remoting - RMI (good), HTTP (bad)

    dhartford

      Hey all,
      I have had great success with EJB3 test-application and using the remoting support for socket-based RMI with great success!

      Now I have moved on to test support for RMI-over-HTTP, and having some issues. Two problems specifically:

      * Using the servlet or EJB invoker over HTTP.
      * The JNDI call for the initial context.

      I have a java client that is using the EJB3-socket talking to a secured EJB3class and all works fine is:

      Properties env = new Properties();
      env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      env.setProperty(Context.SECURITY_PRINCIPAL, username);
      env.setProperty(Context.SECURITY_CREDENTIALS, password);
      
      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
      env.setProperty(Context.PROVIDER_URL,"jnp://localhost:1099");
      
      //then, get appropriate EJB3class (remote or remoteSSL) and make a method call
      


      This works great, and all the EJB3class have the following bindings:
      @RemoteBindings({
       @RemoteBinding(clientBindUrl="sslsocket://0.0.0.0:3843", jndiBinding="MyClassBean/remoteSSL"),
       @RemoteBinding(clientBindUrl="socket://0.0.0.0:3873", jndiBinding="MyClassBean/remote"),
       @RemoteBinding(clientBindUrl="http://0.0.0.0:8080/invoker/EJBInvokerServlet", jndiBinding="MyClassBean/remoteHttp")
       })
      
      /*
       * Security annotations
       */
      @PermitAll
      @SecurityDomain("testRealm")
      


      Problem 1: When I use the above configuration and make a call to the remote Binding for remoteHttp, I get the following error:

      Exception in thread "main" java.lang.ClassCastException: java.lang.String
       at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
      


      Problem 2: When I change the context factory and provider url for HTTP access, I get various errors. The JNDIFactory gives a 'not authenticiated, incorrect username/password' - even though it works fine with the socket approach.
      //env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
      //env.setProperty(Context.PROVIDER_URL,"http://localhost:8080/invoker/JNDIFactory");
      //env.setProperty(Context.PROVIDER_URL,"http://localhost:8080/invoker/JMXInvokerServlet");
      


      The JMXInvoker gives this error:
      javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.io.IOException: Invalid reply content seen: class org.jboss.invocation.InvocationException]
       at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:84)
       at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
       at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.init(Unknown Source)
       at javax.naming.InitialContext.<init>(Unknown Source)
      [snip - my client test class]
      Caused by: java.io.IOException: Invalid reply content seen: class org.jboss.invocation.InvocationException
       at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:153)
       at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:80)