5 Replies Latest reply on Sep 15, 2010 8:59 AM by anand s

    Seam 2.0.2 Remoting In Eclipse

    anand s Newbie


      I am using Seam 2.0.2, Eclipse Galileo.

      I have used ant and got the remoting example shipped with seam working on JBoss 4.2

      I am trying to get the Seam Remoting example running on eclipse.

      I have named the project SeamExample.

      The project gets deployed fine.

      I access the page using the following url:


      The page gets rendered fine

      Now when I click on the button say hello, my firefox error console throws up the following error

      Seam is not defined

      So I view the source and I get

      <script type="text/javascript" src="/SeamExample/seam/resource/remoting/resource/remote.js"></script><script type="text/javascript" src="/SeamExample/seam/resource/remoting/interface.js?helloAction"></script>

      So please let me know where the error is ?

        • 1. Re: Seam 2.0.2 Remoting In Eclipse
          Shane Bryzak Master

          The source paths looks correct to me - what happens when you try to view source of /SeamExample/seam/resource/remoting/resource/remote.js?  Some things that you could check:

          1. That seam-remoting.jar is included in your deployment.

          2. If you are packaging as an EAR file, then seam-remoting.jar should be in the WAR.

          3. That the Seam resource servlet is enabled in your web.xml.

          If all of those things look ok, please let me know and we can dig deeper ;)

          • 2. Re: Seam 2.0.2 Remoting In Eclipse
            anand s Newbie

            Hi Shane,

            Thanks for the quick reply.

            I will give you more details.

            1. I am deplying a war file
            2. The .war file has a WEB-INF/lib which contains the jboss-seam-remoting.jar. I looked into the jar and I could locate the remote.js

            3. The web.xml, components.xml are under the WEB-INF directory

            4. In components.xml I have the following configuration


             <component name="org.jboss.seam.remoting.remoting">
                  <property name="debug">true</property>

            5. In web.xml I have the following configuration


                  <servlet-name>Seam Resource Servlet</servlet-name>
                  <servlet-name>Seam Resource Servlet</servlet-name>

            6. My.xhtml file which refers to remoting is included directly the in .war file which is one level above in the directory

            I have a basic question. Where does the url /seam/resource look for stuff ?


            • 3. Re: Seam 2.0.2 Remoting In Eclipse
              anand s Newbie

              Hi Shane,

              There is one more thing that I observe,

              when i type in the following url in the browser


              I get the following exception

              javax.servlet.ServletException: Servlet.init() for servlet Seam Resource Servlet threw exception

              and the root cause is

              java.lang.IllegalStateException: Attempted to invoke a Seam component outside the an initialized application

              • 4. Re: Seam 2.0.2 Remoting In Eclipse
                Shane Bryzak Master

                The /seam/resource URL sends the request to the Seam resource servlet (org.jboss.seam.servlet.SeamResourceServlet), then from here the request is routed to the correct 'resource provider'.  This servlet is simply a convenience mechanism provided by Seam to provide all the non-JSF type resources without having to configure all the various servlets separately in web.xml (you just configure the resource servlet once, and you're done).

                It is up to each individual resource provider to setup the Seam contexts if they are required to process the request.  Remoting does this when generating JavaScript stubs  - see org.jboss.seam.remoting.InterfaceGenerator.handle().  The work it does here is wrapped in a ContextualHttpServletRequest which automatically sets up Seam's contexts.

                From the error you're getting it seems that something is attempting to access a Seam component without setting up the contexts first.  I can't really determine from your error message what is causing this though - could you please post the full stack trace?

                • 5. Re: Seam 2.0.2 Remoting In Eclipse
                  anand s Newbie

                  Hi Shane,

                  I am trying to deploy the project as a war and not an ear. So I heard there are issues with the same.  I am not sure but I heard that EJB's must be deployed as EARS

                  What should I do to deploy the application as a war file ?