This discussion is archived
4 Replies Latest reply: Jan 25, 2013 8:36 AM by 935795 RSS

Classloading doubt

935795 Newbie
Currently Being Moderated
Hello,

I have doubt on Weblogic classloading and request your help.

I understood or otherwise from a web link on classloading that ewvery application has its own classloaders.

My EAR contains 4 WARS. Each war has a web-inf\lib and has libraries that are present in other web-in\lib too. Some of the libraries are also present in weblogic. I am at the moment playing with weblogic-application.xml and trying my hand on using <classloader-structure> tag.

My doubts are :
Is it okay to have the same libraries in different web-inf\lib?
Is <module-uri> referred in weblogic-application.xml same as <web-uri> specified in application.xml ?
I don't have the <classloader-structure> at the moment, but getting classcastexception. Wouldn't weblogic load either application libraries or weblogic's and sort the preference by itself?

Thanks for your patience.
  • 1. Re: Classloading doubt
    Jeets Journeyer
    Currently Being Moderated
    Is it okay to have the same libraries in different web-inf\lib?

    Yes! you can have shared libraries for web applications. You use <library-ref> for the same.

    Is <module-uri> referred in weblogic-application.xml same as <web-uri> specified in application.xml ?

    Yes! it is same.

    I don't have the <classloader-structure> at the moment, but getting classcastexception. Wouldn't weblogic load either application libraries or weblogic's and sort the preference bty itself?

    Please provide us the exception and weblogic-application.xml you have.

    Hope this helps.

    Jeets.
  • 2. Re: Classloading doubt
    935795 Newbie
    Currently Being Moderated
    Hi,

    The weblogic-application.xml is

    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
    <application-param>
    <param-name>webapp.encoding.default</param-name>
    <param-value>UTF-8</param-value>
    </application-param>
    <prefer-application-packages>
    <package-name>antlr.*</package-name>
              <package-name>org.apache.log4j.*</package-name>
              <package-name>javax.xml.*</package-name>
    </prefer-application-packages>
         <classloader-structure>
              <classloader-structure>
                   <module-ref>
                        <module-uri>anite-stp-web.war</module-uri>
                   </module-ref>
              </classloader-structure>
              <classloader-structure>
                   <module-ref>
                        <module-uri>trxe-web.war</module-uri>
                   </module-ref>
              </classloader-structure>
              <classloader-structure>
                   <module-ref>
                        <module-uri>anite-espmanager-web.war</module-uri>
                   </module-ref>
              </classloader-structure>
              <classloader-structure>
                   <module-ref>
                        <module-uri>aks-web.war</module-uri>
                   </module-ref>
              </classloader-structure>
         </classloader-structure>     
    </weblogic-application>

    The Exception is
    Caused By: java.lang.ClassCastException: weblogic.xml.jaxp.RegistryDocumentBuilderFactory cannot be cast to javax.xml.parsers.DocumentBuilderFactory
         at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:139)

    The problem I faced and solved is listed in another topic "HqlToken and antlr". One of the suggestion was to use <classloader-structure>. So I spawned a new topic on this.

    My thought was to load anite-stp-web.war and then any other wars. The expectation is there is one xmlparserapi.jar inside each of my web-inf\lib that contains javax.xml classes. I felt weblogic got confused with the javax.xml of its own libraries. The above solution is to come out of that problem.
  • 3. Re: Classloading doubt
    935795 Newbie
    Currently Being Moderated
    Hi,

    One experiement I did was to remove the xmlParserAPIs-2.0.2.jar from my package, thereby relying on weblogic's parsers. That might have solved this particular problem and I got log4j classcastexception. When I applied the same prcedure, i recieved slf4j classcastexception. The same solution for slf4j did not work. After that there was a dead end. So I undid this experiment of using weblogic's libraries, and preferred to apply the solution suggested in 'HqlToken and antlr'. Does this give you an idea or way out please?

    regards,
    Rajesh
  • 4. Re: Classloading doubt
    935795 Newbie
    Currently Being Moderated
    The problem was to do with xmlparsers api jars and the javax.xml in rt.jar. I removed the former from my war and it worked.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points