2 Replies Latest reply on Mar 4, 2009 5:59 PM by norman

    How to use Seam components in non-web applications

    seamless

      Hi



      Has anyone tried using Seam in a non-web application?


      I am trying to use seam components in a ear that does not have any war file. There are 3 ejb modules in the ear and one of these ear-module has few @Name annotated components too. This ear-module project follows maven structure where seam related files are placed as following:



      •     components.xml file is present in the src/main/resources/META-INF folder.

      •    seam.properties is present in src/main/resources folder(This file has no properties defined).

      •    Declaration for SeamInterceptor is present in ejb-jar.xml file as mentined in Seam documents.






      When I deploy my ejb-module binded within a ear build in JBoss, The console logs do not show any Seam components getting loaded. An attempt to explicitly get hold of seam components (using Component.getInstance(myComponent)) results in the following error log:



      javax.ejb.EJBException: java.lang.IllegalStateException: No application context active

      Clearly the problem is in the Seam initialization. Why is it that none of the Seam components in this jar are being installed? I do not find any helpful links to guide me on how to use Seam in a non-web application. Any pointers in this direction are highly appreciated.


        • 1. Re: How to use Seam components in non-web applications
          gjeudy

          I don't know any other way aside from bootstrapping Seam from a servlet container. Thats what SeamListener class does in your web.xml declaration.


          <listener>
              <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
          </listener>
          



          Well of course there is the testNG Seam superclass that also bootstraps Seam for testing purposes.


          I have looked at using Seam in a non-web app but didn't succeed, let me know if you do succeed.

          • 2. Re: How to use Seam components in non-web applications
            norman

            You'll need some code that gets executed as the application starts to initialize Seam by calling the correct methods on Lifecycle.  You can see ServletLifecycle as an example of what this looks like in a servlet environment.