Battle_Slug
Battle_Slug

Reputation: 2105

Aspect of AspectJ with SpringAOP doesn't work

I know there are a lot of questions with the same problem, but I really don't understand what's the problem, as I tried to follow a lot of popular tutorials from scratch and it still doesn't work.

I ask you to have a look at my project here link to github and give a piece of advice as I really gave up to make it work.

I use Eclipse Luna + Tomcat 7, everything else you can see from the github as there is really not convenient to past everything here.


SOLVED: Actually, I think I need to be more specific with what I did to solve this puzzle: @tmarwen gave me a great tip off what could be wrong, I tested and saw that my dao-context.xml doesn't instantiate beans at all. So I moved all bean instantiation and <aop:aspectj-autoproxy /> to the separate config.xml file in the WEB-INF along with web.xml file. After that everything started working perfectly.

Upvotes: 0

Views: 105

Answers (1)

tmarwen
tmarwen

Reputation: 16354

First thing to note is that you had introduced a typo inside your root application config file path under web.xml file:

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:coms/config/dao-context.xml</param-value>
</context-param>

While it should be as follows (coms without an s):

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:com/config/dao-context.xml</param-value>
</context-param>

One more hint would be the context config file location, which I bet is not interpreted as a resource file at build time.

Since you are using Maven as your build tool, you may need to change the file location to be under the src/main/resoures directory (default directory being as the resources location for Maven), so that the whole path from your project root folder will be:

  • src/main/resoures/com/config/dao-context.xml

Upvotes: 1

Related Questions