Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Taking data from Session Bean in JBoss

    Hi,

    I have integrated the SmartClient's client portion with JBoss Application Server (EJB 3.0) and I would like to know following things.

    1. I would like to know how to get the reference of Remote Session Bean and execute a method from the SmartClient's JavaScript code. I have read document on ServerObject with lookup procedure (AttiruteScope and AttributeName) , but I am not able to find any example of the same. Could you please point me to some example?

    2. Can I use DMI and RPC Manager with only Client's portion of SmartClient integrated in JBoss?

    3. How can I invoke any of my own jsp files from the SmartClient's Javascript?

    Please let me know.

    Thanks in advance
    Nikhil

    #2
    1 SmartClient communicates with a server via HTTP. Thus, to access your EJBs you will need a servlet or JSP to act as a proxy. Your Javascript client code communicates with the servlet, and the servlet then would access the EJB stack exactly the same as if you were writing a traditional, server-side-only web app. Have a look at the docs for client-side data integrations here: http://www.smartclient.com/docs/6.5....ataIntegration. There is nothing specifically about EJBs in there, but it will help you do the SmartClient-to-servlet communication - presumably you already know how to make a servlet talk to an EJB.

    Or, you could use something like JAX-RPC to expose your beans as web services - since they are HTTP-based, SmartClient can talk to web services directly.

    2 Yes you can, but you need to write your own server-side code as described above.

    3 I'm not sure what you mean by this. If you just mean how can you jump from a SmartClient app to a normal JSP page, then that's not SmartClient-specific - just use window.location.replace

    Comment


      #3
      Hi,

      Thank you for your quick reply. I have just started using SmartClient, so please bare with me.

      As you mentioned in point 1.

      I have a TestJSP.jsp file which has jspInit() method which does the lookup and gets the Remote Interface to the Session Bean as follows
      Code:
       
                   TestNodeFacadeRemote testRef = null; 
                  InitialContext ic = new InitialContext();
                  testRef = (TestNodeFacadeRemote) ic.lookup("TestApplication/TestNodeFacade/remote");
      System.out.println("Successfully got Test Ref ==== " + testRef);
      I am getting the testRef successfully. Now I have a javascript with one create button with following method to be called on click of it.

      Code:
      createItem : function () {
      
      	  }
      Now, on click of it I need to call a method which is defined in testRef (RemoteInterface).

      How can I access the testRef within the SmartClient's javascript code? Is there any way I can access it using SmartClient APIs?

      Or is there any better way of handling it?

      Please let me know.

      Thanks
      Nikhil

      Comment


        #4
        Hi nkoranne,

        Yes, this is standard SmartClient functionality. Please read the previously referenced document on client-server integration - you want "Path 1", server-side integration in Java.

        Comment


          #5
          Hi,

          As you mentioned, I have integrated the server part of SmartClient into JBoss and tried to use RPC Manager call from my Javascript client to the jsp page.

          I took the Reference of following example and written the same way

          Simple example (client code):
          Code:
          var data = { here: "is some data", to: ["send to the server"]};
          RPCManager.sendRequest({ data: data, callback: "myCallback(data)", actionURL: "/rpcHandler.jsp"});
          function myCallback(data) { alert("response from the server: " + data); }
          Simple example (server code: /rpcHandler.jsp):
          Code:
          RPCManager rpc = new RPCManager(request, response, out);
          Object data = rpc.getData();
          System.out.println("client sent: " + data.toString());
          rpc.send("here's a response");
          But while accessing the jsp, following exception has occured on the JBoss console. Anything is missing in above example. Please let me know

          20:53:27,250 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
          com.isomorphic.rpc.ClientMustResubmitException:
          at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:914)
          at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:225)
          at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:251)
          at org.apache.jsp.abc_jsp._jspService(abc_jsp.java:57)
          at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
          at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
          at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

          Comment


            #6
            That error indicates that no actual data arrived at the server.

            Your code appears to send some. Is it possible that that's not the actual code you are using, and in fact your real code sends useSimpleHttp:true or other properties? That would cause this.

            If not, take a look at what is actually being transmitted via Fiddler, Firebug or a similar tool. If you see data being sent, you can check that it's being received by calling httpRequest.getParameter("_transaction") on the server (before calling new RPCManager()).

            If you see the data being sent but not received, then the problem is not SmartClient. Some other system - perhaps an overzealous security product similar to SiteMinder, or a servlet filter, or a sloppy redirect - is causing the data to be dropped.

            Comment


              #7
              I would like to share the console logs which has been printed on JBoss console while I try to communicate with RPCManager. Looks like data is not being sent from client. Could you please let me know if anything is wrongly configured or some issues in the way of execution?



              11:43:18,468 INFO [STDOUT] === 2008-08-27 11:43:18,468 [80-2] WARN RPCManager - Detected zero-length IDA transaction, asking client to retry.
              11:43:18,468 INFO [STDOUT] === 2008-08-27 11:43:18,468 [80-2] WARN RPCManager - Outputting extra debug information:
              11:43:18,468 INFO [STDOUT] === 2008-08-27 11:43:18,468 [80-2] WARN RPCManager - Cookies:
              Name: 'JSESSIONID', value: '91070B30D39089391C431F5611C47676', domain: 'null', path: 'null', maxAge: '-1', isSecure: 'false'
              11:43:18,484 INFO [STDOUT] === 2008-08-27 11:43:18,484 [80-2] WARN RPCManager - Client HTTP Headers:
              accept: */*
              accept-language: en-us
              referer: http://localhost:8080/TestApplication-war/TestApp.jsp
              content-type: application/x-www-form-urlencoded; charset=UTF-8
              accept-encoding: gzip, deflate
              user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
              host: localhost:8080
              content-length: 0
              connection: Keep-Alive
              cache-control: no-cache
              cookie: JSESSIONID=91070B30D39089391C431F5611C47676
              11:43:18,515 INFO [STDOUT] === 2008-08-27 11:43:18,515 [80-2] WARN RPCManager - {isc_rpc:"1", isc_v:"6.5.1", isc_tnum:"0", isc_xhr:"1"}
              11:43:18,515 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
              com.isomorphic.rpc.ClientMustResubmitException:
              at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:914)
              at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:225)
              at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:251)

              Comment


                #8
                Good start. The next step, as previously indicated, is to use either Fiddler or Firebug to verify that data is being sent from the client. Both tools are very easy to install, very easy to use, and should be installed for future development in any case, so please don't skip this step.

                Other questions:
                1) Are you able to run the included SmartClient examples within JBoss or do you instead see similar errors?

                2) Does this happen every time or intermittently?

                3) what's your exact version of JBoss?

                4) do you have any special security software installed in your browser, or non-default security settings or software installed in JBoss?

                Comment

                Working...
                X