0 Replies Latest reply on Mar 28, 2009 12:04 AM by Alex Georgescu

    How do I use Jboss seam contexts with web services?

    Alex Georgescu Newbie

      Hi, I am new to Jboss seam but I am having a great time learning it.

      I am trying to use seam components with a very simple web service and I keep receiving:
      java.lang.IllegalStateException: No application context active

      Here is my code and this error happens when i call Component.getInstance.

      @WebService(name = "SampleService", serviceName = "SampleService")
      public class SampleService {
           public DefaultWebServiceResponse runDbScript(String username, String password,String env,
                     String database, String script)
                DefaultWebServiceResponse response =  new DefaultWebServiceResponse();
                        Queries queries = (Queries) Component.getInstance("queries");
                List<Users> list = queries.getUsers(username, password);
                if (list.size() == 0)
                     response.setDescription("User/password combination does not match");
                     return response;
                // return response          
                response.setDescription("Just a stub");
                return response;

      And the queries Component:

      public class Queries implements QueriesLocal{
           EntityManager entityManager;
           public Queries()
           public List<Users> getUsers(String username, String password)
              List<Users> matchedUsers = entityManager.createQuery(
                        "from Users where username= " + username +
                        " and password = " + password
              return matchedUsers;

      I have also added standard-jaxws-endpoint-config.xml to META-INF folder. The web service without seam works well and so does the rest of the user interface. My only issue is that I cannot use seam components inside the web calls.

      Since this is a web service call, do I need to do anything else to enable seam contexts to work?