11 Replies Latest reply on Aug 12, 2010 6:31 PM by shane.bryzak

    Seam Remoting: remote.js & interface.js not generated...

    yshashidhar

      Hi


      I am unable to locate remote.js and interface.js in my directory structure. Are these generated automatically or do I need to get it manually?


      I have below configurations:
      in web.xml:


      <servlet>
          <servlet-name>Seam Resource Servlet</servlet-name>
          <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
        </servlet>
        <servlet-mapping>
          <servlet-name>Seam Resource Servlet</servlet-name>
          <url-pattern>/seam/resource/*</url-pattern>
        </servlet-mapping>



      in my xhtml page



      <ui:define name="body" style="width: 490px; height: 160px">
                      <s:remote include="qualityIP"/>
                      <script type="text/javascript" src="seam/resource/remoting/resource/remote.js"></script>
                      <script type="text/javascript" src="seam/resource/remoting/interface.js?qualityIP"></script>
                      
                      <script type="text/javascript">
                              //<![CDATA[
                      
                              function jsExecute(){
                                      var name = prompt("what is your name?");
                                      Seam.Component.getInstance("qualityIP").sayHello(name, sayHelloCallback);
                              }
                              function sayHelloCallback(result) {
                                    alert(result);
                          }
                              // ]]>
                      </script>



      And my interface


      @Local
      public interface QualityIP {
              @WebRemote
              public String sayHello(String name);
      }



      And finally my method


      public String sayHello(String name) {
                      return "Hey "+name +", hz u doing?";
              }



      Please help me it seems running out of time to understand this...

        • 1. Re: Seam Remoting: remote.js & interface.js not generated...
          shane.bryzak

          Which version of Seam are you using?  Both of these resources are generated by the InterfaceGenerator class.  Make sure that your packaging is correct - if you are deploying your application as an EAR file then seam-remoting.jar must be packaged inside the WAR. 


          Also, you don't need to specify both the s:remote and the <script/> tags - the s:remote will generate the <script/> tags for you (although that shouldn't cause your problem).  Could you please post the HTML that gets rendered when you view the page in a browser?  That might help to determine what's wrong.

          • 2. Re: Seam Remoting: remote.js & interface.js not generated...
            yshashidhar

            Many thanks for the reply...


            I am using Seam 2.0 and I am archiving my app inside war, and seam-remoting.jar is inside my web-inf/lib folder. Seems okay so far.


            Here is my xhtml snippet:


            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:s="http://jboss.com/products/seam/taglib"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:rich="http://richfaces.org/rich"
                 xmlns:a4j="http://richfaces.org/a4j"
                 template="../../layout/template.xhtml">
                 <ui:define name="body" style="width: 490px; height: 160px">
                      <s:remote include="qualityIP"/>
                      
                      <script type="text/javascript">
                      
                           function jsexecute(){
                                Seam.Remoting.setDebug(true);
                                var name = prompt("what is your name?");
                                alert(Seam.Component.getInstance("qualityIP").emptyMethod());
                           }
                           function sayHelloCallback(result) {
                                 alert(result);
                          }
                      </script>



            This I would able to move bit forward I guess, In IE I am able to see the prompt asking for name.. after entering name I see below IE Java script message




            Object does not support this property or method

            And here are my web methods annotated:


                 @WebRemote
                 public String sayHello(String name) {
                      System.out.println("SeamRemote: inside say hello...");
                      return "Hey "+name +", hz u doing?";
                 }
                 
                 @WebRemote
                 public String emptyMethod(){
                      System.out.println("SeamRemote: inside empty method...");
                      return "empty";
                 }




            Any ideas to move further please?

            • 3. Re: Seam Remoting: remote.js & interface.js not generated...
              yshashidhar

              Any one help me please...

              • 4. Re: Seam Remoting: remote.js & interface.js not generated...
                shane.bryzak

                Can you browse directly to remote.js in a web browser? I.e. http://localhost:8080/myapp/seam/resource/remoting/resource/remote.js

                • 5. Re: Seam Remoting: remote.js & interface.js not generated...
                  yshashidhar

                  I am able to see below message




                  Seam.Remoting.type.qualityIP = function() { this.\__callback \= new Object(); Seam.Remoting.type.qualityIP.prototype.execute \= function(callback) { return Seam.Remoting.execute(this, "execute", [], callback); } Seam.Remoting.type.qualityIP.prototype.sayHello = function(p0, callback) { return Seam.Remoting.execute(this, "sayHello", [p0], callback); } Seam.Remoting.type.qualityIP.prototype.emptyMethod \= function(callback) { return Seam.Remoting.execute(this, \"emptyMethod", [], callback); } } Seam.Remoting.type.qualityIP.\__name = "qualityIP"; Seam.Component.register(Seam.Remoting.type.qualityIP);



                  when I supply give http://localhost:8080/customCSS/seam/resource/remoting/interface.js?qualityIP on my browser


                  I have replaced below lines on my xhtml


                  <ui:define name="body" style="width: 490px; height: 160px">
                                  <!--  <s:remote include="qualityIP"/>  -->
                                  <script type="text/javascript" src="/customCSS/seam/resource/remoting/resource/remote.js"></script>
                                  <script type="text/javascript" src="/customCSS/seam/resource/remoting/interface.js?qualityIP"></script>
                                  
                                  <script type="text/javascript">
                                  
                                          function jsexecute(){
                                                  Seam.Remoting.setDebug(true);
                                                  var name = prompt("what is your name?");
                                                  Seam.Component.getINstance("qualityIP").sayHello("Shashi");
                                          }
                                          function sayHelloCallback(result) {
                                                alert(result);
                                      }
                                  </script>
                  



                  but again I see below same error



                  Object does not support this property or method

                  I think I am doing some mistake while executing the method, can you please cross check am I doing this in right way?

                  • 6. Re: Seam Remoting: remote.js & interface.js not generated...
                    shane.bryzak

                    You have a small typo here:




                    Seam.Component.getINstance("qualityIP").sayHello("Shashi");



                    it should be getInstance, not getINstance


                    The rest of the code looks ok, however you're not passing in the callback method to your function call. I assume you want this:




                    Seam.Component.getINstance("qualityIP").sayHello("Shashi", sayHelloCallback);



                    The next thing I can suggest is to use a JavaScript debugger (such as Firebug, a Firefox add-on) to determine where the error is coming from.

                    • 7. Re: Seam Remoting: remote.js & interface.js not generated...
                      yshashidhar

                      Hmmmmm I corrected the typo and have modified the code as below


                             <ui:define name="body" style="width: 490px; height: 160px">
                                      <!--  <s:remote include="qualityIP"/>  -->
                                      <script type="text/javascript" src="/customCSS/seam/resource/remoting/resource/remote.js"></script>
                                      <script type="text/javascript" src="/customCSS/seam/resource/remoting/interface.js?qualityIP"></script>
                                      
                                      <script type="text/javascript">
                                      
                                              function jsexecute(){
                                                      Seam.Remoting.setDebug(true);
                                                      var name = prompt("what is your name?");
                                                      Seam.Component.getInstance("qualityIP").sayHello(name, sayHelloCallback);
                                              }
                                              function sayHelloCallback(result) {
                                                    alert(result);
                                          }
                                      </script>
                      



                      but I still don't see the alert message which need to come... Also have a system out statement inside sayHello which is also not appearing in console.


                      But this time I see below debug message in IE


                      Thu Aug 12 09:05:44 UTC+0530 2010: Request packet:
                      <envelope><header><context></context></header><body><call component="qualityIP" method="sayHello" id="0">
                      <params><param><str>Shashi</str></param></params><refs></refs></call></body></envelope>
                      
                      
                      Thu Aug 12 09:05:45 UTC+0530 2010: Response packet:
                      



                      Any further thoughts please?

                      • 8. Re: Seam Remoting: remote.js & interface.js not generated...
                        yshashidhar

                        Any help please...

                        • 9. Re: Seam Remoting: remote.js & interface.js not generated...
                          shane.bryzak

                          It seems like your request is being sent successfully, but something is failing on the server.  Are there any exceptions in the server log?  The next step would be to remote debug, setting a breakpoint at org.jboss.seam.remoting.ExecutionHandler.handle(), and stepping through to determine what is failing.  Pay special attention to what happens when call.execute() is invoked, and whether any exceptions are thrown there.

                          • 10. Re: Seam Remoting: remote.js & interface.js not generated...
                            yshashidhar

                            Shane,


                            Could you possibly help me on setting remote debug to get into deeper on this problem?



                            Are there any exceptions in the server log?

                            Do you mean Server console... No errors/exceptions seen over there...


                            • 11. Re: Seam Remoting: remote.js & interface.js not generated...
                              shane.bryzak

                              Remote debugging is quite easy.  I'm going to assume that you're using JBoss AS as your application server, and Eclipse as your IDE.



                              1. Open bin/run.conf (if you're running *nix or Mac) or bin/run.bat (if you're running Windows, or bin/run.conf.bat for the latest versions of JBoss) in an editor.

                              2. Find the line that looks like the following: 
                                # Sample JPDA settings for remote socket debuging
                                #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"


                              3. Uncomment the JAVA_OPTS variable and save the file

                              4. Start JBoss AS

                              5. In Eclipse, open your debug configurations (Run -> Debug Configurations)

                              6. Click on 'Remote Java Application' to select it, then click the 'New launch configuration' button (the first button in the top toolbar)

                              7. Give it a name, and select the project that you wish to debug

                              8. For connection properties, leave the host as localhost, and enter 8787 for the port

                              9. Click Apply, then Close

                              10. Set a breakpoint in your code where you want to debug

                              11. Start the debugger (click the little arrow next to the debug icon, then select the new debug configuration you just created)



                              Now you can just use your application as normal, and when it hits your breakpoint execution will pause and you step through the code, evaluate variables, etc.