Friday March 12, 2010

Example: Common Troubleshooting flags

Having trouble with a test? It's bound to happen eventually. We've coded up a little example that employs some of the more common ways to get more information to help resolve issues.

The heart of the example is the following setup method:

public void setUp() throws Exception {
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    p.put("movieDatabase", "new://Resource?type=DataSource");
    p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");

    // These two debug levels will get you the basic log information
    // on the deployment of applications. Good first step in troubleshooting.
    p.put("log4j.category.OpenEJB.startup", "debug");
    p.put("log4j.category.OpenEJB.startup.config", "debug");

    // This log category is a good way to see what "" options
    // and flags are available and what their default values are
    p.put("log4j.category.OpenEJB.options", "debug");

    // This will output the full configuration of all containers
    // resources and other openejb.xml configurable items.  A good
    // way to see what the final configuration looks like after all
    // overriding has been applied.
    p.put("log4j.category.OpenEJB.startup.service", "debug");

    // Want timestamps in the log output?
    p.put("log4j.appender.C.layout", "org.apache.log4j.PatternLayout");
    p.put("log4j.appender.C.layout.ConversionPattern", "%d - %-5p - %m%n");

    // Will output a generated ejb-jar.xml file that represents
    // 100% of the annotations used in the code.  This is a great
    // way to figure out how to do something in xml for overriding
    // or just to "see" all your application meta-data in one place.
    // Look for log lines like this "Dumping Generated ejb-jar.xml to"
    p.put("openejb.descriptors.output", "true");

    // Setting the validation output level to verbose results in
    // validation messages that attempt to provide explanations
    // and information on what steps can be taken to remedy failures.
    // A great tool for those learning EJB.
    p.put("openejb.validation.output.level", "verbose");

    initialContext = new InitialContext(p);

    initialContext.bind("inject", this);

In practice it is not a good idea to enable so many debug flags as the output will be too much. Best to start with one, read the log output, and see if that doesn't give some direction. If not, disable it and move on to the next.



Posted by ingrossasli1977 on July 18, 2019 at 12:48 PM EDT #

amazing work please you look at me my work.i am new amazing colors and setup! it all works great! I love it!

Posted by health on July 20, 2019 at 06:58 PM EDT #

Post a Comment:
Comments are closed for this entry.



Hot Blogs (today's hits)

Tag Cloud