Pages

Friday, September 14, 2012

How to set classpath in weblogic server

Developers like me might have struggled to figure out a way to set some jars in the CLASSPATH of the weblogic server to access and load the correct Java classes when the server starts. So, I thought of putting my solution in this blog, which might be useful for some developers.

Basically you need to modify the WEBLOGIC_CLASSPATH environment variable in commEnv.cmd file located at <WL_HOME>\common\bin

In my case it is C:\11.1.1.6\wlserver_10.3\common\bin\commEnv.cmd

Append the WEBLOGIC_CLASSPATH variable at the end with the location of jars to be loaded as below:
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%FEATURES_DIR%\weblogic.server.modules_10.3.5.0.jar;%WL_HOME%\server\lib\webservices.jar;%ANT_HOME%/lib/ant-all.jar;%ANT_CONTRIB%/lib/ant-contrib.jar;C:\Users\uagarwal\Downloads\lib\tdgssconfig.jar;C:\Users\uagarwal\Downloads\lib\terajdbc4.jar;
Here, I have set 
C:\Users\uagarwal\Downloads\lib\tdgssconfig.jar; 
C:\Users\uagarwal\Downloads\lib\terajdbc4.jar; 
at the end of the WEBLOGIC_CLASSPATH. 
Alternatively, you can put the jars in <WL_HOME>\server\lib where other jars are present. But don't forget to restart the server, in order to pick the latest classes by the server.

10 comments:

  1. Hi Umesh,

    I created MY SQL data source in 11g. But also copied "mysql-connector-java-5.1.25-bin" to class path via both the suggestion. But still I am getting this exception.

    Exception
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.NoClassDefFoundError, msg=com/mysql/jdbc/MySQLConnection
    at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(ApplicationPoolImpl.java:4740)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareApplicationModule(ApplicationPoolImpl.java:2537)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2347)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:3246)
    at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:572)
    Truncated. see log file for complete stacktrace


    Can you please suggest, what went wrong?

    Thanks, Ankur

    ReplyDelete
    Replies
    1. Did you restart the server as I mentioned above.
      And try adding the jars to your project and compile once.
      Hope it helps.

      Thanks,
      Umesh

      Delete
  2. Hi Umesh
    Thanks for the info. If I add jars to the weblogic-classpath then my project works fine but not in case of adding jars to \server\lib folder.
    Anyways, I wanted to know if there is some other way or if we could modify the weblogic-classpath programmtically (directly from my app) because I do not want to do any manual changes in weblogic...

    Thanks
    Ashu

    ReplyDelete
    Replies
    1. Hi Ashu,
      I am not sure of modifying the weblogic-classpath programatically.
      If you come across it, please let me know.

      Thanks,
      Umesh

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Sure Umesh.
      If not programatically, is there any other to refer those jars from my .ear??
      My .ear structure is:
      ear
      -lib
      -META-INF
      >weblogic-application.xml
      >application.xml
      -all ejb-jars
      -war

      Actually I need to refer those jars from one of my ejb-jar. I could place the jars in lib folder of ear but I dont want to that, neither I want to modify weblogic classpath manually. So please let me know if you know something in this regard.

      Thanks

      Delete
    4. This comment has been removed by the author.

      Delete
  3. http://stackoverflow.com/questions/6551464/deploymentexception-class-not-found-on-weblogic-admin-server-11g

    ReplyDelete
  4. That was quite useful for me , thanks for posting this .
    --Anmol

    ReplyDelete
  5. Online Bet356 Casino Review 188bet 188bet 1XBET 1XBET rb88 rb88 673Play free online blackjack in lacbet.com

    ReplyDelete