1 Reply Latest reply on Oct 2, 2007 1:57 AM by Elias Ross

    Problem with RMI/JRMP

    matt4400 Newbie

      Hello!
      The situation is :
      I have a JBoss Portal 2.6.1GA with an MBean developpe with the JBoss Portal API. My idea is to deploy this service on another server just with JBoss AS 4.2.1GA and used it in the JBoss Portal. So I need to access to this service via RMI/JRMP. I have developpe a MBean which works find in the JBoss AS but I can't acces to the Interface that I publish in the JRMP.

      This is my jboss-service.xml

      <server>
       <mbean code="org.cap2j.jbp.service.HelloService"
       name="cap2j:service=HelloService">
       <attribute name="Phrase">Hello from MBean</attribute>
       <depends>jboss:service=Naming</depends>
       </mbean>
       <!-- The JRMP invoker proxy configuration for the naming service -->
       <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
       name="jboss.test:service=proxyFactory,type=jrmp,target=JNDIMap">
       <!-- Use the standard JRMPInvoker from conf/jboss-service.xml -->
       <attribute name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
       <attribute name="TargetName">cap2j:service=HelloService</attribute>
       <attribute name="JndiName">cap2j/JRMP</attribute>
       <attribute name="ExportedInterface">org.cap2j.jbp.service.HelloServiceMBean</attribute>
       <!-- <attribute name="InvokeTargetMethod">true</attribute> -->
       <attribute name="ClientInterceptors">
       <iterceptors>
      <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
       <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
       <interceptor>org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor</interceptor>
       <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
       </iterceptors>
       </attribute>
       <depends>jboss:service=invoker,type=jrmp</depends>
       <depends>cap2j:service=HelloService</depends>
       </mbean>
      </server>
      


      And this is the code of my Servlet which try to access to the service
      protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
       try{
       InitialContext init = new InitialContext();
       HelloServiceMBean ob = (HelloServiceMBean)init.lookup("cap2j/JRMP");
       }catch(NamingException e){
       e.printStackTrace();
       } catch (Exception e) {
       e.printStackTrace();
       }
      }
      


      But when I do this Cast I have this Error:
      ERROR [STDERR] java.lang.ClassCastException: $Proxy35
      at hello.world.servlet.HelloServlet.doGet(HelloServlet.java:29)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:595)
      


      If someone has an idea of the solution or if there is an another method to do what I want
      Thanks for regards