Results 1 to 4 of 4

Thread: AOP not working !!!

  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Default AOP not working !!!

    Hi,

    I'm trying to do a simple AOP example, but it's not working, I'm having problems in my XML configuration file and here's the my XML file:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans
    PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

    <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/schem...-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <bean id = "singerAspect" class = "vassili.SingerAspect"/>

    <aop:config>
    <aop:aspect ref = "singerAspect">
    <aopointcut id = "singerPointcut"
    expression = "execution(* *.sing(..)) and target(bean)"/>

    <aop:before method = "beforeSinging" pointcut-ref = "singerPointcut" arg-names = "bean"/>
    <aop:after-returning method = "afterSinging" pointcut-ref = "singerPointcut" arg-names = "bean"/>
    </aop:aspect>
    </aop:config>

    </bean>

    Is there something wrong with the XML file ?

    Please i need help ...

    Thanks in advance ...

  2. #2
    Join Date
    Sep 2007
    Location
    Oceanside, CA
    Posts
    187

    Default

    A couple of issues:

    1. Your XML config file contains both DTD and XML schema declarations. Remove the following:

    Code:
    <!DOCTYPE beans
    PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    2. Your config file should be terminated with

    Code:
    </beans>
    instead of

    Code:
    </bean>
    Mike Bingham

  3. #3
    Join Date
    Oct 2007
    Posts
    2

    Default

    I did but it did not work, it's saying:

    Document root element "beans", must match DOCTYPE root "null"

    !!!

    What is the problem ?

  4. #4
    Join Date
    Sep 2007
    Location
    Oceanside, CA
    Posts
    187

    Default

    Are you using Spring 2.0+? You would see this error if you tried to use XML Schema-based configuration with Spring 1.2.9 or earlier. Configuration tags such as <aop:*> are only available with XML Schema-based configuration in Spring 2.0+.
    Mike Bingham

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •