How to Fix Java Version Errors When Deploying Applications on Oracle WebLogic Server

The root of the problem: Compilation with an incompatible JDK

The java.lang.UnsupportedClassVersionError error occurs when an application's bytecode was compiled with a JDK version higher than the one supported by the WebLogic runtime environment. Common example: compiling with JDK 11 and attempting to deploy on a server configured with JDK 8.

Step 1: Checking active versions

1.1. In the administration console

Go to Environment > Servers and select your server. On the Configuration > Server Start tab, review the JAVA_HOME values.

1.2. Via command line

Run on each node:
java -version
And for WebLogic specifically:
${DOMAIN_HOME}/bin/setDomainEnv.sh | grep "JAVA_VENDOR|JAVA_HOME"

Step 2: Modifying environment variables

2.1. Editing startup scripts

Locate and edit according to your operating system:
  • Unix/Linux: ${DOMAIN_HOME}/bin/setDomainEnv.sh
  • Windows: %DOMAIN_HOME%binsetDomainEnv.cmd
Modify or add:
export JAVA_HOME=/ruta/nueva/jdk1.8.0_291
export PATH=${JAVA_HOME}/bin:${PATH}

2.2. Node-specific configuration

For managed nodes, edit startManagedWebLogic.sh or its equivalent, ensuring consistency with the AdminServer.

Step 3: Clean server restart

  1. Stop all servers in the domain: ${DOMAIN_HOME}/bin/stopWebLogic.sh
  2. Delete temporary files in ${DOMAIN_HOME}/servers/{SERVER_NAME}/tmp
  3. Start the AdminServer: ${DOMAIN_HOME}/bin/startWebLogic.sh
  4. Verify the change with: ps -ef | grep java (Linux/Unix)

FAQs: Frequently asked questions

Can I configure different JDKs per application?

Yes, through the weblogic-application.xml file using <package-name> and specific directives. See the official documentation.

How can I check the compilation version of a .war/.ear file?

Use the command:
javap -verbose MyClass.class | grep "major"

Does WebLogic 12.2.1.4 support JDK 11?

Only partially for development. For production, WebLogic 14.1.1+ with an LTS JDK is required. Check the compatibility matrix.
Comparte este contenido:

Deja un comentario

🤖 IA

×
Hola. ¿Qué duda o consulta tienes sobre este contenido?