4 Replies Latest reply on Mar 7, 2008 3:03 AM by gavin.king

    Spring context not started !!

    rmcalderero.rmcalderero.wanadoo.es

      Hi. I cant make seam start an spring application context. I have reduced the problem to a minimal configuration but still dont works.


      applicationContext.xml:


      <?xml version="1.0" encoding="UTF-8"?>
      
      <beans xmlns="http://www.springframework.org/schema/beans"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:aop="http://www.springframework.org/schema/aop"
                xmlns:tx="http://www.springframework.org/schema/tx"
                xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
      
      
         <bean id="servicioSpring" class="org.fundacionctic.tawmonitor.servicios.ServicioSpring" init-method="init"/>
      
      </beans>



      components.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  xmlns:jms="http://jboss.com/products/seam/jms"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:transaction="http://jboss.com/products/seam/transaction"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns:async="http://jboss.com/products/seam/async"
                  xmlns:spring="http://jboss.com/products/seam/spring"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd 
                       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd 
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                       http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.1.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
      
      
           <!-- Parametros generales de configuración -->
           <core:init debug="true"/>
           
          <core:manager conversation-timeout="300000" 
                        concurrent-request-timeout="500"
                        conversation-id-parameter="cid" />
      
           <spring:context-loader context-locations="/WEB-INF/applicationContext.xml"/> 
      ................
                        


      Class ServicioSpring


      package org.fundacionctic.tawmonitor.servicios;
      
      import org.apache.log4j.Logger;
      
      public class ServicioSpring {
      
           private static Logger logger = Logger.getLogger(ServicioSpring.class);
           
           public void init() {
                System.out.println("+++++++++++++++++ Se inicia el ServicioSpring");
           }
           
      }
      


      Seam writes in the log the inicialization of all the components of the application (seam-2.0.0.GA, tomcat 6) but nothing about the spring app context. The message in the init method of the bean is not logged either. Are we missing something?




        • 1. Re: Spring context not started !!
          rmcdonough

          Hey Ruben,


          We don't specify the path to the applictaionContext.xml in our components.xml. We simply have this:


          <spring:context-loader/>



          Seam will locate the applictaionContext.xml in /WEB-INF/applicationContext.xml by default. Additionally, in our applictaionContext.xml, we also define:


          <seam:configure-scopes/>



          That's really the only difference we have and we're able to inject Spring beans into our Seam components.


          Ryan-

          • 2. Re: Spring context not started !!
            rmcalderero.rmcalderero.wanadoo.es

            Than you, Ryan. I'll try your suggestions.


            Actually, we have found an exception in one of tomcat logs caused by aor configuration:



            06-mar-2008 16:18:33 org.apache.catalina.core.StandardContext listenerStart
            GRAVE: Excepción enviando evento inicializado de contexto a instancia de escuchador de clase org.jboss.seam.servlet.SeamListener
            java.lang.RuntimeException: Could not create Component: org.jboss.seam.ioc.spring.contextLoader
                 at org.jboss.seam.init.Initialization.addComponent(Initialization.java:976)
                 at org.jboss.seam.init.Initialization.installComponents(Initialization.java:903)
                 at org.jboss.seam.init.Initialization.init(Initialization.java:548)
                 at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
                 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
                 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
                 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
                 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
                 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
                 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
                 at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
                 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
                 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1206)
                 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
                 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
                 at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
                 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
                 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
                 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
                 at java.lang.Thread.run(Unknown Source)
            Caused by: java.lang.IllegalArgumentException: no such setter method: org.jboss.seam.ioc.spring.ContextLoader.contextLocations
                 at org.jboss.seam.util.Reflections.getSetterMethod(Reflections.java:236)
                 at org.jboss.seam.Component.initInitializers(Component.java:466)
                 at org.jboss.seam.Component.<init>(Component.java:263)
                 at org.jboss.seam.Component.<init>(Component.java:216)
                 at org.jboss.seam.init.Initialization.addComponent(Initialization.java:961)
                 ... 19 more



            Any idea about this?



            • 3. Re: Spring context not started !!
              rmcalderero.rmcalderero.wanadoo.es

              OK, in the first place the documentation should be updated because is wrong in this point. The class ContextLoader that makes the spring startup has a field called configLocations and not context-locations.


              So the configuration should be:


              <spring:context-loader configLocations="/WEB-INF/motorApplicationContext.xml"/> 




              Now the spring context is started.


              • 4. Re: Spring context not started !!
                gavin.king

                If there is a bug in the docs, please enter that in JIRA.


                P.S. It is probably supposed to be config-locations.