Announcement Announcement Module
Collapse
No announcement yet.
Unable to locate NamespaceHandler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to locate NamespaceHandler

    Hi all,

    I'm trying to integrate Spring into an Eclipse-RCP app, to user DAOs and services from an Appfuse-application. So far everything works well, I am already able to use the DAOs in my application.

    A problem still remains, when I try to load the service-beans into the the ApplicationContext, I get the following exception:

    Code:
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://www.springframework.org/schema/aop]
    Offending resource: class path resource [META-INF/applicationContext-service.xml]
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:261)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1111)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1104)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:458)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:353)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:100)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
    at foo.bar.rcp.wrapper.appfuse.AppfuseActivator.createContext(AppfuseActivator.java:66)
    The applicationContext.xml looks like this:
    Code:
    <?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">
    
        <aop:config>
            <aop:advisor id="userManagerTx" advice-ref="userManagerTxAdvice" pointcut="execution(* *..service.UserManager.*(..))" order="0"/>        
            <aop:advisor id="userManagerSecurity" advice-ref="userSecurityAdvice" pointcut="execution(* *..service.UserManager.saveUser(..))" order="1"/>
            <aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))" order="2"/>
        </aop:config>
        
        <tx:advice id="txAdvice">
            <tx:attributes>
                <tx:method name="get*" read-only="true"/>
                <tx:method name="*"/>
            </tx:attributes>
        </tx:advice>
    
        <tx:advice id="userManagerTxAdvice">
            <tx:attributes>
                <tx:method name="save*" rollback-for="UserExistsException"/>
            </tx:attributes>
        </tx:advice>
        
        <bean id="lookupManager" class="foo.bar.service.impl.LookupManagerImpl">
            <property name="lookupDao" ref="lookupDao"/>
        </bean>
    
        <bean id="manager" class="foo.bar.service.impl.BaseManager">
            <property name="dao" ref="dao"/>
        </bean>
    
        <bean id="userManager" class="foo.bar.service.impl.UserManagerImpl">
            <property name="userDao" ref="userDao"/>
        </bean>
    
        <bean id="userSecurityAdvice" class="foo.bar.service.UserSecurityAdvice">
            <property name="userCache" ref="userCache"/>
        </bean>
    
        <bean id="userCache" class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
            <property name="cache">
                <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
                    <property name="cacheManager">
                        <bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
                    </property>
                    <property name="cacheName" value="userCache"/>
                </bean>
            </property>
        </bean>
    
        <bean id="roleManager" class="foo.bar.service.impl.RoleManagerImpl">
            <property name="roleDao" ref="roleDao"/>
        </bean>
    
        <bean id="mailEngine" class="foo.bar.service.MailEngine">
            <property name="mailSender" ref="mailSender"/>
            <property name="velocityEngine" ref="velocityEngine"/>
        </bean>
    
        <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
            <property name="host" value="${mail.host}"/>
            <property name="username" value="${mail.username}"/>
            <property name="password" value="${mail.password}"/>
        </bean>
    
        <!-- Configure Velocity for sending e-mail -->
        <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
            <property name="velocityProperties">
                <props>
                    <prop key="resource.loader">class</prop>
                    <prop key="class.resource.loader.class">
                        org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
                    </prop>
                    <prop key="velocimacro.library"></prop>
                </props>
            </property>
        </bean>
    
        <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage" scope="prototype">
            <property name="from" value="${mail.default.from}"/>
        </bean>
    
        <!-- Add new Managers here -->
        <bean id="personManager" class="foo.bar.service.impl.PersonManagerImpl">
            <property name="personDao" ref="personDao"/>
        </bean>
    </beans>
    In my plugin I have the following jars:
    spring.jar (v2.0.4)
    aspectjweaver.jar
    acegi-security-1.0.2.jar

    Turning up the log-level of Spring to DEBUG didn't show any useful output. I already googled for solutions, but none of the threads and mailing list entries showed a solution, most were related to a bug in Spring 2.0 RC3.

    Maybe there's still a missing dependency or a problem with the OSGI-classloaders used in Eclipse. I'd be very grateful, if anyone could enlighten me on this one or give any useful hint to resolve the problem.

  • #2
    I have the same problem. Has anybody found a solution yet?

    Cheers,
    Bianca

    Comment


    • #3
      Me personally, I never solved it and gave up on integrating the Spring based core into Eclipse-RCP at that time as I had very limited time. It's most probably a dependency problem with missing AOP libraries, or transitive dependencies of the AOP libraries.

      Kind regards,
      Tobias
      Last edited by t0asti; Apr 25th, 2008, 01:27 PM.

      Comment


      • #4
        Well, I've a bit of time today so I'll try to get it to work. If I'm successful, I'll post the solution.

        Greetz
        Bianca

        Comment


        • #5
          The problem is that META-INF/spring.handlers is not visible. It is located in the spring jar file, but the eclipse plugin classloader mechanism will not be able to load it. Probably possible to configure that in some way.

          The easy solution is to copy spring.handlers from spring.jar to META-INF/spring.handlers in your plugin.

          Comment


          • #6
            I believe it's necessary to copy spring.schemas in addition to spring.handlers to make it work.

            Comment


            • #7
              The alternative is to use Spring Dynamic Modules, which will find and register all handlers in any jar/bundle, not just Spring.

              I'm guessing everyone is using the individual Spring libraries and not the big, single one? Using the big one will also fix this problem, but it might give you others...

              Comment


              • #8
                I had this problem too.

                Adding spring-modules-cache.jar to WEB-INF/lib fixed it.

                Comment

                Working...
                X