• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Execption in AOP Logging Program Issue

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I am new to spring and using spring 2.0. I am writing an AOP Logging program.

I am not getting compilation error.
While running the Main.java I am getting warning log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.

My doubt is what i will add the syntax of code in Main.java so that i am getting the output.

[b]”I have added the jar files in the class path .asm-2.2.3.jar, asm-commons-2.2.3.jar, asm-util-2.2.3.jar, aspectjrt.jar, aspectjweaver.jar, spring-aop.jar, spring.jar,log4j.jar, cglib-nodep-2.1_3.jar”


Below given is my code.

Greeter.java


DefaultGreeter.java


MethodLogger.java


Main.Java


MethodLoggerTest-context.xml


Please help/advise me on resolve this issue. .

Thanks for your time.


Best Regards,
Sumanta Panda

 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to provide log4j configuration. Consult log4j documentation.
 
sumanta panda
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
My doubt is what is the piece of code i will add in the Main.Java so that i am able to getting the output.

Please suggest.

Thanks for your time.
Regards,
Sumanta Panda
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In MethodLoggerTest-context.xml file, add an "id" to the bean


In your java code append these two lines :-

 
Ranch Hand
Posts: 85
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there are two issues here:

First: The warning you are getting is generated by log4j, You need to configure log4j to remove this warning. To do that create a log4j.xml configuration file and add a category like this. Also have commons-logging.jar on the class path.



Second: In Main you are just instantiating the spring context, you are not calling anything. So follow the suggsation by Anshu and call the greeter method.

Just a tiny change:


 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic