4 Replies Latest reply on Jun 9, 2009 8:51 PM by he youlin

    Error Integrating Seam with Spring Web Services

    Neil C Novice

      I have a web application written almost entirely with Seam, and Seam manages all the web entry points to it. However, a small part of the application exposes some of the same functionality used by web clients through SOAP-based web services.  I have developed this using Spring Web Services.


      The two components--the web entry-point component and the web service component--are largely separated from each other.  Still, I will be injecting some Seam components into my Spring WS beans to do the work of the service.


      I have developed an XML schema for the service and used SWS' capabilities to publish a WSDL as part of the Seam web application deployment.  That works just fine.  I can deploy and look at the WSDL under the web application context through the browser perfectly.  The issue comes up when I try to inject my Seam component into the actual service.


      I have included jboss-seam-ioc.jar in my deployment, and here is the relevant portion of my Spring configuration file (where the Seam component is named search):


          <bean id="searchService" class="com.myapp.web.ws.search.SearchService">
              <property name="search" ref="internalSearch"/>
          </bean>
          <seam:instance id="internalSearch" name="search"/>
      



      When I deploy the application with the Seam stuff in the Spring config file and then try to view the WSDL, I get this error:



      java.lang.IllegalStateException: No application context active
           at org.jboss.seam.Component.forName(Component.java:1912)
           at org.jboss.seam.Component.getInstance(Component.java:1972)
           at org.jboss.seam.Component.getInstance(Component.java:1950)
           at org.jboss.seam.Component.getInstance(Component.java:1944)
           at org.jboss.seam.Component.getInstance(Component.java:1939)
           at org.jboss.seam.ioc.spring.SeamTargetSource.getTarget(SeamTargetSource.java:85)
           at org.jboss.seam.ioc.spring.SeamFactoryBean.createInstance(SeamFactoryBean.java:97)
           at org.springframework.beans.factory.config.AbstractFactoryBean.getObject(AbstractFactoryBean.java:146)
           at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:121)
           at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
           at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:98)
           at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1288)
           at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:275)
           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
           at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
           at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
           at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
           at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
           at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
           at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
           at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
      



      Here is the relevant part of my web.xml file:



          <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>/WEB-INF/spring-beans.xml</param-value>
          </context-param>
          <!-- Seam -->
          <listener>
              <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
          </listener>
          <listener>
              <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
          </listener>
          <filter>
              <filter-name>Seam Filter</filter-name>
              <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
          </filter>
          <filter-mapping>
              <filter-name>Seam Filter</filter-name>
              <url-pattern>/*</url-pattern>
          </filter-mapping>
          <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>
          <!-- Faces Servlet -->
          <servlet>
              <servlet-name>Faces Servlet</servlet-name>
              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
          </servlet>
          <servlet-mapping>
              <servlet-name>Faces Servlet</servlet-name>
              <url-pattern>*.html</url-pattern>
          </servlet-mapping>
          <!-- Spring Web Services -->
          <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          </listener>
          <servlet>
              <servlet-name>ws</servlet-name>
              <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
          </servlet>
          <servlet-mapping>
              <servlet-name>ws</servlet-name>
              <url-pattern>/services</url-pattern>
          </servlet-mapping>
          <servlet-mapping>
              <servlet-name>ws</servlet-name>
              <url-pattern>*.wsdl</url-pattern>
          </servlet-mapping>
          <servlet-mapping>
              <servlet-name>ws</servlet-name>
              <url-pattern>*.ws</url-pattern>
          </servlet-mapping>
      



      Any insight into where I am off with the configuration is appreciated. 


      Thanks.