7 Replies Latest reply on Jan 9, 2009 11:11 AM by learner.klearchosklearchou.yahoo.co.uk

    Web Services

      Hello to all,

      I am trying to make a simple web service call based on the seambay example.
      So I did the following:

      1. Created a project with seam-gen that supports EJB's (jar option).
      2. Created some simple model and action classes that through the web browser works fine.
      3. Created the services class according to the seambay.
      4. Created a standalone client that calls this web service.

      Everything ok up to now.

      My problem starts when I want to do something useful inside the web service method.
      For example I am trying to access a class like this:
      DocumentAction da = (DocumentAction) Component.getInstance(DocumentAction.class);

      I receive an error from the application server like the following:
      java.lang.IllegalStateException: No application context active

      Could you please point me what I miss here.
      The class from which I call the Component.getInstance( is something like this:

      @WebService(name = "DocumentServices", serviceName = "DocumentServices")
      public class DocumentServices implements DocumentServicesRemote
      and inside the web method

          public String registerDocument()

      I try to get the instance from where I receive the error.

      Thank you in advance for your help.

        • 1. Re: Web Services

          what happens if you make it a seam object, annotate with @Name ?

          • 2. Re: Web Services

            Do you have a correctly configured standard-jaxws-endpoint-config.xml in your META-INF dir?

            • 3. Re: Web Services
              Hello to all,

              sorry for my late answer but yesterday I was not available.

              I have included the xml that the seam reference states.
              The object already contains the @Name.
              More specifically

              The object is an action that I already use for Seam.
              The first line in the web service method is the following:
                      System.out.println("Application context " + Contexts.isApplicationContextActive() );
                      System.out.println("Application Context is " + Contexts.getApplicationContext() );

              that returns false and null respectively.

              What else do you think it could be wrong?

              Thank you for your help.
              • 4. Re: Web Services

                Hello I have just now tried to place the @Name at the services object basically and not to the object that I want to receive using the getInstance and it worked!

                But why at the Seambay example there is no such an annotation (@Name) and it works?

                Tank you again.

                • 5. Re: Web Services

                  I have changed the generated task of the build.xml (seam-gen)
                  and I have simply inserted this extra line:
                  <include name="standard-jaxws-endpoint-config.xml" />
                  after the ejb-jar.xml

                          <target name="jar" depends="compile,copyclasses"
                                          description="Build the distribution .jar file">
                                  <copy todir="${jar.dir}">
                                          <fileset dir="${basedir}/resources">
                                                  <include name="seam.properties" />
                                                  <include name="*.drl" />
                                  <copy todir="${jar.dir}/META-INF">
                                          <fileset dir="${basedir}/resources/META-INF">
                                                  <include name="ejb-jar.xml" />
                                                  <include name="standard-jaxws-endpoint-config.xml" />
                                  <copy tofile="${jar.dir}/META-INF/persistence.xml"
                                  <copy tofile="${jar.dir}/import.sql"

                  Is this enough?

                  Thank you,
                  • 6. Re: Web Services
                    Hello to all,

                    in order to summarize up to now what I have done.
                    1. I have included the standard-jaxws-endpoint-config.xml file that in the past I have wrongly just placed it in the correct folder without changing the build.xml file.

                    2. I removed the @Name("services") from the DocumentServices class because it was not needed anymore (as in seambay example).

                    3. I have one action called RegisterDocumentAction that contains a register method.
                    I have inserted a @Begin like this
                            @Begin(join = true)
                         public String register()

                    4. When I run the web service I receive an error like this:

                    14:34:07 ERROR [STDERR] java.lang.IllegalStateException: Transaction begin not d
                    etected, try installing transaction:ejb-transaction in components.xml
                    14:34:07 ERROR [STDERR]         at org.jboss.seam.transaction.SeSynchronizations

                    5. So I tried to follow the error message and I have inserted the <transaction:ejb-transaction/> at the components.xml
                    Unfortunately here the Jboss could not start with the following message:

                    15:04:39 ERROR [core.ContainerBase.[jboss.web].[localhost].[/documnetReader]] Ex
                    ception sending context initialized event to listener instance of class org.jbos
                    java.lang.RuntimeException: error while reading /WEB-INF/components.xml
                            at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Init
                            at org.jboss.seam.init.Initialization.create(Initialization.java:104)
                            at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.j
                            at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
                            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
                            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
                            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
                            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

                    Do you have please any ideas regarding the source of the problem ?

                    Best regards,
                    • 7. Re: Web Services
                      Finally I found the problem.

                      The namespace must be declared at the beginning of the XML.
                      The name space is

                      Thus the complete XML when we add the <transaction:ejb-transaction />
                      at the components.xml is
                      <?xml version="1.0" encoding="UTF-8"?>
                                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
                                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
                                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
                                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
                                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
                                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">