Results 1 to 4 of 4

Thread: Integrating Logging with Main EJB Application

  1. #1

    Default Integrating Logging with Main EJB Application

    Hi,
    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.

    Code:
    DOMConfigurator.configure("log4j.xml");  
    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
    Damodar

  2. #2
    Join Date
    May 2011
    Posts
    1

    Default

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

  3. #3

    Default

    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.

    Code:
    @Stateless(name="Controller")
    @Interceptors(SampleLogger.class)
    public class Controller implements ControllerRemote, ControllerLocal {
    		public void businessMethod1(){}
    }
    
    
    public class SampleLogger(){
                    @AroundInvoke
                    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
    Damodar

  4. #4
    Join Date
    May 2011
    Posts
    1

    Default

    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);
    reporterService.fireEngine();

    The following is my SERVICE CODE :

    HTML Code:

Tags for this Thread

Posting Permissions

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