Search code examples
log4jwebsphereclassloaderwebsphere-7

Rome 0.9 does not work correctly when module classloader order : parent last


Project description: WebSphere Application Server 7.Maven project which uses Rome0.9.

<dependency>
    <groupId>rome</groupId>
    <artifactId>rome</artifactId>
    <version>0.9</version>
</dependency> 

I was solving the problem with log4j not logging. The problem was that log4j.properties were already set in parent project. That's why I changed module's classloader order to Parent Last. It fixed the problem with log4j, but application now throws following exception:

ParsingFeedException: Invalid XML

I've checked parent loaded libraries and they include the same version of Rome - 0.9.

It seems that I'm missing some dependencies in my project. I wonder if there is some way to find out which libraries are missing?

Maybe you could suggest any other solution?


Solution

  • I don't have a solution for searching missing loaded library. However this workaround worked for me: I reconfigured log4j in static block of main servlet class.

    static Logger logger = LoggerFactory.getLogger(FeedAggregatorServlet.class);
    static {
         Properties p = new Properties();
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         try {
             p.load(classLoader.getResourceAsStream("/FeedAggregatorlog4j.properties"));
         } catch (IOException e) {
             e.printStackTrace();             
         }
        PropertyConfigurator.configure(p);
    }