1 Reply Latest reply on May 17, 2011 2:06 PM by Jeff Briggs

    Seam Remoting - failure to load interface.js

    Jeff Briggs Newbie

      Hi, I'm new to Seam and am going through some examples trying to get them to run on my company's J2EE server, Websphere 6.1.  Things are going surprisingly well so far, but today I ran into an issue getting a seam remoting example to work.


      The issue is that the interface.js file does not load (it is totally empty), which of course results in JS errors.  I get no exceptions in the log.  If I try to view interface.js through firebug, I get this message:


      Failed to load source for: http://localhost:9082/seamremote/seam/resource/remoting/interface.js?manager
      



      I've tried importing the js files both with script tags and with the s:remote tag -- in both cases the resource.js file loads fine but the interface.js is empty.


      Method 1:
      <script type="text/javascript" 
        src="seam/resource/remoting/resource/remote.js">
      </script>
       
      <script type="text/javascript" 
        src="seam/resource/remoting/interface.js?manager">
      </script>
      
      Method 2:
      <s:remote include="manager"/>
      




      This is the session bean interface with the @WebRemote annotations


      @Local
      public interface Manager {
        ...
        @WebRemote
        public boolean checkName (String name);
        
        @WebRemote
        public void setComment (String comment);
      }



      Session bean implementation


      @Stateful
      @Name("manager")
      @Scope (SESSION)
      public class ManagerAction implements Manager {
        ...
      
        public boolean checkName (String name) {
          System.out.println("CheckName() is called");
          
          List <Person> existing = em.createQuery(
              "select p from Person p where name=:name")
              .setParameter("name", name)
              .getResultList();
          
          if (existing.size() != 0) {
            return false;
          } else {
            return true;
          }
        }
        
        public void setComment (String comment) {
          System.out.println("setComment() is called with " + comment);
          person.setComment (comment);
        }
      ...
      



      definition and mapping of the SeamResourceServlet 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>
      



      I have the app packaged as an EAR.  Within the EAR is a JAR with the EJB and a WAR for the web-app.  I've got most library JARs (including jboss-seam-remoting.jar) packaged at the EAR level.  The only JARs that I have at at the WAR level are the JSF/Richfaces JARS, as well as the jboss-seam-debug.jar and jboss-seam-ui.jar.


      I have tried including 'jboss-seam-remoting.jar' in the WEB-INF/lib of the WAR file (in addition to within the the EAR itself) but this made no difference.


      Any help would be greatly appreciated!  Thank you,
      -Jeff

        • 1. Re: Seam Remoting - failure to load interface.js
          Jeff Briggs Newbie

          I solved my problem -- it turns out that the request parameters were not being found in the InterfaceGenerator class. 


          To figure this out I imported the Seam remoting source (v 2.2.2) into Eclipse and debugged the InterfaceGenerator.handle method.  I noticed that on line 83, the enumeration of request parameter names was empty.  I'm not sure why this is so, maybe this is a Websphere quirk.


          So then I simply tried adding an = sign to the end of my script import and this immediately fixed the problem.


          So to sum up, this is the change I had to make:


          <!-- Doesn't work: -->
          <s:remote include="manager"/>
          
          <!-- Works: -->
          <s:remote include="manager="/>