Announcement Announcement Module
No announcement yet.
Integrating Logging with Main EJB Application Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integrating Logging with Main EJB Application

    I am using Spring AOP 3.1, AspectJ and log4j for logging (I am using annotations). So I created an Advice class, a Business Logic class and a Test class that has main method, in a standalone Java project. I put following two lines of code in the main method which loads the Spring Configuration XML and Logger XML file for me. This works fines. It logs the messages into specified log files.

    ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    Now I want to integrate this logging application with my main application. My application is as follows.
    1) JMS client project that produces and send a message to Weblogic 10.3.3 Server. This client is a standalone java project.
    2) The message is received by a MDB which passes it to an Stateless Session Bean.
    3) Stateless Session Bean calls a DAO which inturn makes JDBC calls to insert the message into database.
    Everything is working fine. But I donot know how to integrate the logging feature mentioned above with this main application so that it logs the messages for each method called in the above 3 steps.
    Basically, I need to know how can I load the Spring and Logging xml configuration files. Currently I am adding the above to lines of code in a static block in one of the classes in my AOP project.
    I have added all my ejb projects as well as spring aop project in a single ear which I am deploying on the server. But when I run the JMS client there is no logging taking place.

    Please help me with this. If you need any other detail then please let me know.

    Thanks and Regards

  • #2
    I also need answer of that problem, i hope for better solution here.


    • #3
      You can use interceptors to log the details. In the interceptor class write a method with @AroundInvoke annotation which is executed when a business method in the EJB class is called. Then bind that interceptor class with EJB using @Interceptor annotation. Following is the sample. Please read about Interceptors online for detailed explanation.

      public class Controller implements ControllerRemote, ControllerLocal {
      		public void businessMethod1(){}
      public class SampleLogger(){
                      public Object doLogging(InvocationContext ctx) throws Exception{
                             //write logging code here.

      If you like to use Spring AOP and AspectJ for logging in an EJB application then have a look at following topic.

      SpringAOP and AspectJ integration with EJB

      Thanks and Regards


      • #4
        The following is my code from where context is initialized and the service is called :

        ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[]{"com/gsm/reporter/context.xml"});

        ReporterService reporterService = appContext.getBean, Duplicate File Finder("reporterService",ReporterServi ceImpl.class);

        The following is my SERVICE CODE :

        HTML Code: