Home > Software engineering >  Oracle Weblogic - Cannot load driver: org.postgresql.Driver
Oracle Weblogic - Cannot load driver: org.postgresql.Driver

Time:11-10

I am new in the configuring classpath in weblogic and trying to set up postgre driver.

Environment(local): IntegratedWeblogicServer - Locally installed SOA suite 12.2.1.4 in windows 10

PostgreSQL Driver version location: C:\Oracle\Middleware\Oracle_Home\wlserver\server\lib\postgresql-42.2.24.jar

I followed the ff documentations of oracle: https://docs.oracle.com/cd/E24329_01/web.1211/e24487/weblogicserver.htm#ADMRF204

Add the one line in commEnv.cmd to set WEBLOGIC_CLASSPATH. Here is the copy.

@rem *************************************************************************
@rem This script is used to initialize common environment to start WebLogic
@rem Server, as well as WebLogic development.
@rem *************************************************************************

IF NOT DEFINED MW_HOME (
 IF NOT DEFINED WL_HOME (
  echo Please set MW_HOME or WL_HOME 
  IF DEFINED USE_CMD_EXIT (
   EXIT 1
  ) ELSE (
   EXIT /B 1
  )
 )
)

IF DEFINED WL_HOME (
 set MW_HOME=%WL_HOME%\..
) ELSE (
 set WL_HOME=%MW_HOME%\wlserver 
)

set WEBLOGIC_CLASSPATH=%WL_HOME%\server\lib\postgresql.jar;%WEBLOGIC_CLASSPATH%

FOR %%i IN ("%MW_HOME%") DO SET MW_HOME=%%~fsi
FOR %%i IN ("%WL_HOME%") DO SET WL_HOME=%%~fsi
    
call %MW_HOME%/oracle_common/common/bin/commBaseEnv.cmd
call %MW_HOME%/oracle_common/common/bin/commExtEnv.cmd

After applying changes, start again the IntegratedWeblogicServer, Tried to set up the datasource in weblogic, test connection and still got the same error.

11 8, 21 1:52:21,689 PM SGT> <Error> <Console> <BEA-240003> <Administration Console encountered the following error: java.lang.ClassNotFoundException: Cannot load driver: org.postgresql.Driver
    at weblogic.jdbc.common.internal.DataSourceUtil.testConnection0(DataSourceUtil.java:368)
    at weblogic.jdbc.common.internal.DataSourceUtil.access$000(DataSourceUtil.java:24)
    at weblogic.jdbc.common.internal.DataSourceUtil$1.run(DataSourceUtil.java:287) `
 

Also, DefaultDomain doesnt have /lib

DefaultDomain

Anything that I've missed out?

CodePudding user response:

Copy the postgresql-42.2.24.jar into your domain's lib folder instead of the weblogic installation folder.

eg. $JDEV_USER_DIR/system12.2.1.4.42.190911.2248/DefaultDomain/lib.

Any jars placed in that location will be added to the server classpath when it is booted.

  • Related