This discussion is archived
8 Replies Latest reply: Jul 29, 2013 1:13 AM by 1e0d842a-b6bd-48f3-8e9d-b21735bb8678 RSS

WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)

890593 Newbie
Currently Being Moderated
Hi, I'm facing a problem on WLS10.3.5 + Spring 3.1 + Hibernate 3.6.7 connecting to Apache Derby 10.8.1.2.

The Spring ContextLoaderListener configured in the web.xml is failing since the the entityManagerFactory creation failed - since the derby datasource defined in WLS could not be created. Root cause - ClassNotFoundException by the weblogic.utils.classloaders.GenericClassLoader. I've tried adding derbyclient.jar in all locations - WLS server lib, domain lib, WEB-INF/lib, VM_HOME/jre/lib/ext, and also tried setting PRE_CLASSPATH. Also tried keeping a duplicate copy of the jar in all the locations at the same time. No luck.

Caused By: java.lang.ClassNotFoundException: org.apache.derby.client.am.ConnectionCallbackInterface
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
Truncated. see log file for complete stacktrace

The datasource is created successfully from the console so there's no problem with the jar file. I could also load the above class using a test JSP from another bare WAR deployed into the same domain.

I'm out of ideas and need some options to explore. btw, I specified in the weblogic.xml that the antlr.* classes should be taken from the application. Also tried this option for org.apache.derby.* classes.

This looks like a buggy class loader problem. Any ideas or solution please?
  • 1. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    RenévanWijk Oracle ACE
    Currently Being Moderated
    "The datasource is created successfully from the console so there's no problem with the jar file."

    Did you also test the data source when you created it?
    - when yes then WebLogic can indeed find the derbyclient.jar as the driver org.apache.derby.jdbc.ClientDriver is part of it.

    "I specified in the weblogic.xml that the antlr.* classes should be taken from the application. Also tried this option for org.apache.derby.* classes."

    Have you only defined a
    <prefer-application-packages>
        <package-name>antlr.*</package-name>
        <package-name>org.apache.derby.*</package-name>
    </prefer-application-packages>
    in weblogic.xml or did you also turn on prefer-web-inf-classes?

    It is smart to start from scratch and delete all the jar files in all the directories. To make the derbyclient.jar part of the WebLogic classpath you can do the following:

    - edit setDomainEnv: When you open setDomainEnv there is an entry like "SET THE CLASSPATH". Just before - if [ "${JAVA_VENDOR}" != "BEA" ] ; then
    you can put something like: CLASSPATH=${CLASSPATH}${CLASSPATHSEP}location/derbyclient.jar

    If the class must be available on every server in a cluster, you can edit the commEnv file (located in the ${WL_HOME}/common/bin directory)
    Search for the entry "set up WebLogic Server's class path". And below the WEBLOGIC_CLASSPATH you can add something like:
    WEBLOGIC_CLASSPATH=${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}location/derbyclient.jar

    Hope this helps you a little
  • 2. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    890593 Newbie
    Currently Being Moderated
    René, thanks for the suggestions.

    Yes, I also tested the datasource from the console.
    No, I did not turn on prefer-webinf-classes.
    Yes, I also started from scratch and this didn't help either.

    I will try out your idea to set the CLASSPATH variable. I set the PRE_CLASSPATH and it didn't help so I don't have much hopes. But I will still give it a shot.

    Looking at the stack trace, there's to-fro hops from java.lang.ClassLoader to weblogic.utils.classloaders.GenericClassLoader and back. Any means to print out the associated classpath that each classloader instance is associated with? Adding the jar file to VM_HOME/jre/lib/ext folder should've not given a ClassNotFoundException. I get a feeling that the a custom classloader is created to search in a predefined fixed path.

    btw, This is a XA datasource for JTA. I also have a non JTA datasource that seems to load fine - from the logs.
  • 3. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    RenévanWijk Oracle ACE
    Currently Being Moderated
    There is indeed a line in the stacktrace that says - weblogic.utils.classloaders.GenericClassLoader.findLocalClass
    looks like it is trying to load the class from the application classloader. Then, the class must present either
    in the WEB-INF/lib directory or through the classpath attribute in the manifest file.

    Could you try deleting the prefer-application-packages (of course you have to have this for the antlr otherwise the
    Hibernate queries are not parsed correctly) - but just to test this case, to see if some classloader filter is messing
    things up. When this indeed the case, you can also try using prefer-web-inf-classes.

    Note that when you tested the data source in the console (which went right) the jar file is certainly on the classpath.
    Otherwise you would have gotten an error indicating that used driver could not be found.

    How does the structure of your WAR file look?
  • 4. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    890593 Newbie
    Currently Being Moderated
    Yes. I also tested by deleting the prefer-application-packages entry from weblogic.xml. It didn't fix the problem.

    I have a single WAR file deployed directly and not packaged in an EAR file.

    MyWAR
    - pages //contains the JSPs in various sub-directories
    - WEB-INF
    - classes
    struts.xml
    - lib
    //all my dependent jar files, including jar files of my custom java projects containing DAOs, entities and other spring beans.
    applicationContext.xml
    web.xml
    weblogic.xml

    As I write this, I'm thinking I'll create an EAR just to see if it helps.
  • 5. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    RenévanWijk Oracle ACE
    Currently Being Moderated
    Your WAR looks fine.

    Note that when using an EAR, you can use the APP-INF/lib for your jars. This will automatically be picked up.

    http://middlewaremagic.com/weblogic/?p=6725
  • 6. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    922934 Newbie
    Currently Being Moderated
    Hi,
    Did you find fix the problem. i am having the same problem.

    Thanks in advance
  • 7. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    708246 Newbie
    Currently Being Moderated
    Im also facing the same issue. Any solution?
  • 8. Re: WebLogic 10.3.5 ClassNotFoundException (jar file is available in classpath)
    1e0d842a-b6bd-48f3-8e9d-b21735bb8678 Newbie
    Currently Being Moderated

    I was facing the same problem and I use Eclipse IDE. I fixed with Clean all projects

Legend

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