Announcement Announcement Module
Collapse
No announcement yet.
Failed to Read Schema for spring-aop-2.0.xsd Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Failed to Read Schema for spring-aop-2.0.xsd

    Hi i get this error message below when is was testing my sampe application copied from Chapter 6. Aspect Oriented Programming with Spring

    Code:
    schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/aop/spring-aop-2.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    Below is my SpringAop.xml
    Code:
    <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"
          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">
    
       <!-- this is the object that will be proxied by Spring's AOP infrastructure -->
       <bean id="fooService" class="biz.DefaultFooService"/>
    
       <!-- this is the actual advice itself -->
       <bean id="profiler" class="biz.SimpleProfiler"/>
    
       <aop:config>
          <aop:aspect ref="profiler">
    
             <aop:pointcut id="theExecutionOfSomeFooServiceMethod"
                        expression="execution(* biz.FooService.getFoo(String,int))
                        and args(name, age)"/>
    
             <aop:around pointcut-ref="theExecutionOfSomeFooServiceMethod"
                      method="profile"/>
    
          </aop:aspect>
       </aop:config>
    
    </beans>

    Any My Boot java is as below

    Code:
    import org.springframework.beans.factory.BeanFactory;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    
    public final class Boot {
    
       public static void main(final String[] args) throws Exception {
          BeanFactory ctx = new ClassPathXmlApplicationContext("SpringAop.xml");
          FooService foo = (FooService) ctx.getBean("fooService");
          foo.getFoo("Pengo", 12);
       }
    }


    Any idea?
    i copied this example from Spring Chapter and i run i ran to above error.

    Thanks

  • #2
    Hi

    Okay for the time being it is okay ,
    what i did i save as the aop.xsd and save in my local computer

    but after i test . i didnt see any interceptor lines

    here is my output
    Code:
    0 [main] INFO xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [SpringAop.xml]
    889 [main] INFO xml.DefaultNamespaceHandlerResolver  - Ignoring handler [org.springframework.scripting.config.LangNamespaceHandler]: class not found
    889 [main] INFO xml.DefaultNamespaceHandlerResolver  - Ignoring handler [org.springframework.ejb.config.JeeNamespaceHandler]: class not found
    920 [main] INFO support.ClassPathXmlApplicationContext  - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=18468004]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [fooService,profiler,org.springframework.aop.config.internalAutoProxyCreator,theExecutionOfSomeFooServiceMethod]; root of BeanFactory hierarchy
    936 [main] INFO support.ClassPathXmlApplicationContext  - 4 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=18468004]
    951 [main] INFO core.CollectionFactory  - JDK 1.4+ collections available
    967 [main] INFO core.CollectionFactory  - Commons Collections 3.x available
    1107 [main] INFO framework.DefaultAopProxyFactory  - CGLIB2 available: proxyTargetClass feature enabled
    1201 [main] INFO support.ClassPathXmlApplicationContext  - Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    1201 [main] INFO support.ClassPathXmlApplicationContext  - Unable to locate MessageSource with name 'messageSource': using default [[email protected]e]
    1216 [main] INFO support.ClassPathXmlApplicationContext  - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@12bb7e0]
    1216 [main] INFO support.DefaultListableBeanFactory  - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [fooService,profiler,org.springframework.aop.config.internalAutoProxyCreator,theExecutionOfSomeFooServiceMethod]; root of BeanFactory hierarchy]
    NAME +++>Pengo

    my Foo Service as below

    Code:
    interface FooService {
    
    	   String getFoo(String fooName, int age);
    	}
    
    
    public class DefaultFooService implements FooService {
    
    	   public String getFoo(String name, int age) {
    
    
    		   System.out.println("NAME +++>"+name);
    		   
    		   return "1";
    	   }
    	}


    My Profiles is as below

    Code:
    import org.aspectj.lang.ProceedingJoinPoint;
    import org.springframework.util.StopWatch;
    
    public class SimpleProfiler {
    
       public Object profile(ProceedingJoinPoint call, String name, int age) throws Throwable {
          StopWatch clock = new StopWatch(
                "Profiling for '" + name + "' and '" + age + "'");
          System.out.println("PROFILING for "+name);
          try {
             clock.start(call.toShortString());
             return call.proceed();
          } finally {
             clock.stop();
             System.out.println(clock.prettyPrint());
          }
       }
    }

    Anything wrong with my code??
    By right if this one works , i should be able to see "PROFILING" String


    here is my SpringAop.xml

    Code:
    <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"
          xsi:schemaLocation="http://www.springframework.org/schema/aop C:\aop.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
       <!-- this is the object that will be proxied by Spring's AOP infrastructure -->
       <bean id="fooService" class="biz.DefaultFooService"/>
    
       <!-- this is the actual advice itself -->
       <bean id="profiler" class="biz.SimpleProfiler"/>
    
       <aop:config>
          <aop:aspect ref="profiler">
    
             <aop:pointcut id="theExecutionOfSomeFooServiceMethod"
                        expression="execution(* biz.FooService.getFoo(String,int))
                        and args(name, age)"/>
    
             <aop:around pointcut-ref="theExecutionOfSomeFooServiceMethod"
                      method="profile"/>
    
          </aop:aspect>
       </aop:config>
    
    </beans>

    Comment


    • #3
      Any Idea Guys?

      Or do you have any simple working example for interceptors using Spring Aop?

      Thanks

      Comment


      • #4
        I have run your example using spring 2.0.3 snapshot and the interceptor works fine. Which version of spring is being used?
        My output is:
        Code:
        PROFILING for Pengo
        NAME +++>Pengo
        StopWatch 'Profiling for 'Pengo' and '12'': running time (millis) = 10
        -----------------------------------------
        ms     %     Task name
        -----------------------------------------
        00010  100%  execution(getFoo)
        cheers
        chris tam
        xenium

        Comment


        • #5
          Solution

          Probably you do not have spring-aop.jar in your path

          Comment

          Working...
          X